[GRASS-SVN] r32678 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 11 06:12:40 EDT 2008
Author: martinl
Date: 2008-08-11 06:12:39 -0400 (Mon, 11 Aug 2008)
New Revision: 32678
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI: don't crash when gis element is selected repeatedly
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-08-11 09:45:28 UTC (rev 32677)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2008-08-11 10:12:39 UTC (rev 32678)
@@ -99,7 +99,7 @@
def GetStringValue(self):
str = ""
for value in self.value:
- str += self.seltree.GetItemText(value) + ","
+ str += value + ","
str = str.rstrip(',')
return str
@@ -110,9 +110,13 @@
self.GetElementList(self.type, self.mapsets, self.exceptOf)
if len(self.value) > 0:
- self.seltree.EnsureVisible(self.value[0])
- self.seltree.SelectItem(self.value[0])
-
+ root = self.seltree.GetRootItem()
+ if not root:
+ return
+ item = self.FindItem(root, self.value[0])
+ self.seltree.EnsureVisible(item)
+ self.seltree.SelectItem(item)
+
def SetStringValue(self, value):
# this assumes that item strings are unique...
root = self.seltree.GetRootItem()
@@ -242,7 +246,7 @@
if self.seltree.ItemHasChildren(item):
item = self.FindItem(item, text)
item, cookie = self.seltree.GetNextChild(parentItem, cookie)
- return wx.TreeItemId();
+ return wx.TreeItemId()
def AddItem(self, value, parent=None):
@@ -273,9 +277,10 @@
self.value = [] # cannot select mapset item
else:
if self.multiple is True:
- self.value.append(item)
+ # text item should be unique
+ self.value.append(self.seltree.GetItemText(item))
else:
- self.value = [item, ]
+ self.value = [self.seltree.GetItemText(item), ]
self.Dismiss()
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-08-11 09:45:28 UTC (rev 32677)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2008-08-11 10:12:39 UTC (rev 32678)
@@ -655,39 +655,60 @@
point = wx.GetMousePosition()
toolMenu = wx.Menu()
# Add items to the menu
- copy = wx.MenuItem(toolMenu, wx.ID_ANY, _('Copy features from (background) vector map'))
+ copy = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Copy features from (background) vector map'),
+ kind=wx.ITEM_CHECK)
+ if self.action == "copyLine":
+ print copy.GetId()
+ toolMenu.Check(1, True)
toolMenu.AppendItem(copy)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopy, copy)
- flip = wx.MenuItem(toolMenu, wx.ID_ANY, _('Flip selected lines/boundaries'))
+ flip = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Flip selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(flip)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnFlip, flip)
- merge = wx.MenuItem(toolMenu, wx.ID_ANY, _('Merge selected lines/boundaries'))
+ merge = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Merge selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(merge)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnMerge, merge)
- breakL = wx.MenuItem(toolMenu, wx.ID_ANY, _('Break selected lines/boundaries at intersection'))
+ breakL = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Break selected lines/boundaries at intersection'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(breakL)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnBreak, breakL)
- snap = wx.MenuItem(toolMenu, wx.ID_ANY, _('Snap selected lines/boundaries (only to nodes)'))
+ snap = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Snap selected lines/boundaries (only to nodes)'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(snap)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
- connect = wx.MenuItem(toolMenu, wx.ID_ANY, _('Connect selected lines/boundaries'))
+ connect = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Connect selected lines/boundaries'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(connect)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
- query = wx.MenuItem(toolMenu, wx.ID_ANY, _('Query tool'))
+ query = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Query features'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(query)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnQuery, query)
- zbulk = wx.MenuItem(toolMenu, wx.ID_ANY, _('Z bulk-labeling of 3D lines'))
+ zbulk = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Z bulk-labeling of 3D lines'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(zbulk)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
- typeconv = wx.MenuItem(toolMenu, wx.ID_ANY, _('Feature type conversion'))
+ typeconv = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
+ text=_('Feature type conversion'),
+ kind=wx.ITEM_CHECK)
toolMenu.AppendItem(typeconv)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
More information about the grass-commit
mailing list