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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 13 12:50:02 EST 2010


Author: martinl
Date: 2010-03-13 12:50:01 -0500 (Sat, 13 Mar 2010)
New Revision: 41426

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: be more consistent on ColumnSelect events
(merge r41425 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-03-13 17:35:40 UTC (rev 41425)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py	2010-03-13 17:50:01 UTC (rev 41426)
@@ -617,27 +617,27 @@
         self.SetValue('')
         
 class ColumnSelect(wx.ComboBox):
+    """!Creates combo box for selecting columns in the attribute table
+    for a vector map.
+
+    @param parent window parent
+    @param id window id
+    @param value default value
+    @param size window size
+    @param vector vector map name
+    @param layer layer number
+    @param param parameters list (see menuform.py)
+    @param **kwags wx.ComboBox parameters
     """
-    Creates combo box for selecting columns in the attribute table for a vector.
-    The 'layer' terminology is likely to change for GRASS 7
-    """
-    def __init__(self, parent,
-                 id = wx.ID_ANY, value = '',
-                 size = globalvar.DIALOG_COMBOBOX_SIZE,
-                 vector = None, layer = 1, choices = [], readonly = False,
-                 **kwargs):
-        if readonly:
-            if kwargs.has_key('style'):
-                style |= wx.CB_READONLY
-            else:
-                style = wx.CB_READONLY
+    def __init__(self, parent, id = wx.ID_ANY, value = '', 
+                 size=globalvar.DIALOG_COMBOBOX_SIZE,
+                 vector = None, layer = 1, param = None, **kwargs):
         self.defaultValue = value
+        self.param = param
         
-        super(ColumnSelect, self).__init__(parent, id, value = value, choices = choices, size = size,
-                                           **kwargs)
+        super(ColumnSelect, self).__init__(parent, id, value, size = size, **kwargs)
+        self.SetName("ColumnSelect")
         
-        self.SetName("ColumnSelect")
-
         if vector:
             self.InsertColumns(vector, layer)
     
@@ -665,14 +665,22 @@
                     if value['type'] not in type:
                         columns.remove(key)
         except (KeyError, ValueError):
-            columns = []
-
+            columns = list()
+        
         self.SetItems(columns)
         self.SetValue(self.defaultValue)
-    
+        
+        if self.param:
+            self.param['value'] = ''
+        
     def InsertTableColumns(self, table, driver=None, database=None):
-        """!Insert table columns"""
-        columns = []
+        """!Insert table columns
+
+        @param table table name
+        @param driver driver name
+        @param database database name
+        """
+        columns = list()
         
         ret = gcmd.RunCommand('db.columns',
                               read = True,
@@ -682,10 +690,13 @@
         
         if ret:
             columns = ret.splitlines()
-
+        
         self.SetItems(columns)
         self.SetValue(self.defaultValue)
         
+        if self.param:
+            self.param['value'] = ''
+        
 class LocationSelect(wx.ComboBox):
     """!Widget for selecting GRASS location"""
     def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_COMBOBOX_SIZE, 

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-13 17:35:40 UTC (rev 41425)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-03-13 17:50:01 UTC (rev 41426)
@@ -1342,7 +1342,8 @@
                                 win.Bind(wx.EVT_TEXT, self.OnSetValue)
                         elif p.get('prompt', '') == 'dbcolumn':
                             win = gselect.ColumnSelect(parent = which_panel,
-                                                       value = p.get('default', ''))
+                                                       value = p.get('default', ''),
+                                                       param = p)
                             ### p['wxGetValue'] = win.GetStringSelection
                             ### win.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
                             win.Bind(wx.EVT_TEXT, self.OnSetValue)
@@ -1512,6 +1513,8 @@
         for fn, kwargs in event.data.iteritems():
             fn(**kwargs)
         
+        self.parent.updateValuesHook()
+        
     def OnVerbosity(self, event):
         """!Verbosity level changed"""
         verbose = self.FindWindowById(self.task.get_flag('verbose')['wxId'])



More information about the grass-commit mailing list