jschuengel: thuban/Extensions/umn_mapserver mf_export.py,1.3,1.4
cvs@intevation.de
cvs at intevation.de
Wed Jul 14 12:36:42 CEST 2004
Author: jschuengel
Update of /thubanrepository/thuban/Extensions/umn_mapserver
In directory doto:/tmp/cvs-serv9273
Modified Files:
mf_export.py
Log Message:
Added the function to check if a mapobject exists and used it to set the status of the menu items.
If no mapfile exists the settings could not be edditied.
Define after which menuitem the exportitem will include.
Index: mf_export.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_export.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mf_export.py 6 Jul 2004 14:29:36 -0000 1.3
+++ mf_export.py 14 Jul 2004 10:36:40 -0000 1.4
@@ -101,6 +101,7 @@
theMap = context.mainwindow.canvas.Map().extension_umn_mapobj
else:
theMap = MF_Map(mapObj(""))
+ context.mainwindow.canvas.Map().extension_umn_mapobj = theMap
dlg = wxFileDialog(context.mainwindow, "Save file as...", ".", "",
"UMN MapServer Mapfiles (*.map)|*.map|" \
@@ -129,6 +130,13 @@
for nr in range(len(tb_layers)-1, -1, -1):
theMap.remove_layer(nr)
+
+# check if an mapobj exists, to control the menuitem is available or not
+def _has_umn_mapobj(context):
+ """Return true if a umn_mapobj exists"""
+ return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj")
+
+
# ###################################
#
# Hook in MapServer Extension into Thuban
@@ -136,15 +144,18 @@
# ###################################
# register the new command
-registry.Add(Command("export_new_mapfile", _("Export new Mapfile"), \
- export_mapfile, helptext = _("Create a new mapfile")))
+registry.Add(Command("export_new_mapfile", _("Export mapfile"), \
+ export_mapfile, helptext = _("Create a new mapfile"), \
+ sensitive = _has_umn_mapobj))
# find the extensions menu (create it anew if not found)
-experimental_menu = main_menu.FindOrInsertMenu("experimental", _("Experimenta&l"))
+experimental_menu = main_menu.FindOrInsertMenu("experimental", \
+ _("Experimenta&l"))
# find the extension menu and add a new submenu if found
-mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", _("&MapServer"))
+mapserver_menu = experimental_menu.FindOrInsertMenu("mapserver", \
+ _("&MapServer"))
# finally add the new entry to the extensions menu
-mapserver_menu.InsertItem("export_new_mapfile")
+mapserver_menu.InsertItem("export_new_mapfile", after="edit_mapfile")
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)