[GRASS-SVN] r42009 - grass/branches/releasebranch_6_4/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 23 12:06:32 EDT 2010


Author: martinl
Date: 2010-04-23 12:06:32 -0400 (Fri, 23 Apr 2010)
New Revision: 42009

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: SubGroup widget imlemented
(merge r42004 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py	2010-04-23 16:01:07 UTC (rev 42008)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gselect.py	2010-04-23 16:06:32 UTC (rev 42009)
@@ -11,10 +11,11 @@
  - DriverSelect
  - DatabaseSelect
  - ColumnSelect
+ - SubGroupSelect
 
-(C) 2007-2008 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.
+(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.
 
 @author Michael Barton
 @author Martin Landa <landa.martin gmail.com>
@@ -684,3 +685,30 @@
         # columnchoices.sort()
         self.SetItems(columnchoices)
     
+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/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py	2010-04-23 16:01:07 UTC (rev 42008)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py	2010-04-23 16:06:32 UTC (rev 42009)
@@ -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)
 
@@ -1318,6 +1323,7 @@
                 # GIS element entry
                 if p.get('prompt','') not in ('color',
                                               'color_none',
+                                              'subgroup',
                                               'dbdriver',
                                               'dbname',
                                               'dbtable',
@@ -1334,7 +1340,6 @@
                         mapsets = [grassenv.GetGRASSVariable('MAPSET'),]
                     else:
                         mapsets = None
-                        
                     selection = gselect.Select(parent=which_panel, id=wx.ID_ANY,
                                                size=globalvar.DIALOG_GSELECT_SIZE,
                                                type=p.get('element', ''),
@@ -1349,9 +1354,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',
@@ -1501,6 +1515,8 @@
         pDatabase = None
         pTable = None
         pColumn = []
+        pGroup = None
+        pSubGroup = None
         for p in self.task.params:
             if p.get('gisprompt', False) == False:
                 continue
@@ -1521,6 +1537,10 @@
                 pDatabase = p
             elif prompt == 'dbtable':
                 pTable = p
+            elif prompt == 'group':
+                pGroup = p
+            elif prompt == 'subgroup':
+                pSubGroup = p
         
         pColumnIds = []
         for p in pColumn:
@@ -1546,6 +1566,9 @@
         if pTable and pColumnIds:
             pTable['wxId-bind'] = pColumnIds
         
+        if pGroup and pSubGroup:
+            pGroup['wxId-bind'] = pSubGroup['wxId']
+        
 	#
 	# determine panel size
 	#
@@ -1698,9 +1721,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