1 |
# Copyright (c) 2004 by Intevation GmbH |
2 |
# Authors: |
3 |
# Frank Koormann <[email protected]> |
4 |
# |
5 |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
7 |
|
8 |
|
9 |
"""Dialogs for alternative paths (path recovery). |
10 |
|
11 |
AltPathFileDialog: File dialog to specify alterative path. |
12 |
AltPathConfirmDialog: Confirm or cancel alternative path suggestion. |
13 |
""" |
14 |
|
15 |
from Thuban import _ |
16 |
|
17 |
import wx |
18 |
|
19 |
import os |
20 |
|
21 |
class AltPathFileDialog(wx.FileDialog): |
22 |
|
23 |
def __init__(self, filename): |
24 |
msg = _("Select an alternative data file for %s" % \ |
25 |
os.path.basename(filename)) |
26 |
|
27 |
wx.FileDialog.__init__(self, None, |
28 |
msg, |
29 |
os.path.dirname(filename), |
30 |
os.path.basename(filename), |
31 |
_("Shapefiles (*.shp)") + "|*.shp;*.SHP|" + |
32 |
_("All Files (*.*)") + "|*.*", |
33 |
wx.OPEN) |
34 |
|
35 |
def RunDialog(self): |
36 |
val = self.ShowModal() |
37 |
self.Destroy() |
38 |
if val == wx.ID_OK: |
39 |
return self.GetPaths()[0] |
40 |
else: |
41 |
return None |
42 |
|
43 |
class AltPathConfirmDialog(wx.MessageDialog): |
44 |
|
45 |
def __init__(self, filename): |
46 |
self.filename = filename |
47 |
msg = _("Found the following as an alternative for %s.\n%s\n\n Please confirm with Yes or select alternative with No." % (os.path.basename(filename), filename)) |
48 |
|
49 |
wx.MessageDialog.__init__(self, None, msg, _("Alternative Path"), |
50 |
wx.YES_NO|wx.YES_DEFAULT|wx.ICON_INFORMATION) |
51 |
|
52 |
def RunDialog(self): |
53 |
val = self.ShowModal() |
54 |
self.Destroy() |
55 |
if val == wx.ID_YES: |
56 |
return self.filename |
57 |
else: |
58 |
dlg = AltPathFileDialog(self.filename) |
59 |
fname = dlg.RunDialog() |
60 |
return fname |