[GRASS-SVN] r58390 - in grass/trunk/gui/wxpython: gui_core modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 5 03:23:37 PST 2013
Author: turek
Date: 2013-12-05 03:23:37 -0800 (Thu, 05 Dec 2013)
New Revision: 58390
Modified:
grass/trunk/gui/wxpython/gui_core/gselect.py
grass/trunk/gui/wxpython/modules/colorrules.py
Log:
vector colors dialog fix
Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py 2013-12-05 08:14:46 UTC (rev 58389)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py 2013-12-05 11:23:37 UTC (rev 58390)
@@ -809,7 +809,6 @@
if vector:
layers = GetVectorNumberOfLayers(vector)
-
elif dsn:
ret = RunCommand('v.in.ogr',
read = True,
@@ -916,7 +915,8 @@
param = None, **kwargs):
self.defaultValue = value
self.param = param
-
+ self.columns = []
+
wx.combo.ComboCtrl.__init__(self, parent, id, size = size, **kwargs)
self.GetChildren()[0].SetName("ColumnSelect")
self.GetChildren()[0].type = type
@@ -928,7 +928,10 @@
if vector:
self.InsertColumns(vector, layer)
self.GetChildren()[0].Bind(wx.EVT_KEY_UP, self.OnKeyUp)
-
+
+ def GetColumns(self):
+ return self.columns
+
def OnKeyUp(self, event):
"""!Shows popupwindow if down arrow key is released"""
if event.GetKeyCode() == wx.WXK_DOWN and not self.IsPopupShown():
@@ -936,6 +939,10 @@
else:
event.Skip()
+ def Clear(self):
+ self.tcp.DeleteAllItems()
+ self.SetValue('')
+
def InsertColumns(self, vector, layer, excludeKey = False, excludeCols = None, type = None, dbInfo = None):
"""!Insert columns for a vector attribute table into the columns combobox
@@ -947,7 +954,7 @@
"""
if not dbInfo:
dbInfo = VectorDBInfo(vector)
-
+
try:
try:
layer = int(layer)
@@ -957,35 +964,35 @@
table = dbInfo.GetTable(layer)
columnchoices = dbInfo.GetTableDesc(table)
keyColumn = dbInfo.GetKeyColumn(layer)
- columns = len(columnchoices.keys()) * ['']
+ self.columns = len(columnchoices.keys()) * ['']
for key, val in columnchoices.iteritems():
- columns[val['index']] = key
+ self.columns[val['index']] = key
if excludeKey: # exclude key column
- columns.remove(keyColumn)
+ self.columns.remove(keyColumn)
if excludeCols: # exclude key column
for key in columnchoices.iterkeys():
if key in excludeCols:
- columns.remove(key)
+ self.columns.remove(key)
if type: # only selected column types
for key, value in columnchoices.iteritems():
if value['type'] not in type:
try:
- columns.remove(key)
+ self.columns.remove(key)
except ValueError:
pass
except (KeyError, ValueError):
- columns = list()
+ self.columns[:] = []
# update list
self.tcp.DeleteAllItems()
- for col in columns:
+ for col in self.columns:
self.tcp.AddItem(col)
self.SetValue(self.defaultValue)
if self.param:
value = self.param.get('value', '')
- if value != '' and value in columns:
+ if value != '' and value in self.columns:
self.SetValue(value)
def InsertTableColumns(self, table, driver=None, database=None):
@@ -995,7 +1002,7 @@
@param driver driver name
@param database database name
"""
- columns = list()
+ self.columns[:] = []
ret = RunCommand('db.columns',
read = True,
@@ -1004,17 +1011,17 @@
table = table)
if ret:
- columns = ret.splitlines()
+ self.columns = ret.splitlines()
# update list
self.tcp.DeleteAllItems()
self.SetValue(self.defaultValue)
- for col in columns:
+ for col in self.columns:
self.tcp.AddItem(col)
if self.param:
value = self.param.get('value', '')
- if value != '' and value in columns:
+ if value != '' and value in self.columns:
self.SetValue(value)
class DbaseSelect(wx.lib.filebrowsebutton.DirBrowseButton):
Modified: grass/trunk/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/modules/colorrules.py 2013-12-05 08:14:46 UTC (rev 58389)
+++ grass/trunk/gui/wxpython/modules/colorrules.py 2013-12-05 11:23:37 UTC (rev 58390)
@@ -967,9 +967,10 @@
# additional bindings for vector color management
self.Bind(wx.EVT_COMBOBOX, self.OnLayerSelection, self.layerSelect)
- self.Bind(wx.EVT_COMBOBOX, self.OnSourceColumnSelection, self.sourceColumn)
- self.Bind(wx.EVT_COMBOBOX, self.OnFromColSelection, self.fromColumn)
- self.Bind(wx.EVT_COMBOBOX, self.OnToColSelection, self.toColumn)
+
+ self.sourceColumn.Bind(wx.EVT_TEXT, self.OnSourceColumnSelection)
+ self.fromColumn.Bind(wx.EVT_TEXT, self.OnFromColSelection)
+ self.toColumn.Bind(wx.EVT_TEXT, self.OnToColSelection)
self.Bind(wx.EVT_BUTTON, self.OnAddColumn, self.addColumn)
self._initLayer()
@@ -1148,8 +1149,8 @@
def OnCheckColumn(self, event):
"""!Use color column instead of color table"""
if self.useColumn.GetValue():
- self.properties['loadColumn'] = self.fromColumn.GetStringSelection()
- self.properties['storeColumn'] = self.toColumn.GetStringSelection()
+ self.properties['loadColumn'] = self.fromColumn.GetValue()
+ self.properties['storeColumn'] = self.toColumn.GetValue()
self.fromColumn.Enable(True)
self.toColumn.Enable(True)
self.colorTable = False
@@ -1219,6 +1220,7 @@
# check for db connection
self.dbInfo = VectorDBInfo(self.inmap)
enable = True
+
if not len(self.dbInfo.layers): # no connection
if not (self.version7 and self.attributeType == 'color'): # otherwise it doesn't matter
wx.CallAfter(self.NoConnection, self.inmap)
@@ -1305,8 +1307,8 @@
self.sourceColumn.InsertColumns(vector = self.inmap, layer = vlayer,
type = ['integer', 'double precision'], dbInfo = self.dbInfo,
excludeCols = ['tmpColumn'])
- self.sourceColumn.SetStringSelection('cat')
- self.properties['sourceColumn'] = self.sourceColumn.GetString(0)
+ self.sourceColumn.SetValue('cat')
+ self.properties['sourceColumn'] = self.sourceColumn.GetValue()
if self.attributeType == 'color':
type = ['character']
@@ -1317,12 +1319,16 @@
self.toColumn.InsertColumns(vector = self.inmap, layer = vlayer, type = type,
dbInfo = self.dbInfo, excludeCols = ['tmpColumn'])
- found = self.fromColumn.FindString(self.columnsProp[self.attributeType]['name'])
+ v = self.columnsProp[self.attributeType]['name']
+ found = False
+ if v in self.fromColumn.GetColumns():
+ found = True
+
if found != wx.NOT_FOUND:
- self.fromColumn.SetSelection(found)
- self.toColumn.SetSelection(found)
- self.properties['loadColumn'] = self.fromColumn.GetString(found)
- self.properties['storeColumn'] = self.toColumn.GetString(found)
+ self.fromColumn.SetValue(v)
+ self.toColumn.SetValue(v)
+ self.properties['loadColumn'] = v
+ self.properties['storeColumn'] = v
else:
self.properties['loadColumn'] = ''
self.properties['storeColumn'] = ''
@@ -1338,7 +1344,7 @@
def OnAddColumn(self, event):
"""!Add GRASS(RGB,SIZE,WIDTH) column if it doesn't exist"""
- if self.columnsProp[self.attributeType]['name'] not in self.fromColumn.GetItems():
+ if self.columnsProp[self.attributeType]['name'] not in self.fromColumn.GetColumns():
if self.version7:
modul = 'v.db.addcolumn'
else:
@@ -1350,8 +1356,8 @@
self.columnsProp[self.attributeType]['type1']))
self.toColumn.InsertColumns(self.inmap, self.properties['layer'],
type = self.columnsProp[self.attributeType]['type2'])
- self.toColumn.SetStringSelection(self.columnsProp[self.attributeType]['name'])
- self.properties['storeColumn'] = self.toColumn.GetStringSelection()
+ self.toColumn.SetValue(self.columnsProp[self.attributeType]['name'])
+ self.properties['storeColumn'] = self.toColumn.GetValue()
self.LoadTable()
else:
More information about the grass-commit
mailing list