[GRASS-SVN] r53916 - in grass/trunk/gui/wxpython: core gui_core lmgr modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 19 06:55:37 PST 2012
Author: wenzeslaus
Date: 2012-11-19 06:55:36 -0800 (Mon, 19 Nov 2012)
New Revision: 53916
Added:
grass/trunk/gui/wxpython/core/events.py
Modified:
grass/trunk/gui/wxpython/core/modulesdata.py
grass/trunk/gui/wxpython/gui_core/goutput.py
grass/trunk/gui/wxpython/gui_core/menu.py
grass/trunk/gui/wxpython/gui_core/widgets.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/modules/extensions.py
Log:
wxGUI/SearchModuleWidget: general notification event, removing GConsole-statusbar dependency (co-author: annakrat)
Added: grass/trunk/gui/wxpython/core/events.py
===================================================================
--- grass/trunk/gui/wxpython/core/events.py (rev 0)
+++ grass/trunk/gui/wxpython/core/events.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -0,0 +1,24 @@
+"""!
+ at package core.events
+
+ at brief General events
+
+Put here only truly general events. Once you find that your event can be
+generated in more than one class, put your event here. Otherwise,
+leave it in your class file.
+
+(C) 2012 by the GRASS Development Team
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Vaclav Petras <wenzeslaus gmail.com>
+"""
+
+
+from wx.lib.newevent import NewCommandEvent
+
+
+# Notification event intended to update statusbar.
+gShowNotification, EVT_SHOW_NOTIFICATION = NewCommandEvent()
+
Property changes on: grass/trunk/gui/wxpython/core/events.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
Modified: grass/trunk/gui/wxpython/core/modulesdata.py
===================================================================
--- grass/trunk/gui/wxpython/core/modulesdata.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/core/modulesdata.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -30,6 +30,10 @@
"""!Holds information about modules.
@todo add doctest
+ @todo analyze what exactly this class is doing
+ @todo split this class into two classes
+
+ @see modules::extensions::ExtensionModulesData
"""
def __init__(self, modulesDesc = None):
Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -273,7 +273,6 @@
self.MakeSearchPaneContent(self.searchPane.GetPane(), modulesData)
self.searchPane.Collapse(True)
self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnSearchPaneChanged, self.searchPane)
- self.search.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
self.search.Bind(EVT_MODULE_SELECTED,
lambda event:
self.cmdPrompt.SetTextAndFocus(event.name + ' '))
@@ -738,16 +737,6 @@
else:
self.cmdPrompt.Unbind(stc.EVT_STC_PAINTED)
self.cmdOutput.Unbind(stc.EVT_STC_PAINTED)
-
- def OnUpdateStatusBar(self, event):
- """!Update statusbar text"""
- if event.GetString():
- nItems = len(self.cmdPrompt.GetCommandItems())
- self.frame.SetStatusText(_('%d modules match') % nItems, 0)
- else:
- self.frame.SetStatusText('', 0)
-
- event.Skip()
def OnCmdOutput(self, event):
"""!Print command output"""
Modified: grass/trunk/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/menu.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/gui_core/menu.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -27,6 +27,7 @@
from core.modulesdata import ModulesData
from core.gcmd import EncodeString
from core.settings import UserSettings
+from core.events import EVT_SHOW_NOTIFICATION
from gui_core.widgets import ItemTree, SearchModuleWidget
from lmgr.menudata import LayerManagerMenuData
@@ -155,6 +156,13 @@
self.search.GetCtrl().Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
self.search.GetCtrl().Bind(wx.EVT_KEY_UP, self.OnKeyUp)
+ # stop propagation of event
+ # because number of matched items differs
+ # from number of matched items in tree
+ # TODO: find the reason for this difference
+ # TODO: use this event for updating statusbar (i.e., don't do this bind)
+ self.Bind(EVT_SHOW_NOTIFICATION, lambda event: None)
+
self._layout()
self.search.SetFocus()
Modified: grass/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -49,6 +49,7 @@
from core import globalvar
from core.debug import Debug
+from core.events import gShowNotification
from wx.lib.newevent import NewEvent
wxSymbolSelectionChanged, EVT_SYMBOL_SELECTION_CHANGED = NewEvent()
@@ -800,20 +801,22 @@
mList = self.modulesData.GetCommandItems()
if self.showChoice:
self.searchChoice.SetItems(mList)
- if self.showTip:
- self.searchTip.SetLabel(_("%d modules found") % len(mList))
- event.Skip()
- return
+ label = _("%d modules found") % len(mList)
+ else:
+ findIn = self.searchBy.GetClientData(self.searchBy.GetSelection())
+ modules, nFound = self.modulesData.FindModules(text = text, findIn = findIn)
+ self.modulesData.SetFilter(modules)
+ if self.showChoice:
+ self.searchChoice.SetItems(self.modulesData.GetCommandItems())
+ self.searchChoice.SetSelection(0)
+ label = _("%d modules match") % nFound
- findIn = self.searchBy.GetClientData(self.searchBy.GetSelection())
- modules, nFound = self.modulesData.FindModules(text = text, findIn = findIn)
- self.modulesData.SetFilter(modules)
- if self.showChoice:
- self.searchChoice.SetItems(self.modulesData.GetCommandItems())
- self.searchChoice.SetSelection(0)
if self.showTip:
- self.searchTip.SetLabel(_("%d modules match") % nFound)
+ self.searchTip.SetLabel(label)
+ newEvent = gShowNotification(self.GetId(), message = label)
+ wx.PostEvent(self, newEvent)
+
event.Skip()
def OnSelectModule(self, event):
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -42,6 +42,7 @@
from core.gcmd import RunCommand, GError, GMessage
from core.settings import UserSettings, GetDisplayVectSettings
from core.utils import SetAddOnPath
+from core.events import EVT_SHOW_NOTIFICATION
from gui_core.preferences import MapsetAccess, PreferencesDialog, EVT_SETTINGS_CHANGED
from lmgr.layertree import LayerTree, LMIcons
from lmgr.menudata import LayerManagerMenuData
@@ -154,6 +155,8 @@
# bindings
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+ self.Bind(EVT_SHOW_NOTIFICATION,
+ lambda event: self.SetStatusText(event.message))
# minimal frame size
self.SetMinSize((globalvar.GM_WINDOW_SIZE[0], 400))
Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py 2012-11-19 13:38:51 UTC (rev 53915)
+++ grass/trunk/gui/wxpython/modules/extensions.py 2012-11-19 14:55:36 UTC (rev 53916)
@@ -40,7 +40,8 @@
class ExtensionModulesData(object):
"""!Holds information about modules.
- @todo add doctest
+ @todo add some test
+ @todo this class has some common methods with core::modulesdata::ModulesData
"""
def __init__(self, modulesDesc):
More information about the grass-commit
mailing list