/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/altpathdialog.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/Thuban/UI/altpathdialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2446 - (show annotations)
Mon Dec 13 11:52:34 2004 UTC (20 years, 2 months ago) by frank
Original Path: trunk/thuban/Thuban/UI/altpathdialog.py
File MIME type: text/x-python
File size: 2041 byte(s)
Alternative Path feature:
	* test/test_load.py (TestAltPath): New, tests for alternative path feature
	in load_session()
	(Shapefile_CallBack): Helper, implements controllable callback.

	* Thuban/UI/application.py (ThubanApplication.OnInit):
	Added "alt_path" to self.path
	(ThubanApplication.OpenSession): Added shapefile_callback as second
	callback similar to db_connection_callback.
	(ThubanApplication.run_alt_path_dialog): New, implementaion of
	shapefile_callback. In addition to raising the dialog the control of
	self.path('alt_path') is implemented here.

	* Thuban/Model/load.py (SessionLoader.__init__): Added shapefile_callback.
	(SessionLoader.open_shapefile): Open shapefile, eventually with
	alternative path. This wrapps the "theSession.OpenShapefile(filename)"
	formerly used in start_fileshapesource()/start_layer().
	(SessionLoader.start_fileshapesource): Call open_shapefile().
	(SessionLoader.start_layer): Call open_shapefile().
	(load_session): Added shapefile_callback.

	* Thuban/UI/altpathdialog.py: New, implements dialogs for alternative path
	feature (search / check).

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 from wxPython.wx import wxFileDialog, wxMessageDialog, wxOPEN, \
18 wxYES_NO, wxYES_DEFAULT, wxICON_INFORMATION, \
19 wxID_OK, wxID_YES
20
21 import os
22
23 class AltPathFileDialog(wxFileDialog):
24
25 def __init__(self, filename):
26 msg = _("Select an alternative data file for %s" % \
27 os.path.basename(filename))
28
29 wxFileDialog.__init__(self, None,
30 msg,
31 os.path.dirname(filename),
32 os.path.basename(filename),
33 _("Shapefiles (*.shp)") + "|*.shp;*.SHP|" +
34 _("All Files (*.*)") + "|*.*",
35 wxOPEN)
36
37 def RunDialog(self):
38 val = self.ShowModal()
39 self.Destroy()
40 if val == wxID_OK:
41 return self.GetPaths()[0]
42 else:
43 return None
44
45 class AltPathConfirmDialog(wxMessageDialog):
46
47 def __init__(self, filename):
48 self.filename = filename
49 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))
50
51 wxMessageDialog.__init__(self, None, msg, _("Alternative Path"),
52 wxYES_NO|wxYES_DEFAULT|wxICON_INFORMATION)
53
54 def RunDialog(self):
55 val = self.ShowModal()
56 self.Destroy()
57 if val == wxID_YES:
58 return self.filename
59 else:
60 dlg = AltPathFileDialog(self.filename)
61 fname = dlg.RunDialog()
62 return fname

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26