[GRASS-SVN] r53548 - grass/trunk/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 25 03:01:11 PDT 2012
Author: martinl
Date: 2012-10-25 03:01:10 -0700 (Thu, 25 Oct 2012)
New Revision: 53548
Modified:
grass/trunk/gui/wxpython/gui_core/ghelp.py
grass/trunk/gui/wxpython/gui_core/menu.py
Log:
wxGUI: improve search module widget (Ctrl+Enter to run selected command)
Modified: grass/trunk/gui/wxpython/gui_core/ghelp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/ghelp.py 2012-10-24 19:09:15 UTC (rev 53547)
+++ grass/trunk/gui/wxpython/gui_core/ghelp.py 2012-10-25 10:01:10 UTC (rev 53548)
@@ -57,7 +57,7 @@
_('keywords') : 'keywords' }
self.box = wx.StaticBox(parent = self, id = wx.ID_ANY,
- label = " %s " % _("Find module(s)"))
+ label = " %s " % _("Find module - (press Enter for next match)"))
self.searchBy = wx.Choice(parent = self, id = wx.ID_ANY,
choices = [_('description'),
@@ -65,10 +65,10 @@
_('command')])
self.searchBy.SetSelection(0)
- self.search = wx.TextCtrl(parent = self, id = wx.ID_ANY,
- value = "", size = (-1, 25),
- style = wx.TE_PROCESS_ENTER)
- self.search.Bind(wx.EVT_TEXT, self.OnSearchModule)
+ self.search = wx.SearchCtrl(parent = self, id = wx.ID_ANY,
+ size = (-1, 25), style = wx.TE_PROCESS_ENTER)
+ if self.cmdPrompt:
+ self.search.Bind(wx.EVT_TEXT, self.OnSearchModule)
if self.showTip:
self.searchTip = StaticWrapText(parent = self, id = wx.ID_ANY,
@@ -108,6 +108,10 @@
self.SetSizer(sizer)
sizer.Fit(self)
+ def GetCtrl(self):
+ """!Get SearchCtrl widget"""
+ return self.search
+
def GetSelection(self):
"""!Get selected element"""
selection = self.searchBy.GetStringSelection()
Modified: grass/trunk/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/menu.py 2012-10-24 19:09:15 UTC (rev 53547)
+++ grass/trunk/gui/wxpython/gui_core/menu.py 2012-10-25 10:01:10 UTC (rev 53548)
@@ -132,7 +132,7 @@
wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
self.dataBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
- label = " %s " % _("Menu tree (double-click to run command)"))
+ label = " %s " % _("Menu tree (double-click or Ctrl-Enter to run command)"))
# tree
self.tree = MenuTree(parent = self, data = ManagerData())
self.tree.Load()
@@ -142,15 +142,16 @@
# buttons
self.btnRun = wx.Button(self, id = wx.ID_OK, label = _("&Run"))
- self.btnRun.SetToolTipString(_("Run selected command"))
+ self.btnRun.SetToolTipString(_("Run selected command from the menu tree"))
self.btnRun.Enable(False)
# bindings
self.btnRun.Bind(wx.EVT_BUTTON, self.OnRun)
self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated)
self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnItemSelected)
- self.search.Bind(wx.EVT_TEXT_ENTER, self.OnShowItem)
- self.search.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
+# self.search.GetCtrl().Bind(wx.EVT_TEXT_ENTER, self.OnShowItem)
+ self.search.GetCtrl().Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
+ self.search.GetCtrl().Bind(wx.EVT_KEY_UP, self.OnKeyUp)
self._layout()
@@ -211,6 +212,13 @@
else:
eval(handler)(None)
+ def OnKeyUp(self, event):
+ if event.GetKeyCode() == wx.WXK_RETURN:
+ if event.ControlDown():
+ self.OnRun(event)
+ else:
+ self.OnShowItem(event)
+
def OnShowItem(self, event):
"""!Show selected item"""
self.tree.OnShowItem(event)
@@ -253,11 +261,11 @@
def OnUpdateStatusBar(self, event):
"""!Update statusbar text"""
element = self.search.GetSelection()
- self.tree.SearchItems(element = element,
- value = event.GetString())
+ value = event.GetEventObject().GetValue()
+ self.tree.SearchItems(element = element, value = value)
nItems = len(self.tree.itemsMarked)
- if event.GetString():
+ if value:
self.parent.SetStatusText(_("%d modules match") % nItems, 0)
else:
self.parent.SetStatusText("", 0)
More information about the grass-commit
mailing list