[GRASS-SVN] r41316 - in grass/branches/releasebranch_6_4/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Mar 7 05:57:12 EST 2010


Author: martinl
Date: 2010-03-07 05:57:12 -0500 (Sun, 07 Mar 2010)
New Revision: 41316

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/location_wizard.py
Log:
wxGUI/loc_wiz: bugfix #987


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py	2010-03-07 01:54:07 UTC (rev 41315)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py	2010-03-07 10:57:12 UTC (rev 41316)
@@ -406,9 +406,10 @@
             return None
 
     def OnWizard(self, event):
-        """Location wizard started"""
+        """!Location wizard started"""
         from gui_modules import location_wizard
-        gWizard = location_wizard.LocationWizard(self, self.tgisdbase.GetValue())
+        gWizard = location_wizard.LocationWizard(parent = self,
+                                                 grassdatabase = self.tgisdbase.GetValue())
         if gWizard.location != None:
             self.OnSetDatabase(event)
             self.UpdateMapsets(os.path.join(self.gisdbase, gWizard.location))

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/location_wizard.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/location_wizard.py	2010-03-07 01:54:07 UTC (rev 41315)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/location_wizard.py	2010-03-07 10:57:12 UTC (rev 41316)
@@ -65,14 +65,6 @@
 global wizerror
 global translist
 
-coordsys = ''
-north = ''
-south = ''
-east = ''
-west = ''
-resolution = ''
-transformlist = []
-
 class BaseClass(wx.Object):
     """!Base class providing basic methods"""
     def __init__(self):
@@ -268,6 +260,7 @@
                                              "PROJ.4 parameters"))
         self.radio6 = wx.RadioButton(parent=self, id=wx.ID_ANY,
                                      label=_("Create an arbitrary non-earth coordinate system (XY)"))
+        
         # layout
         self.sizer.AddGrowableCol(1)
         self.sizer.SetVGap(10)
@@ -1308,13 +1301,13 @@
                                     style=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
         # text input
         epsgdir = utils.PathJoin(os.environ["GRASS_PROJSHARE"], 'epsg')
-        self.tfile = self.MakeTextCtrl(text=epsgdir, size=(200,-1))
+        self.tfile = self.MakeTextCtrl(text=epsgdir, size=(200,-1),
+                                       style = wx.TE_PROCESS_ENTER)
         self.tcode = self.MakeTextCtrl(size=(200,-1))
 
         # buttons
         self.bbrowse = self.MakeButton(_("Browse"))
-#        self.bbcodes = self.MakeButton(_("Reload EPSG Codes"))
-
+        
         # search box
         self.searchb = wx.SearchCtrl(self, size=(200,-1),
                                      style=wx.TE_PROCESS_ENTER)
@@ -1348,11 +1341,7 @@
                        flag=wx.ALIGN_LEFT |
                        wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border=5, pos=(3, 3))
-#        self.sizer.Add(item=self.bbcodes,
-#                       flag=wx.ALIGN_LEFT |
-#                       wx.ALIGN_CENTER_VERTICAL |
-#                       wx.ALL, border=5, pos=(3, 4))
-
+        
         self.sizer.AddGrowableRow(4)
         self.sizer.Add(item=self.epsglist,
                        flag=wx.ALIGN_LEFT | wx.EXPAND, pos=(4, 1),
@@ -1360,7 +1349,7 @@
 
         # events
         self.bbrowse.Bind(wx.EVT_BUTTON, self.OnBrowse)
-#        self.bbcodes.Bind(wx.EVT_BUTTON, self.OnBrowseCodes)
+        self.tfile.Bind(wx.EVT_TEXT_ENTER, self.OnBrowseCodes)
         self.tcode.Bind(wx.EVT_TEXT, self.OnText)
         self.tcode.Bind(wx.EVT_TEXT_ENTER, self.OnText)
         self.epsglist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
@@ -1459,15 +1448,15 @@
         path = os.path.dirname(self.tfile.GetValue())
         if not path:
             path = os.getcwd()
-
+        
         dlg = wx.FileDialog(parent=self, message=_("Choose EPSG codes file"),
                             defaultDir=path, defaultFile="", wildcard="*", style=wx.OPEN)
-
+        
         if dlg.ShowModal() == wx.ID_OK:
             path = dlg.GetPath()
             self.tfile.SetValue(path)
             self.OnBrowseCodes(None)
-
+        
         dlg.Destroy()
 
         event.Skip()
@@ -1488,7 +1477,15 @@
         if True:
             data = []
             self.epsgCodeDict = {}
-            f = open(self.tfile.GetValue(), "r")
+            try:
+                f = open(self.tfile.GetValue(), "r")
+            except IOError:
+                wx.MessageBox(parent=self,
+                              message=_("Unable to read EPGS file: '%s'") % self.tfile.GetValue(),
+                              caption=_("Error"),  style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+                self.epsglist.Populate([], update=True)
+                return
+            
             i = 0
             code = None
             for line in f.readlines():
@@ -1500,15 +1497,18 @@
                     descr = line[1:].strip()
                 elif line[0] == '<':
                     code, params = line.split(" ", 1)
-                    code = int(code.replace('<', '').replace('>', ''))
-
+                    try:
+                        code = int(code.replace('<', '').replace('>', ''))
+                    except ValueError:
+                        code = None
+                
                 if code is not None:
                     data.append((code, descr, params))
                     self.epsgCodeDict[code] = (descr, params)
                     code = None
                 i += 1
             f.close()
-
+        
         if type(self.epsgCodeDict) == type(''):
             wx.MessageBox(parent=self,
                           message=_("Unable to read EPGS codes: %s") % self.epsgCodeDict,
@@ -1745,23 +1745,22 @@
             event.Skip()
 
 class LocationWizard(wx.Object):
-    """
+    """!
     Start wizard here and finish wizard here
     """
     def __init__(self, parent, grassdatabase):
+        self.__cleanUp()
+        
         global coordsys
         self.parent = parent
 
         #
         # define wizard image
         #
-        # file = "loc_wizard.png"
-        file = "loc_wizard_qgis.png"
-        imagePath = os.path.join(globalvar.ETCWXDIR, "images", file)
+        imagePath = os.path.join(globalvar.ETCWXDIR, "images", "loc_wizard_qgis.png")
         wizbmp = wx.Image(imagePath, wx.BITMAP_TYPE_PNG)
-        # wizbmp.Rescale(250,600)
         wizbmp = wizbmp.ConvertToBitmap()
-
+        
         #
         # get georeferencing information from tables in $GISBASE/etc
         #
@@ -1881,12 +1880,34 @@
                                     'err' : msg },
                               caption=_("Location wizard"),
                               style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
-        else:
-            win = wx.MessageBox(parent=self.parent,
-                                message=_("Location wizard canceled. "
-                                          "Location not created."),
-                                caption=_("Location wizard"))
-    
+        else: # -> cancelled
+            self.wizard.Destroy()
+            wx.MessageBox(parent=self.parent,
+                          message=_("Location wizard canceled. "
+                                    "Location not created."),
+                          caption=_("Location wizard"),
+                          style=wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+        
+        self.__cleanUp()
+        
+    def __cleanUp(self):
+        global coordsys
+        global north
+        global south
+        global east
+        global west
+        global resolution
+        global wizerror
+        global translist
+        
+        coordsys = ''
+        north = ''
+        south = ''
+        east = ''
+        west = ''
+        resolution = ''
+        transformlist = []
+
     def __readData(self):
         """!Get georeferencing information from tables in $GISBASE/etc"""
 



More information about the grass-commit mailing list