[GRASS-SVN] r34424 - in grass/branches/develbranch_6:
gui/wxpython/gui_modules vector/v.category
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Nov 21 09:15:28 EST 2008
Author: martinl
Date: 2008-11-21 09:15:28 -0500 (Fri, 21 Nov 2008)
New Revision: 34424
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
grass/branches/develbranch_6/vector/v.category/main.c
Log:
wxGUI: fix layer selection -- trac #371
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-11-21 14:01:38 UTC (rev 34423)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-11-21 14:15:28 UTC (rev 34424)
@@ -443,12 +443,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/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-11-21 14:01:38 UTC (rev 34423)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-11-21 14:15:28 UTC (rev 34424)
@@ -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/branches/develbranch_6/vector/v.category/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.category/main.c 2008-11-21 14:01:38 UTC (rev 34423)
+++ grass/branches/develbranch_6/vector/v.category/main.c 2008-11-21 14:15:28 UTC (rev 34424)
@@ -410,11 +410,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