[GRASS-SVN] r55387 - grass/trunk/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Mar 14 14:04:51 PDT 2013
Author: annakrat
Date: 2013-03-14 14:04:51 -0700 (Thu, 14 Mar 2013)
New Revision: 55387
Modified:
grass/trunk/gui/wxpython/gui_core/dialogs.py
grass/trunk/gui/wxpython/gui_core/widgets.py
Log:
wxGUI: continue replacing events (symbolSelectionChanged)
Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-03-14 20:49:32 UTC (rev 55386)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-03-14 21:04:51 UTC (rev 55387)
@@ -40,7 +40,6 @@
import wx
import wx.lib.filebrowsebutton as filebrowse
import wx.lib.mixins.listctrl as listmix
-from wx.lib.newevent import NewEvent
from grass.script import core as grass
from grass.script import task as gtask
@@ -51,7 +50,7 @@
from core.gcmd import GError, RunCommand, GMessage
from gui_core.gselect import LocationSelect, MapsetSelect, Select, OgrTypeSelect, GdalSelect, MapsetSelect
from gui_core.forms import GUI
-from gui_core.widgets import SingleSymbolPanel, EVT_SYMBOL_SELECTION_CHANGED, GListCtrl, SimpleValidator
+from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator
from core.utils import GetLayerNameFromCmd, GetValidLayerName
from core.settings import UserSettings, GetDisplayVectSettings
from core.debug import Debug
@@ -2398,7 +2397,6 @@
self.panels = self._createSymbolPanels(mainPanel)
for panel in self.panels:
vSizer.Add(panel, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
- panel.Bind(EVT_SYMBOL_SELECTION_CHANGED, self.SelectionChanged)
mainSizer.Add(vSizer, proportion = 1, flag = wx.ALL| wx.EXPAND, border = 5)
self.btnCancel = wx.Button(parent = mainPanel, id = wx.ID_CANCEL)
@@ -2459,6 +2457,7 @@
symbolPanels = []
for img in images:
iP = SingleSymbolPanel(parent = panel, symbolPath = img)
+ iP.symbolSelectionChanged.connect(self.SelectionChanged)
sizer.Add(item = iP, proportion = 0, flag = wx.ALIGN_CENTER)
symbolPanels.append(iP)
@@ -2492,22 +2491,22 @@
self.btnOK.Disable()
self.infoLabel.SetLabel('')
- def SelectionChanged(self, event):
+ def SelectionChanged(self, name, doubleClick):
"""!Selected symbol changed."""
- if event.doubleClick:
+ if doubleClick:
self.EndModal(wx.ID_OK)
# deselect all
for i in range(len(self.panels)):
for panel in self.symbolPanels[i]:
- if panel.GetName() != event.name:
+ if panel.GetName() != name:
panel.Deselect()
self.btnOK.Enable()
- self.selected = event.name
+ self.selected = name
self.selectedDir = self.folderChoice.GetStringSelection()
- self.infoLabel.SetLabel(event.name)
+ self.infoLabel.SetLabel(name)
def GetSelectedSymbolName(self):
"""!Returns currently selected symbol name (e.g. 'basic/x').
Modified: grass/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py 2013-03-14 20:49:32 UTC (rev 55386)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py 2013-03-14 21:04:51 UTC (rev 55387)
@@ -56,7 +56,6 @@
from core.debug import Debug
from wx.lib.newevent import NewEvent
-wxSymbolSelectionChanged, EVT_SYMBOL_SELECTION_CHANGED = NewEvent()
class NotebookController:
@@ -731,9 +730,15 @@
def __init__(self, parent, symbolPath):
"""!Panel constructor
+ Signal symbolSelectionChanged - symbol selected
+ - attribute 'name' (symbol name)
+ - attribute 'doubleClick' (underlying cause)
+
@param parent parent (gui_core::dialog::SymbolDialog)
@param symbolPath absolute path to symbol
"""
+ self.symbolSelectionChanged = Signal('SingleSymbolPanel.symbolSelectionChanged')
+
wx.Panel.__init__(self, parent, id = wx.ID_ANY, style = wx.BORDER_RAISED)
self.SetName(os.path.splitext(os.path.basename(symbolPath))[0])
self.sBmp = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(symbolPath))
@@ -760,12 +765,10 @@
self.SetBackgroundColour(self.selectColor)
event.Skip()
- event = wxSymbolSelectionChanged(name = self.GetName(), doubleClick = False)
- wx.PostEvent(self.GetParent(), event)
+ self.symbolSelectionChanged.emit(name=self.GetName(), doubleClick=False)
def OnDoubleClick(self, event):
- event = wxSymbolSelectionChanged(name = self.GetName(), doubleClick = True)
- wx.PostEvent(self.GetParent(), event)
+ self.symbolSelectionChanged.emit(name=self.GetName(), doubleClick=True)
def Deselect(self):
"""!Panel deselected, background changes back to default"""
More information about the grass-commit
mailing list