[GRASS-SVN] r34425 - in grass/trunk: gui/wxpython/gui_modules vector/v.category

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 21 09:30:15 EST 2008


Author: martinl
Date: 2008-11-21 09:30:15 -0500 (Fri, 21 Nov 2008)
New Revision: 34425

Modified:
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/vector/v.category/main.c
Log:
wxGUI: fix layer selection -- trac #371
	(merge from devbr6, r34424)


Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-11-21 14:15:28 UTC (rev 34424)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-11-21 14:30:15 UTC (rev 34425)
@@ -446,12 +446,12 @@
         
     def InsertLayers(self, vector):
         """Insert layers for a vector into the layer combobox"""
-        layerchoices = VectorDBInfo(vector).layers.keys()
+        layerchoices = utils.GetVectorNumberOfLayers(vector)
         
         if self.all:
             layerchoices.insert(0, '-1')
         if len(layerchoices) > 1:
-            self.SetItems(map(str, layerchoices))
+            self.SetItems(layerchoices)
             self.SetStringSelection('1')
         else:
             self.SetItems(['1'])

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-11-21 14:15:28 UTC (rev 34424)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-11-21 14:30:15 UTC (rev 34425)
@@ -239,6 +239,27 @@
     """Sort list items (not case-sensitive)"""
     list.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
 
+def GetVectorNumberOfLayers(vector):
+    """Get list of vector layers"""
+    cmdlist = ['v.category',
+               'input=%s' % vector,
+               'option=report']
+    
+    layers = []
+    for line in gcmd.Command(cmdlist).ReadStdOutput():
+        if not 'Layer' in line:
+            continue
+        
+        value = line.split(':')[1].strip()
+        if '/' in value: # value/name
+            layers.append(value.split('/')[0])
+        else:
+            layers.append(value)
+    
+    print layers
+    
+    return layers
+
 def reexec_with_pythonw():
     """Re-execute Python on Mac OS"""
     if sys.platform == 'darwin' and \

Modified: grass/trunk/vector/v.category/main.c
===================================================================
--- grass/trunk/vector/v.category/main.c	2008-11-21 14:15:28 UTC (rev 34424)
+++ grass/trunk/vector/v.category/main.c	2008-11-21 14:30:15 UTC (rev 34425)
@@ -406,11 +406,11 @@
 	    }
 	    else {
 		if (freps[i]->table != '\0') {
-		    G_message("%s: %d/%s", _("Layer/table"),
-			      freps[i]->field, freps[i]->table);
+		    fprintf(stdout, "%s: %d/%s\n", _("Layer/table"),
+			    freps[i]->field, freps[i]->table);
 		}
 		else {
-		    G_message("%s: %d", _("Layer"), freps[i]->field);
+		    fprintf(stdout, "%s: %d\n", _("Layer"), freps[i]->field);
 		}
 		fprintf(stdout, "type       count        min        max\n");
 		fprintf(stdout, "point    %7d %10d %10d\n",



More information about the grass-commit mailing list