Parcourir la source

wxGUI: location wizard also accessible from Layer Manager

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@47296 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa il y a 13 ans
Parent
commit
75af11054d
2 fichiers modifiés avec 33 ajouts et 0 suppressions
  1. 26 0
      gui/wxpython/wxgui.py
  2. 7 0
      gui/wxpython/xml/menudata.xml

+ 26 - 0
gui/wxpython/wxgui.py

@@ -302,6 +302,32 @@ class GMFrame(wx.Frame):
         if self.workspaceFile:
             self.SetTitle(self.baseTitle + " - " +  os.path.basename(self.workspaceFile) + '*')
         
+    def OnLocationWizard(self, event):
+        """!Launch location wizard"""
+        from gui_modules import location_wizard
+        
+        gisdbase = grass.gisenv()['GISDBASE']
+        gWizard = location_wizard.LocationWizard(parent = self,
+                                                 grassdatabase = gisdbase)
+        
+        if gWizard.location !=  None:
+            dlg = wx.MessageDialog(parent = self,
+                                   message = _('Location <%s> created.\n\n'
+                                               'Do you want to switch to the '
+                                               'new location?') % gWizard.location,
+                                   caption=_("Switch to new location?"),
+                                   style = wx.YES_NO | wx.NO_DEFAULT |
+                                   wx.ICON_QUESTION | wx.CENTRE)
+            
+            ret = dlg.ShowModal()
+            if ret == wx.ID_YES:
+                gcmd.RunCommand("g.gisenv",
+                                set = "LOCATION_NAME=%s" % gWizard.location)
+                gcmd.RunCommand("g.gisenv",
+                                set = "MAPSET=PERMANENT")
+            
+            dlg.Destroy()
+            
     def OnSettingsChanged(self, event):
         """!Here can be functions which have to be called after EVT_SETTINGS_CHANGED. 
         Now only set copying of selected text to clipboard (in goutput).

+ 7 - 0
gui/wxpython/xml/menudata.xml

@@ -831,6 +831,13 @@
 	    </menuitem>
 	    <separator />
 	    <menuitem>
+	      <label>Create new location</label>
+	      <help>Launches location wizard to create new GRASS location.</help>
+	      <keywords>location, wizard</keywords>
+              <handler>OnLocationWizard</handler>
+	    </menuitem>
+	    <separator />
+	    <menuitem>
 	      <label>Version</label>
 	      <help>Displays version and copyright information.</help>
 	      <keywords>general,version</keywords>