[GRASS-SVN] r33350 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 9 04:22:30 EDT 2008
Author: martinl
Date: 2008-09-09 04:22:30 -0400 (Tue, 09 Sep 2008)
New Revision: 33350
Modified:
grass/trunk/gui/wxpython/gui_modules/colorrules.py
grass/trunk/gui/wxpython/gui_modules/gselect.py
Log:
wxGUI: colorrules fixes
(merge from devbr6, r33349)
Modified: grass/trunk/gui/wxpython/gui_modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/colorrules.py 2008-09-09 08:18:18 UTC (rev 33349)
+++ grass/trunk/gui/wxpython/gui_modules/colorrules.py 2008-09-09 08:22:30 UTC (rev 33350)
@@ -106,7 +106,7 @@
label='Attribute column:')
self.cb_vrgb_label = wx.StaticText(parent=self, id=wx.ID_ANY,
label='RGB color column:')
- self.cb_vlayer = gselect.LayerSelect(self, vector='')
+ self.cb_vlayer = gselect.LayerSelect(self)
self.cb_vcol = gselect.ColumnSelect(self, vector='', layer='')
self.cb_vrgb = gselect.ColumnSelect(self, vector='', layer='')
@@ -281,18 +281,15 @@
except:
pass
elif self.cmd == 'vcolors':
- try:
- # initialize layer selection combobox
- self.cb_vlayer.InsertLayers(self.inmap)
- # initialize attribute table for layer=1
- self.vtable = gselect.VectorDBInfo(self.inmap).layers[str(self.vlayer)]
- # initialize column selection comboboxes
- self.cb_vcol.InsertColumns(vector=self.inmap, layer=self.vlayer)
- self.cb_vrgb.InsertColumns(vector=self.inmap, layer=self.vlayer)
- self.Update()
- except:
- pass
-
+ # initialize layer selection combobox
+ self.cb_vlayer.InsertLayers(self.inmap)
+ # initialize attribute table for layer=1
+ self.vtable = gselect.VectorDBInfo(self.inmap).layers[int(self.vlayer)]['table']
+ # initialize column selection comboboxes
+ self.cb_vcol.InsertColumns(vector=self.inmap, layer=self.vlayer)
+ self.cb_vrgb.InsertColumns(vector=self.inmap, layer=self.vlayer)
+ self.Update()
+
def OnLayerSelection(self, event):
# reset choices in column selection comboboxes if layer changes
self.vlayer = int(event.GetString())
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-09-09 08:18:18 UTC (rev 33349)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2008-09-09 08:22:30 UTC (rev 33350)
@@ -390,8 +390,7 @@
break
self.tables[table] = columns
- #print 'self tables =', self.tables[table]
-
+
return True
def Reset(self):
@@ -402,32 +401,31 @@
for name in self.tables[table].keys():
self.tables[table][name]['values'] = []
self.tables[table][name]['ids'] = []
-
+
class LayerSelect(wx.ComboBox):
"""
Creates combo box for selecting data layers defined for vector.
The 'layer' terminology is likely to change for GRASS 7
"""
def __init__(self, parent,
- id=wx.ID_ANY, value='1', pos=wx.DefaultPosition,
- size=wx.DefaultSize, choices=['1'], **kargs):
+ id=wx.ID_ANY, pos=wx.DefaultPosition,
+ size=wx.DefaultSize, vector=None, choices=[]):
- super(LayerSelect, self).__init__(parent, id, value, pos, size, choices)
+ super(LayerSelect, self).__init__(parent, id, pos=pos, size=size,
+ choices=choices)
- lsvector = kargs['vector'] # vector map to check for attribute tables
+ if not vector:
+ return
- if lsvector == '':
- return
- else:
- self.InsertLayers(lsvector)
+ self.InsertLayers(vector)
def InsertLayers(self, vector):
- """insert layers for a vector into the layer combobox"""
+ """Insert layers for a vector into the layer combobox"""
layerchoices = VectorDBInfo(vector).layers.keys()
- self.SetItems(layerchoices)
- self.SetSelection(0)
- self.SetValue('1') # all vectors have a layer 1 by default
+ self.SetItems(map(str, layerchoices))
+ self.SetStringSelection('1')
+
class ColumnSelect(wx.ComboBox):
"""
Creates combo box for selecting columns in the attribute table for a vector.
@@ -435,25 +433,22 @@
"""
def __init__(self, parent,
id=wx.ID_ANY, value='', pos=wx.DefaultPosition,
- size=wx.DefaultSize, choices=[''], **kargs):
+ size=wx.DefaultSize, vector=None, layer=1, choices=[]):
super(ColumnSelect, self).__init__(parent, id, value, pos, size, choices)
- csvector = kargs['vector'] # vector map to check for attribute tables
- cslayer = kargs['layer'] # data layer connected to attribute table
+ if not vector:
+ return
- if csvector == '' or cslayer == '':
- return
- else:
- self.InsertColumns(csvector, cslayer)
+ self.InsertColumns(vector, layer)
def InsertColumns(self, vector, layer):
- """insert columns for a vector attribute table into the columns combobox"""
- if vector == '' or layer == '': return
- table = VectorDBInfo(vector).layers[str(layer)]
- columnchoices = VectorDBInfo(vector).tables[table]
+ """Insert columns for a vector attribute table into the columns combobox"""
+ dbInfo = VectorDBInfo(vector)
+ table = dbInfo.layers[int(layer)]['table']
+ columnchoices = dbInfo.tables[table]
#columnchoices.sort()
- self.SetItems(columnchoices)
+ self.SetItems(columnchoices.keys())
class DbColumnSelect(wx.ComboBox):
"""
@@ -478,14 +473,19 @@
"""insert columns for a table into the columns combobox"""
if table == '' : return
- cmd = ['db.columns','table=%s' % table]
- if dbdriver != '': cmd.append('driver=%s' % dbdriver)
- if dbdatabase != '': cmd.append('database=%s' % dbdatabase)
+ cmd = ['db.columns',
+ 'table=%s' % table]
+ if dbdriver:
+ cmd.append('driver=%s' % dbdriver)
+ if dbdatabase:
+ cmd.append('database=%s' % dbdatabase)
+
try:
columnchoices = gcmd.Command(cmd).ReadStdOutput()
except gcmd.CmdError:
columnchoices = []
- #columnchoices.sort()
+ # columnchoices.sort()
self.SetItems(columnchoices)
+
More information about the grass-commit
mailing list