[GRASS-SVN] r42056 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 28 17:14:47 EDT 2010


Author: martinl
Date: 2010-04-28 17:14:46 -0400 (Wed, 28 Apr 2010)
New Revision: 42056

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/layertree.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: direct OGR read access fixes


Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2010-04-28 19:27:09 UTC (rev 42055)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2010-04-28 21:14:46 UTC (rev 42056)
@@ -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/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-28 19:27:09 UTC (rev 42055)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-28 21:14:46 UTC (rev 42056)
@@ -983,18 +983,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,
@@ -1163,7 +1167,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)
         
@@ -1251,8 +1255,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/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py	2010-04-28 19:27:09 UTC (rev 42055)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py	2010-04-28 21:14:46 UTC (rev 42056)
@@ -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/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-28 19:27:09 UTC (rev 42055)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-28 21:14:46 UTC (rev 42056)
@@ -1431,7 +1431,8 @@
                             
                             p['wxId'].append(rbox.GetId())
                             p['wxId'].append(ogrSelection.GetId())
-                            p['wxId'].append(ogrSelection.GetDsnWin().GetId())
+                            for win in ogrSelection.GetDsnWin():
+                                p['wxId'].append(win.GetId())
                         else:
                             which_sizer.Add(item=selection, proportion=0,
                                             flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_CENTER_VERTICAL,
@@ -1889,11 +1890,11 @@
                 if found:
                     if name in ('LayerSelect', 'DriverSelect', 'TableSelect'):
                         porf['value'] = me.GetStringSelection()
+                    elif name == 'GdalSelect':
+                        porf['value'] = event.dsn
                     else:
                         porf['value'] = me.GetValue()
                     
-                    if name == 'GdalSelect':
-                        porf['value'] += '@OGR'
                   
         self.OnUpdateValues()
         

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2010-04-28 19:27:09 UTC (rev 42055)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2010-04-28 21:14:46 UTC (rev 42056)
@@ -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
             
@@ -147,7 +147,7 @@
                 ogr = True
             if p == 'layer' and not ogr:
                 continue
-            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