[GRASS-SVN] r42057 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 28 17:18:00 EDT 2010


Author: martinl
Date: 2010-04-28 17:18:00 -0400 (Wed, 28 Apr 2010)
New Revision: 42057

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: direct OGR read access fixes
(merge r42056 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2010-04-28 21:14:46 UTC (rev 42056)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2010-04-28 21:18:00 UTC (rev 42057)
@@ -79,19 +79,27 @@
                           caption = caption,
                           style = style)
         else:
-            exception = traceback.format_exc()
-            reason = exception.split('\n')[-2].split(':', 1)[-1].strip()
-        
-            if Debug.get_level() > 0:
+            exc_type, exc_value, exc_traceback = sys.exc_info()
+            if exc_traceback:
+                exception = traceback.format_exc()
+                reason = exception.splitlines()[-2].split(':', 1)[-1].strip()
+            
+            if Debug.get_level() > 0 and exc_traceback:
                 sys.stderr.write(exception)
-        
-            wx.MessageBox(parent = parent,
-                          message = message + '\n\n%s: %s\n\n%s' % \
-                              (_('Reason'),
-                               reason, exception),
-                          caption = caption,
-                          style = style)
-
+            
+            if exc_traceback:
+                wx.MessageBox(parent = parent,
+                              message = message + '\n\n%s: %s\n\n%s' % \
+                                  (_('Reason'),
+                                   reason, exception),
+                              caption = caption,
+                              style = style)
+            else:
+                wx.MessageBox(parent = parent,
+                              message = message,
+                              caption = caption,
+                              style = style)
+    
 class GError(Exception):
     def __init__(self, value):
         self.value = value

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-04-28 21:14:46 UTC (rev 42056)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-04-28 21:18:00 UTC (rev 42057)
@@ -942,18 +942,22 @@
                                                 startDirectory=os.getcwd(),
                                                 changeCallback=self.OnSetDsn)
         dsnDbFile.Hide()
-        
+        dsnDbFile.SetName('GdalSelect')
+
         dsnDbText = wx.TextCtrl(parent = self, id = wx.ID_ANY)
         dsnDbText.Hide()
         dsnDbText.Bind(wx.EVT_TEXT, self.OnSetDsn)
-        
+        dsnDbText.SetName('GdalSelect')
+
         dsnDbChoice = wx.Choice(parent = self, id = wx.ID_ANY)
         dsnDbChoice.Hide()
         dsnDbChoice.Bind(wx.EVT_CHOICE, self.OnSetDsn)
-        
+        dsnDbChoice.SetName('GdalSelect')
+
         dsnPro = wx.TextCtrl(parent = self, id = wx.ID_ANY)
         dsnPro.Hide()
         dsnPro.Bind(wx.EVT_TEXT, self.OnSetDsn)
+        dsnPro.SetName('GdalSelect')
 
         # format
         self.format = FormatSelect(parent = self,
@@ -1122,7 +1126,7 @@
                 data.append((layerId, layerName.strip(), grassName.strip()))
                 layerId += 1
         
-        evt = wxGdalSelect(dsn = dsn)
+        evt = wxGdalSelect(dsn = dsn + '@OGR')
         evt.SetId(self.input[self.dsnType][1].GetId())
         wx.PostEvent(self.parent, evt)
         
@@ -1210,8 +1214,14 @@
         return self.input[self.dsnType][1].GetValue()
 
     def GetDsnWin(self):
-        """!Get DSN windows"""
-        return self.input[self.dsnType][1]
+        """!Get list of DSN windows"""
+        win = list()
+        for stype in ('file', 'dir', 'pro'):
+            win.append(self.input[stype][1])
+        for stype in ('file', 'text', 'choice'):
+            win.append(self.input['db-win'][stype])
+        
+        return win
     
     def GetFormatExt(self):
         """!Get format extension"""

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-04-28 21:14:46 UTC (rev 42056)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-04-28 21:18:00 UTC (rev 42057)
@@ -46,6 +46,7 @@
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
 from vdigit import haveVDigit
+from gcmd import GMessage
 try:
     import subprocess
 except:
@@ -1293,11 +1294,8 @@
             mapname = utils.GetLayerNameFromCmd(dcmd, layerType=mapLayer.type,
                                                 fullyQualified=True)
             if not mapname:
-                wx.MessageBox(parent=self,
-                              message=_("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd),
-                              caption=_("Error"),
-                              style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
-
+                GMessage(parent=self,
+                         message=_("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd))
                 return
             
             self.SetItemText(layer, mapname + ' (opacity: ' + str(opacity) + '%)')

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-04-28 21:14:46 UTC (rev 42056)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-04-28 21:18:00 UTC (rev 42057)
@@ -98,7 +98,7 @@
         params = list()
         for idx in range(len(dcmd)):
             try:
-                p, v = dcmd[idx].split('=')
+                p, v = dcmd[idx].split('=', 1)
             except ValueError:
                 continue
             
@@ -111,7 +111,7 @@
                      'h_map', 's_map', 'i_map',
                      'reliefmap'):
                 params.append((idx, p, v))
-            
+        
         if len(params) < 1:
             return mapname
             
@@ -140,7 +140,7 @@
     
         maps = list()
         for i, p, v in params:
-            maps.append(dcmd[i].split('=')[1])
+            maps.append(dcmd[i].split('=', 1)[1])
         mapname = '\n'.join(maps)
     
     return mapname



More information about the grass-commit mailing list