[GRASS-SVN] r54481 - grass/trunk/gui/wxpython/gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 1 12:14:56 PST 2013


Author: martinl
Date: 2013-01-01 12:14:55 -0800 (Tue, 01 Jan 2013)
New Revision: 54481

Modified:
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI: SigantureSelect implemented


Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2013-01-01 18:54:19 UTC (rev 54480)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2013-01-01 20:14:55 UTC (rev 54481)
@@ -287,6 +287,25 @@
             
             elif name == 'SubGroupSelect':
                 self.data[win.Insert] = { 'group' : p.get('value', '')}
+
+            elif name == 'SignatureSelect':
+                if p.get('prompt', 'group') == 'group':
+                    group = p.get('value', '')
+                    pSubGroup = self.task.get_param('subgroup', element = 'prompt', raiseError = False)
+                    if pSubGroup:
+                        subgroup = pSubGroup.get('value', '')
+                    else:
+                        subgroup = None
+                else:
+                    subgroup = p.get('value', '')
+                    pGroup = self.task.get_param('group', element = 'prompt', raiseError = False)
+                    if pGroup:
+                        group = pGroup.get('value', '')
+                    else:
+                        group = None
+                
+                self.data[win.Insert] = { 'group' : group,
+                                          'subgroup' : subgroup}
             
             elif name == 'LocationSelect':
                 pDbase = self.task.get_param('dbase', element = 'element', raiseError = False)
@@ -1106,6 +1125,7 @@
                 if p.get('prompt','') not in ('color',
                                               'color_none',
                                               'subgroup',
+                                              'sigfile',
                                               'dbdriver',
                                               'dbname',
                                               'dbtable',
@@ -1222,12 +1242,21 @@
                 elif prompt == 'subgroup':
                     selection = gselect.SubGroupSelect(parent = which_panel)
                     p['wxId'] = [ selection.GetId() ]
-                    selection.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
-                    selection.Bind(wx.EVT_TEXT,     self.OnSetValue)
+                    selection.Bind(wx.EVT_TEXT, self.OnUpdateSelection)
+                    selection.Bind(wx.EVT_TEXT, 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)
 
+                # sigrature file
+                elif prompt == 'sigfile':
+                    selection = gselect.SignatureSelect(parent = which_panel)
+                    p['wxId'] = [ selection.GetId() ]
+                    selection.Bind(wx.EVT_TEXT, 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 prompt in ('dbdriver',
                                 'dbname',
@@ -1553,6 +1582,8 @@
                 pGroup = p
             elif prompt == 'subgroup':
                 pSubGroup = p
+            elif prompt == 'sigfile':
+                pSigFile = p
             elif prompt == 'dbase':
                 pDbase = p
             elif prompt == 'location':
@@ -1587,8 +1618,11 @@
             pTable['wxId-bind'] = pColumnIds
         
         if pGroup and pSubGroup:
-            pGroup['wxId-bind'] = pSubGroup['wxId']
-
+            if pSigFile:
+                pGroup['wxId-bind'] = copy.copy(pSigFile['wxId'])
+                pSubGroup['wxId-bind'] = pSigFile['wxId']
+            pGroup['wxId-bind'] += pSubGroup['wxId']
+        
         if pDbase and pLocation:
             pDbase['wxId-bind'] = pLocation['wxId']
 

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2013-01-01 18:54:19 UTC (rev 54480)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2013-01-01 20:14:55 UTC (rev 54481)
@@ -23,6 +23,7 @@
  - gselect::ElementSelect
  - gselect::OgrTypeSelect
  - gselect::CoordinatesSelect
+ - gselect::SignatureSelect
 
 (C) 2007-2012 by the GRASS Development Team 
 
@@ -2074,3 +2075,42 @@
     def GetTextWin(self):
         """!Get TextCtrl widget"""
         return self.coordsField
+
+class SignatureSelect(wx.ComboBox):
+    """!Widget for selecting signatures"""
+    def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE, 
+                 **kwargs):
+        super(SignatureSelect, self).__init__(parent, id, size = size, 
+                                              **kwargs)
+        self.SetName("SignatureSelect")
+
+    def Insert(self, group, subgroup = None):
+        """!Insert signatures for defined group/subgroup
+
+        @param group group name (can be fully-qualified)
+        @param subgroup non fully-qualified name of subgroup
+        """
+        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)
+        
+        if subgroup:
+            path = os.path.join(path, 'subgroup', subgroup)
+        try:
+            items = list()
+            for element in os.listdir(path):
+                if element in ('subgroup', 'REF'):
+                    continue
+                items.append(element)
+            self.SetItems(items)
+        except OSError:
+            self.SetItems([])
+        self.SetValue('')



More information about the grass-commit mailing list