[GRASS-SVN] r35363 -
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 12 08:14:52 EST 2009
Author: martinl
Date: 2009-01-12 08:14:52 -0500 (Mon, 12 Jan 2009)
New Revision: 35363
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI dialog fix (table -> columns)
gcmd.RunCommand() also backported
(merge trunk, r35360)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py 2009-01-12 13:10:37 UTC (rev 35362)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gcmd.py 2009-01-12 13:14:52 UTC (rev 35363)
@@ -581,3 +581,35 @@
"""Abort running process, used by main thread to signal an abort"""
self._want_abort = True
+def RunCommand(prog, flags = "", overwrite = False, quiet = False, verbose = False,
+ parent = None, read = False, stdin = None, **kwargs):
+ """Run GRASS command"""
+ kwargs['stderr'] = subprocess.PIPE
+
+ if read:
+ kwargs['stdout'] = subprocess.PIPE
+
+ if stdin:
+ kwargs['stdin'] = subprocess.PIPE
+
+ ps = grass.start_command(prog, flags, overwrite, quiet, verbose, **kwargs)
+
+ if stdin:
+ ps.stdin.write(stdin)
+ ps.stdin.close()
+ ps.stdin = None
+
+ ret = ps.wait()
+
+ stdout, stderr = ps.communicate()
+
+ if ret != 0 and parent:
+ e = CmdError(cmd = prog,
+ message = stderr,
+ parent = parent)
+ e.Show()
+
+ if not read:
+ return ret
+
+ return stdout
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2009-01-12 13:10:37 UTC (rev 35362)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py 2009-01-12 13:14:52 UTC (rev 35363)
@@ -537,7 +537,7 @@
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)
@@ -561,7 +561,22 @@
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)
+
class DbColumnSelect(wx.ComboBox):
"""
Creates combo box for selecting columns from any table.
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2009-01-12 13:10:37 UTC (rev 35362)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py 2009-01-12 13:14:52 UTC (rev 35363)
@@ -1,24 +1,25 @@
#! /usr/bin/python
-"""Construct simple wx.Python GUI from a GRASS command interface description.
+"""
+ at 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 @@
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 at intevation.de>
@author Bernhard Reiter <bernhard at intevation.de>
@@ -1226,6 +1227,7 @@
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',''),
@@ -1362,7 +1364,7 @@
if pTable and pColumn:
pTable['wxId-bind'] = pColumn
-
+
#
# determine panel size
#
@@ -1536,14 +1538,19 @@
pMap = self.task.get_param('map', raiseError=False)
if not pMap:
pMap = self.task.get_param('input', raiseError=False)
+
+ if pMap:
+ map = pMap.get('value', '')
+ else:
+ map = None
- map = pMap.get('value', '')
-
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
@@ -1564,9 +1571,20 @@
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()
More information about the grass-commit
mailing list