Procházet zdrojové kódy

wxGUI: be more consistent on ColumnSelect events

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@41425 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa před 15 roky
rodič
revize
7890ee2aed

+ 34 - 16
gui/wxpython/gui_modules/gselect.py

@@ -657,20 +657,27 @@ class TableSelect(wx.ComboBox):
         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='', pos=wx.DefaultPosition,
-                 size=globalvar.DIALOG_COMBOBOX_SIZE, vector=None,
-                 layer=1, choices=[]):
+    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, pos, size, choices)
-        
+        super(ColumnSelect, self).__init__(parent, id, value, size = size, **kwargs)
         self.SetName("ColumnSelect")
-
+        
         if vector:
             self.InsertColumns(vector, layer)
                 
@@ -698,14 +705,22 @@ class ColumnSelect(wx.ComboBox):
                     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,
@@ -715,10 +730,13 @@ class ColumnSelect(wx.ComboBox):
         
         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, 

+ 4 - 1
gui/wxpython/gui_modules/menuform.py

@@ -1447,7 +1447,8 @@ class cmdPanel(wx.Panel):
                                 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)
                             win.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
                             win.Bind(wx.EVT_TEXT,     self.OnSetValue)
 
@@ -1665,6 +1666,8 @@ class cmdPanel(wx.Panel):
         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'][0])