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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 21 07:37:06 EDT 2010


Author: martinl
Date: 2010-04-21 07:37:05 -0400 (Wed, 21 Apr 2010)
New Revision: 41947

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: native/ogr format enhancements


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-21 11:00:04 UTC (rev 41946)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-21 11:37:05 UTC (rev 41947)
@@ -578,6 +578,7 @@
         @param dsn    OGR data source name
         """
         layers = list()
+        self.SetValue('')
         if vector:
             # TODO
             pass
@@ -591,7 +592,7 @@
                 layers = ret.splitlines()
         
         self.SetItems(layers)
-    
+        
 class DriverSelect(wx.ComboBox):
     """!Creates combo box for selecting database driver.
     """

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-21 11:00:04 UTC (rev 41946)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-21 11:37:05 UTC (rev 41947)
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 """
- at brief Construct simple wx.Python GUI from a GRASS command interface
+ at brief Construct simple wxPython GUI from a GRASS command interface
 description.
 
 Classes:
@@ -12,36 +12,35 @@
  - GrassGUIApp
  - GUI
 
- Copyright (C) 2000-2009 by the GRASS Development Team
+This program is just a coarse approach to automatically build a GUI
+from a xml-based GRASS user interface description.
 
- This program is free software under the GPL (>=v2) Read the file
- COPYING coming with GRASS for details.
+You need to have Python 2.4, wxPython 2.8 and python-xml.
 
- This program is just a coarse approach to automatically build a GUI
- from a xml-based GRASS user interface description.
+The XML stream is read from executing the command given in the
+command line, thus you may call it for instance this way:
 
- You need to have Python 2.4, wxPython 2.8 and python-xml.
+python menuform.py r.basins.fill
 
- The XML stream is read from executing the command given in the
- command line, thus you may call it for instance this way:
+Or you set an alias or wrap the call up in a nice shell script, GUI
+environment ... please contribute your idea.
 
- python menuform.py r.basins.fill
+Updated to wxPython 2.8 syntax and contrib widgets.  Methods added to
+make it callable by gui.  Method added to automatically re-run with
+pythonw on a Mac.
 
- Or you set an alias or wrap the call up in a nice shell script, GUI
- environment ... please contribute your idea.
+ at todo
+ - verify option value types
 
- Updated to wxPython 2.8 syntax and contrib widgets.  Methods added to
- make it callable by gui.  Method added to automatically re-run with
- pythonw on a Mac.
+Copyright (C) 2000-2019 by the GRASS Development Team
+This program is free software under the GPL (>=v2) Read the file
+COPYING coming with GRASS for details.
 
 @author Jan-Oliver Wagner <jan at intevation.de>
 @author Bernhard Reiter <bernhard at intevation.de>
 @author Michael Barton, Arizona State University
 @author Daniel Calvelo <dca.gis at gmail.com>
 @author Martin Landa <landa.martin at gmail.com>
