[GRASS-SVN] r42007 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 23 11:59:47 EDT 2010
Author: martinl
Date: 2010-04-23 11:59:46 -0400 (Fri, 23 Apr 2010)
New Revision: 42007
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: SubGroup widget imlemented
(merge r42004 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-04-23 15:57:41 UTC (rev 42006)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-04-23 15:59:46 UTC (rev 42007)
@@ -14,8 +14,9 @@
- ColumnSelect
- LocationSelect
- MapsetSelect
+ - SubGroupSelect
-(C) 2007-2009 by the GRASS Development Team This program is free
+(C) 2007-2010 by the GRASS Development Team This program is free
software under the GNU General Public License (>=v2). Read the file
COPYING that comes with GRASS for details.
@@ -734,3 +735,30 @@
if setItems:
self.SetItems(utils.GetListOfMapsets(self.gisdbase, self.location, selectable = True)) # selectable
+
+class SubGroupSelect(wx.ComboBox):
+ """!Widget for selecting subgroups"""
+ def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
+ **kwargs):
+ super(SubGroupSelect, self).__init__(parent, id, size = size,
+ style = wx.CB_READONLY, **kwargs)
+ self.SetName("SubGroupSelect")
+
+ def Insert(self, group):
+ """!Insert subgroups for defined group"""
+ if not group:
+ return
+ gisenv = grass.gisenv()
+ try:
+ name, mapset = group.split('@', 1)
+ except ValueError:
+ name = group
+ mapset = gisenv['MAPSET']
+
+ path = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'], mapset,
+ 'group', name, 'subgroup')
+ try:
+ self.SetItems(os.listdir(path))
+ except OSError:
+ self.SetItems([])
+ self.SetValue('')
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2010-04-23 15:57:41 UTC (rev 42006)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py 2010-04-23 15:59:46 UTC (rev 42007)
@@ -201,7 +201,7 @@
pType = p.get('prompt', '')
if not pType:
return
-
+
# check for map/input parameter
pMap = self.task.get_param('map', raiseError=False)
if not pMap:
@@ -261,7 +261,12 @@
'database' : db }
else:
self.data[win.InsertTableColumns] = { 'table' : pTable.get('value') }
-
+
+ elif name == 'SubGroupSelect':
+ pGroup = self.task.get_param('group', element='element', raiseError=False)
+ if pGroup:
+ self.data[win.Insert] = { 'group' : pGroup.get('value', '')}
+
def UpdateDialog(parent, event, eventId, task):
return UpdateThread(parent, event, eventId, task)
@@ -1313,6 +1318,7 @@
# GIS element entry
if p.get('prompt','') not in ('color',
'color_none',
+ 'subgroup',
'dbdriver',
'dbname',
'dbtable',
@@ -1329,7 +1335,6 @@
mapsets = [grass.gisenv()['MAPSET'],]
else:
mapsets = None
-
selection = gselect.Select(parent=which_panel, id=wx.ID_ANY,
size=globalvar.DIALOG_GSELECT_SIZE,
type=p.get('element', ''),
@@ -1344,9 +1349,18 @@
# we target the textctl here
p['wxId'] = selection.GetChildren()[0].GetId()
selection.GetChildren()[0].Bind(wx.EVT_TEXT, self.OnSetValue)
- if p.get('prompt', '') == 'vector':
+ if p.get('prompt', '') in ('vector', 'group'):
selection.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
-
+
+ # subgroup
+ elif p.get('prompt', '') == 'subgroup':
+ selection = gselect.SubGroupSelect(parent = which_panel)
+ p['wxId'] = [ selection.GetId() ]
+ selection.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
+ which_sizer.Add(item = selection, proportion = 0,
+ flag = wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_CENTER_VERTICAL,
+ border = 5)
+
# layer, dbdriver, dbname, dbcolumn, dbtable entry
elif p.get('prompt', '') in ('dbdriver',
'dbname',
@@ -1496,6 +1510,8 @@
pDatabase = None
pTable = None
pColumn = []
+ pGroup = None
+ pSubGroup = None
for p in self.task.params:
if p.get('gisprompt', False) == False:
continue
@@ -1516,6 +1532,10 @@
pDatabase = p
elif prompt == 'dbtable':
pTable = p
+ elif prompt == 'group':
+ pGroup = p
+ elif prompt == 'subgroup':
+ pSubGroup = p
pColumnIds = []
for p in pColumn:
@@ -1541,6 +1561,9 @@
if pTable and pColumnIds:
pTable['wxId-bind'] = pColumnIds
+ if pGroup and pSubGroup:
+ pGroup['wxId-bind'] = pSubGroup['wxId']
+
#
# determine panel size
#
@@ -1694,9 +1717,8 @@
event.Skip()
def OnUpdateSelection(self, event):
+ """!Update dialog (layers, tables, columns, etc.)
"""
- Update dialog (layers, tables, columns, etc.)
- """
if event:
self.parent.updateThread.Update(UpdateDialog,
self,
More information about the grass-commit
mailing list