[GRASS-SVN] r42004 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 23 11:48:30 EDT 2010


Author: martinl
Date: 2010-04-23 11:48:30 -0400 (Fri, 23 Apr 2010)
New Revision: 42004

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: SubGroup widget imlemented


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-23 15:44:11 UTC (rev 42003)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2010-04-23 15:48:30 UTC (rev 42004)
@@ -15,8 +15,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.
 
@@ -775,3 +776,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/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-23 15:44:11 UTC (rev 42003)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-04-23 15:48:30 UTC (rev 42004)
@@ -199,7 +199,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:
@@ -295,7 +295,12 @@
                                                               'database' : db }
                     elif pTable:
                         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)
 
@@ -1359,6 +1364,7 @@
                 # GIS element entry
                 if p.get('prompt','') not in ('color',
                                               'color_none',
+                                              'subgroup',
                                               'dbdriver',
                                               'dbname',
                                               'dbtable',
@@ -1374,7 +1380,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', ''),
@@ -1432,11 +1437,24 @@
                             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)
+                    elif p.get('prompt', '') == 'group':
+                        selection.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
+                        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)
                     else:
                         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)
-                        
+                # 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',
@@ -1593,6 +1611,8 @@
         pDatabase = None
         pTable = None
         pColumn = []
+        pGroup = None
+        pSubGroup = None
         for p in self.task.params:
             if p.get('gisprompt', False) == False:
                 continue
@@ -1625,6 +1645,10 @@
                 pDatabase = p
             elif prompt == 'dbtable':
                 pTable = p
+            elif prompt == 'group':
+                pGroup = p
+            elif prompt == 'subgroup':
+                pSubGroup = p
         
         # collect ids
         pColumnIds = []
@@ -1652,6 +1676,9 @@
         if pTable and pColumnIds:
             pTable['wxId-bind'] = pColumnIds
         
+        if pGroup and pSubGroup:
+            pGroup['wxId-bind'] = pSubGroup['wxId']
+        
 	#
 	# determine panel size
 	#
@@ -1868,9 +1895,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