Browse Source

wxGUI dialog fix (table -> columns)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35360 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 năm trước cách đây
mục cha
commit
609ffaccff
2 tập tin đã thay đổi với 60 bổ sung26 xóa
  1. 17 1
      gui/wxpython/gui_modules/gselect.py
  2. 43 25
      gui/wxpython/gui_modules/menuform.py

+ 17 - 1
gui/wxpython/gui_modules/gselect.py

@@ -503,7 +503,7 @@ class ColumnSelect(wx.ComboBox):
                  id=wx.ID_ANY, value='', pos=wx.DefaultPosition,
                  size=globalvar.DIALOG_COMBOBOX_SIZE, vector=None,
                  layer=1, choices=[]):
-
+        
         super(ColumnSelect, self).__init__(parent, id, value, pos, size, choices,
                                            style=wx.CB_READONLY)
 
@@ -527,3 +527,19 @@ class ColumnSelect(wx.ComboBox):
 
         self.SetItems(columns)
         self.SetValue('')
+    
+    def InsertTableColumns(self, table, driver=None, database=None):
+        """Insert table columns"""
+        columns = []
+        
+        ret = gcmd.RunCommand('db.columns',
+                              read = True,
+                              driver = driver,
+                              database = database,
+                              table = table)
+        
+        if ret:
+            columns = ret.splitlines()
+
+        self.SetItems(columns)
+        

+ 43 - 25
gui/wxpython/gui_modules/menuform.py

@@ -1,24 +1,25 @@
 #! /usr/bin/python
-"""Construct simple wx.Python GUI from a GRASS command interface description.
+"""
+@brief Construct simple wx.Python GUI from a GRASS command interface
+description.
 
 Classes:
- * testSAXContentHandler
- * grassTask
- * processTask
- * helpPanel
- * mainFrame
- * cmdPanel
- * GrassGUIApp
- * GUI
+ - testSAXContentHandler
+ - grassTask
+ - processTask
+ - helpPanel
+ - mainFrame
+ - cmdPanel
+ - GrassGUIApp
+ - GUI
 
- Copyright (C) 2000-2007 by the GRASS Development Team
+ Copyright (C) 2000-2009 by the GRASS Development Team
 
- This program is free software under the GPL (>=v2)
- Read the file COPYING coming with GRASS for details.
+ This program is free software under the GPL (>=v2) Read the file
+ COPYING coming with GRASS for details.
 
- This program is just a coarse approach to
- automatically build a GUI from a xml-based
- GRASS user interface description.
+ This program is just a coarse approach to automatically build a GUI
+ from a xml-based GRASS user interface description.
 
  You need to have Python 2.4, wxPython 2.8 and python-xml.
 
@@ -27,12 +28,12 @@ Classes:
 
  python <this file.py> r.basins.fill
 
- Or you set an alias or wrap the call up in a nice
- shell script, GUI environment ... please contribute your idea.
+ Or you set an alias or wrap the call up in a nice shell script, GUI
+ environment ... please contribute your idea.
 
- 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.
+ 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.
 
 @author Jan-Oliver Wagner <jan@intevation.de>
 @author Bernhard Reiter <bernhard@intevation.de>
@@ -1227,6 +1228,7 @@ class cmdPanel(wx.Panel):
                             if p.get('age', 'old_dbtable') == 'old_dbtable':
                                 win = gselect.TableSelect(parent=which_panel)
                                 p['wxGetValue'] = win.GetStringSelection
+                                win.Bind(wx.EVT_COMBOBOX, self.OnUpdateSelection)
                                 win.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
                             else:
                                 win = wx.TextCtrl(parent=which_panel, value = p.get('default',''),
@@ -1363,7 +1365,7 @@ class cmdPanel(wx.Panel):
 
         if pTable and pColumn:
             pTable['wxId-bind'] = pColumn
-                
+        
 	#
 	# determine panel size
 	#
@@ -1537,14 +1539,19 @@ class cmdPanel(wx.Panel):
         pMap = self.task.get_param('map', raiseError=False)
         if not pMap:
             pMap = self.task.get_param('input', raiseError=False)
-        
-        map = pMap.get('value', '')
+
+        if pMap:
+            map = pMap.get('value', '')
+        else:
+            map = None
         
         for uid in p['wxId-bind']:
             win = self.FindWindowById(uid)
             name = win.GetName()
+            
             if name == 'LayerSelect':
                 win.InsertLayers(map)
+            
             elif name == 'TableSelect':
                 pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)
                 driver = db = None
@@ -1565,9 +1572,20 @@ class cmdPanel(wx.Panel):
                         layer = int(pLayer.get('default', 1))
                 else:
                     layer = 1
+                if map:
+                    win.InsertColumns(map, layer)
+                else: # table
+                    pDriver = self.task.get_param('dbdriver', element='prompt', raiseError=False)
+                    if pDriver:
+                        driver = pDriver.get('value', None)
+                    pDb = self.task.get_param('dbname', element='prompt', raiseError=False)
+                    if pDb:
+                        db = pDb.get('value', None)
+                    pTable = self.task.get_param('dbtable', element='element', raiseError=False)
+                    if pTable and \
+                            pTable.get('value', '') != '':
+                        win.InsertTableColumns(pTable.get('value'), driver, db)
                 
-                win.InsertColumns(map, layer)
-        
         if event:
             event.Skip()