Explorar o código

wxGUI: backport first run message from TCL/TK GUI
(merge from devbr6, https://trac.osgeo.org/grass/changeset/36087)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36088 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa %!s(int64=16) %!d(string=hai) anos
pai
achega
2825429fec
Modificáronse 1 ficheiros con 22 adicións e 6 borrados
  1. 22 6
      gui/wxpython/gis_set.py

+ 22 - 6
gui/wxpython/gis_set.py

@@ -48,7 +48,7 @@ class GRASSStartup(wx.Frame):
         #
         #
         self.gisbase  = os.getenv("GISBASE")
         self.gisbase  = os.getenv("GISBASE")
         self.grassrc  = self._read_grassrc()
         self.grassrc  = self._read_grassrc()
-        self.gisdbase = self._getRCValue("GISDBASE")
+        self.gisdbase = self.GetRCValue("GISDBASE")
 
 
         #
         #
         # list of locations/mapsets
         # list of locations/mapsets
@@ -166,7 +166,7 @@ class GRASSStartup(wx.Frame):
         self.lbmapsets.Bind(wx.EVT_LIST_ITEM_SELECTED,   self.OnSelectMapset)
         self.lbmapsets.Bind(wx.EVT_LIST_ITEM_SELECTED,   self.OnSelectMapset)
         self.tgisdbase.Bind(wx.EVT_TEXT_ENTER, self.OnSetDatabase)
         self.tgisdbase.Bind(wx.EVT_TEXT_ENTER, self.OnSetDatabase)
         self.Bind(wx.EVT_CLOSE,               self.OnCloseWindow)
         self.Bind(wx.EVT_CLOSE,               self.OnCloseWindow)
-
+        
     def _set_properties(self):
     def _set_properties(self):
         """Set frame properties"""
         """Set frame properties"""
         self.SetTitle(_("Welcome to GRASS GIS"))
         self.SetTitle(_("Welcome to GRASS GIS"))
@@ -191,7 +191,7 @@ class GRASSStartup(wx.Frame):
         self.tgisdbase.SetValue(self.gisdbase)
         self.tgisdbase.SetValue(self.gisdbase)
 
 
         self.OnSetDatabase(None)
         self.OnSetDatabase(None)
-        location = self._getRCValue("LOCATION_NAME")
+        location = self.GetRCValue("LOCATION_NAME")
         if location == "<UNKNOWN>" or \
         if location == "<UNKNOWN>" or \
                 not os.path.isdir(os.path.join(self.gisdbase, location)):
                 not os.path.isdir(os.path.join(self.gisdbase, location)):
             location = None
             location = None
@@ -208,7 +208,7 @@ class GRASSStartup(wx.Frame):
                 
                 
             # list of mapsets
             # list of mapsets
             self.UpdateMapsets(os.path.join(self.gisdbase,location))
             self.UpdateMapsets(os.path.join(self.gisdbase,location))
-            mapset = self._getRCValue("MAPSET")
+            mapset = self.GetRCValue("MAPSET")
             if mapset:
             if mapset:
                 try:
                 try:
                     self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset),
                     self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset),
@@ -383,7 +383,7 @@ class GRASSStartup(wx.Frame):
 
 
         return grassrc
         return grassrc
 
 
-    def _getRCValue(self, value):
+    def GetRCValue(self, value):
         "Return GRASS variable (read from GISRC)"""
         "Return GRASS variable (read from GISRC)"""
 
 
         if self.grassrc.has_key(value):
         if self.grassrc.has_key(value):
@@ -611,7 +611,11 @@ class GRASSStartup(wx.Frame):
 
 
         disabled = []
         disabled = []
         idx = 0
         idx = 0
-        locationName = self.listOfLocations[self.lblocations.GetSelection()]
+        try:
+            locationName = self.listOfLocations[self.lblocations.GetSelection()]
+        except IndexError:
+            locationName = ''
+        
         for mapset in self.listOfMapsets:
         for mapset in self.listOfMapsets:
             if mapset not in self.listOfMapsetsSelectable or \
             if mapset not in self.listOfMapsetsSelectable or \
                     os.path.isfile(os.path.join(self.gisdbase,
                     os.path.isfile(os.path.join(self.gisdbase,
@@ -812,6 +816,18 @@ class StartUp(wx.App):
         StartUp.CenterOnScreen()
         StartUp.CenterOnScreen()
         self.SetTopWindow(StartUp)
         self.SetTopWindow(StartUp)
         StartUp.Show()
         StartUp.Show()
+        
+        if StartUp.GetRCValue("LOCATION_NAME") == "<UNKNOWN>":
+            wx.MessageBox(parent=StartUp,
+                          caption=_('Starting GRASS for the first time'),
+                          message=_('GRASS needs a directory in which to store its data. '
+                                    'Create one now if you have not already done so. '
+                                    'A popular choice is "grassdata", located in '
+                                    'your home directory.'),
+                          style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+            
+            StartUp.OnBrowse(None)
+        
         return 1
         return 1
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":