-
- at todo
- - verify option value types
 """
 
 import sys
@@ -136,23 +135,22 @@
 
 def color_resolve(color):
     if len(color)>0 and color[0] in "0123456789":
-        rgb = tuple(map(int,color.split( ':' )))
+        rgb = tuple(map(int, color.split( ':' )))
         label = color
     else:
         # Convert color names to RGB
         try:
-            rgb = str2rgb[ color ]
+            rgb = str2rgb[color]
             label = color
         except KeyError:
-            rgb = (200,200,200)
+            rgb = (200, 200, 200)
             label = _('Select Color')
     return (rgb, label)
 
 def text_beautify( someString , width=70):
+    """!Make really long texts shorter, clean up whitespace and remove
+    trailing punctuation.
     """
-    Make really long texts shorter, clean up whitespace and
-    remove trailing punctuation.
-    """
     if width > 0:
         return escape_ampersand( string.strip(
                 os.linesep.join( textwrap.wrap( utils.normalize_whitespace(someString), width ) ),
@@ -234,18 +232,18 @@
                         if p.get('element', '') == 'layer':
                             layer = p.get('value', '')
                             if layer != '':
-                                layer = int(p.get('value', 1))
+                                layer = p.get('value', 1)
                             else:
-                                layer = int(p.get('default', 1))
+                                layer = p.get('default', 1)
                             break
                         
                 elif p.get('element', '') == 'layer': # -> layer
                     # get layer
                     layer = p.get('value', '')
                     if layer != '':
-                        layer = int(p.get('value', 1))
+                        layer = p.get('value', 1)
                     else:
-                        layer = int(p.get('default', 1))
+                        layer = p.get('default', 1)
                     
                     # get map name
                     pMap = self.task.get_param(p['wxId'][0], element = 'wxId-bind', raiseError = False)
@@ -1393,27 +1391,24 @@
                         
                         if p.get('age', '') == 'old':
                             # OGR supported (read-only)
-                            hsizer = wx.GridBagSizer(vgap=5, hgap=5)
+                            self.hsizer = wx.BoxSizer(wx.HORIZONTAL)
                             
-                            hsizer.Add(item=selection,
-                                       flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_TOP,
-                                       border=5,
-                                       pos = (0, 0))
+                            self.hsizer.Add(item=selection,
+                                            flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_TOP,
+                                            border=5)
                             
                             # format (native / ogr)
                             rbox = wx.RadioBox(parent = which_panel, id = wx.ID_ANY,
                                                label = " %s " % _("Format"),
                                                style = wx.RA_SPECIFY_ROWS,
-                                               size = (100, -1),
-                                               choices = [_("Native"), _("OGR")])
+                                               choices = [_("Native / Linked OGR"), _("Direct OGR")])
                             rbox.SetName('VectorFormat')
                             rbox.Bind(wx.EVT_RADIOBOX, self.OnVectorFormat)
                             
-                            hsizer.Add(item=rbox,
-                                       flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.ALIGN_TOP,
-                                       pos = (0, 1),
-                                       span = (3, 1),
-                                       border=5)
+                            self.hsizer.Add(item=rbox,
+                                            flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT |
+                                            wx.RIGHT | wx.ALIGN_TOP,
+                                            border=5)
                             
                             ogrSelection = filebrowse.DirBrowseButton(parent = which_panel, id = wx.ID_ANY, 
                                                                       size = globalvar.DIALOG_GSELECT_SIZE,
@@ -1423,23 +1418,12 @@
                                                                       startDirectory = os.getcwd())
                             for win in ogrSelection.GetChildren():
                                 win.SetName('OgrSelect')
-                            ogrSelection.Enable(False)
+                            ogrSelection.Hide()
                             ogrSelection.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
                             ogrSelection.Bind(wx.EVT_TEXT, self.OnSetValue)
-                                                        
-                            hsizer.Add(item=wx.StaticText(parent = which_panel, id = wx.ID_ANY,
-                                                          label = _("Name of OGR data source:")),
-                                       flag=wx.ALIGN_BOTTOM | wx.LEFT,
-                                       pos = (1, 0),
-                                       border=5)
                             
-                            hsizer.Add(item=ogrSelection,
-                                       flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.ALIGN_TOP,
-                                       pos = (2, 0),
-                                       border=5)
+                            which_sizer.Add(item = self.hsizer, proportion = 0)
                             
-                            which_sizer.Add(item = hsizer, proportion = 0)
-                            
                             p['wxId'].append(rbox.GetId())
                             p['wxId'].append(ogrSelection.GetChildren()[1].GetId())
                         else:
@@ -1713,15 +1697,34 @@
                 winOgr = self.FindWindowById(id + 2)
         
         # enable / disable widgets & update values
+        rbox = self.FindWindowByName('VectorFormat')
+        self.hsizer.Remove(rbox)
         if sel == 0:   # -> native
-            winOgr.Enable(False)
-            winNative.Enable(True)
+            winOgr.Hide()
+            self.hsizer.Remove(winOgr)
+
+            self.hsizer.Add(item=winNative,
+                            flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_TOP,
+                            border=5)
+            winNative.Show()
             p['value'] = winNative.GetValue()
+        
         elif sel == 1: # -> OGR
-            winNative.Enable(False)
-            winOgr.Enable(True)
+            winNative.Hide()
+            self.hsizer.Remove(winNative)
+
+            self.hsizer.Add(item=winOgr,
+                            flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_TOP,
+                            border=5)
+            winOgr.Show()
             p['value'] = winOgr.GetValue()
+
+        self.hsizer.Add(item=rbox,
+                        flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT |
+                        wx.RIGHT | wx.ALIGN_TOP,
+                        border=5)
         
+        self.hsizer.Layout()
         self.OnUpdateValues()
         self.OnUpdateSelection(event)
         
@@ -1853,7 +1856,7 @@
                     
                     if name == 'OgrSelect':
                         porf['value'] += '@OGR'
-                    
+                  
         self.OnUpdateValues()
         
         event.Skip()



More information about the grass-commit mailing list