[GRASS-SVN] r57176 - in grass/trunk/gui/wxpython: core gui_core lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 16 07:36:44 PDT 2013
Author: annakrat
Date: 2013-07-16 07:36:44 -0700 (Tue, 16 Jul 2013)
New Revision: 57176
Modified:
grass/trunk/gui/wxpython/core/menutree.py
grass/trunk/gui/wxpython/gui_core/menu.py
grass/trunk/gui/wxpython/gui_core/widgets.py
grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI/search tree: simplify graphical interface, add tooltips
Modified: grass/trunk/gui/wxpython/core/menutree.py
===================================================================
--- grass/trunk/gui/wxpython/core/menutree.py 2013-07-16 14:32:43 UTC (rev 57175)
+++ grass/trunk/gui/wxpython/core/menutree.py 2013-07-16 14:36:44 UTC (rev 57176)
@@ -100,10 +100,10 @@
desc = _(desc.text)
else:
desc = ""
- if keywords != None:
+ if keywords is None or keywords.text is None:
+ keywords = ""
+ else:
keywords = keywords.text
- else:
- keywords = ""
if shortcut != None:
shortcut = shortcut.text
else:
Modified: grass/trunk/gui/wxpython/gui_core/menu.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/menu.py 2013-07-16 14:32:43 UTC (rev 57175)
+++ grass/trunk/gui/wxpython/gui_core/menu.py 2013-07-16 14:36:44 UTC (rev 57176)
@@ -129,9 +129,10 @@
# tree
self._tree = CTreeView(model=model, parent=self)
+ self._tree.SetToolTipString(_("Double-click or Ctrl-Enter to run selected module"))
- self._dataBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
- label = " %s " % _("Menu tree (double-click or Ctrl-Enter to run command)"))
+# self._dataBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
+# label = " %s " % _("Module tree"))
# search widget
self._search = SearchModuleWidget(parent=self,
@@ -142,7 +143,7 @@
# buttons
self._btnRun = wx.Button(self, id=wx.ID_OK, label=_("&Run"))
- self._btnRun.SetToolTipString(_("Run selected command from the menu tree"))
+ self._btnRun.SetToolTipString(_("Run selected module from the tree"))
# bindings
self._btnRun.Bind(wx.EVT_BUTTON, lambda evt: self.Run())
@@ -160,7 +161,7 @@
sizer = wx.BoxSizer(wx.VERTICAL)
# body
- dataSizer = wx.StaticBoxSizer(self._dataBox, wx.HORIZONTAL)
+ dataSizer = wx.BoxSizer(wx.HORIZONTAL)
dataSizer.Add(item = self._tree, proportion =1,
flag = wx.EXPAND)
Modified: grass/trunk/gui/wxpython/gui_core/widgets.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/widgets.py 2013-07-16 14:32:43 UTC (rev 57175)
+++ grass/trunk/gui/wxpython/gui_core/widgets.py 2013-07-16 14:36:44 UTC (rev 57176)
@@ -782,6 +782,7 @@
self._model = model
self._results = [] # list of found nodes
self._resultIndex = -1
+ self._searchKeys = ['description', 'keywords', 'command']
self.moduleSelected = Signal('SearchModuleWidget.moduleSelected')
self.showSearchResult = Signal('SearchModuleWidget.showSearchResult')
@@ -789,28 +790,18 @@
wx.Panel.__init__(self, parent = parent, id = wx.ID_ANY, **kwargs)
- self._searchDict = { _('description') : 'description',
- _('command') : 'command',
- _('keywords') : 'keywords' }
+# self._box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+# label = " %s " % _("Find module - (press Enter for next match)"))
-
- self._box = wx.StaticBox(parent = self, id = wx.ID_ANY,
- label = " %s " % _("Find module - (press Enter for next match)"))
-
- self._searchBy = wx.Choice(parent = self, id = wx.ID_ANY)
- items = [_('description'), _('keywords'), _('command')]
- datas = ['description', 'keywords', 'command']
- for item, data in zip(items, datas):
- self._searchBy.Append(item = item, clientData = data)
- self._searchBy.SetSelection(0)
- self._searchBy.Bind(wx.EVT_CHOICE, self.OnSearchModule)
-
if sys.platform == 'win32':
- ctrl = wx.TextCtrl
+ self._search = wx.TextCtrl(parent = self, id = wx.ID_ANY,
+ size = (-1, 25), style = wx.TE_PROCESS_ENTER)
else:
- ctrl = wx.SearchCtrl
- self._search = ctrl(parent = self, id = wx.ID_ANY,
- size = (-1, 25), style = wx.TE_PROCESS_ENTER)
+ self._search = wx.SearchCtrl(parent = self, id = wx.ID_ANY,
+ size = (-1, 25), style = wx.TE_PROCESS_ENTER)
+ self._search.SetDescriptiveText(_('Fulltext search'))
+ self._search.SetToolTipString(_("Type to search in all modules. Press Enter for next match."))
+
self._search.Bind(wx.EVT_TEXT, self.OnSearchModule)
self._search.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
@@ -820,34 +811,32 @@
if self._showChoice:
self._searchChoice = wx.Choice(parent = self, id = wx.ID_ANY)
- self._searchChoice.SetItems(self._searchModule(key='command', value=''))
+ self._searchChoice.SetItems(self._searchModule(keys=['command'], value=''))
self._searchChoice.Bind(wx.EVT_CHOICE, self.OnSelectModule)
self._layout()
def _layout(self):
"""!Do layout"""
- sizer = wx.StaticBoxSizer(self._box, wx.HORIZONTAL)
- gridSizer = wx.GridBagSizer(hgap = 3, vgap = 3)
-
- gridSizer.Add(item = self._searchBy,
- flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
- gridSizer.Add(item = self._search,
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (0, 1))
- row = 1
+ sizer = wx.BoxSizer(wx.HORIZONTAL)
+ boxSizer = wx.BoxSizer(wx.VERTICAL)
+
+ boxSizer.Add(item=self._search,
+ flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.BOTTOM,
+ border=5)
if self._showChoice:
- gridSizer.Add(item = self._searchChoice,
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
- row += 1
+ hSizer = wx.BoxSizer(wx.HORIZONTAL)
+ hSizer.Add(item=self._searchChoice,
+ flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.BOTTOM,
+ border=5)
+ hSizer.AddStretchSpacer()
+ boxSizer.Add(item=hSizer, flag=wx.EXPAND)
if self._showTip:
- gridSizer.Add(item = self._searchTip,
- flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
- row += 1
+ boxSizer.Add(item=self._searchTip,
+ flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
- gridSizer.AddGrowableCol(1)
+ sizer.Add(item = boxSizer, proportion = 1)
- sizer.Add(item = gridSizer, proportion = 1)
-
self.SetSizer(sizer)
sizer.Fit(self)
@@ -861,19 +850,13 @@
self.showSearchResult.emit(result=self._results[self._resultIndex])
event.Skip()
- def GetSelection(self):
- """!Get selected element"""
- selection = self._searchBy.GetStringSelection()
-
- return self._searchDict[selection]
-
- def SetSelection(self, i):
- """!Set selection element"""
- self._searchBy.SetSelection(i)
-
def OnSearchModule(self, event):
"""!Search module by keywords or description"""
- commands = self._searchModule(key=self.GetSelection(), value=self._search.GetValue())
+ value = self._search.GetValue()
+ if len(value) <= 2:
+ self.showNotification.emit(message=_("Searching, please type more characters."))
+ return
+ commands = self._searchModule(keys=self._searchKeys, value=value)
if self._showChoice:
self._searchChoice.SetItems(commands)
if commands:
@@ -887,8 +870,13 @@
event.Skip()
- def _searchModule(self, key, value):
- nodes = self._model.SearchNodes(key=key, value=value)
+ def _searchModule(self, keys, value):
+ nodes = set()
+ for key in keys:
+ nodes.update(self._model.SearchNodes(key=key, value=value))
+
+ nodes = list(nodes)
+ nodes.sort(key=lambda node: self._model.GetIndexOfNode(node))
self._results = nodes
self._resultIndex = -1
return [node.data['command'] for node in nodes if node.data['command']]
@@ -906,7 +894,6 @@
def Reset(self):
"""!Reset widget"""
- self._searchBy.SetSelection(0)
self._search.SetValue('')
if self._showTip:
self._searchTip.SetLabel('')
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-07-16 14:32:43 UTC (rev 57175)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-07-16 14:36:44 UTC (rev 57176)
@@ -319,7 +319,7 @@
if not UserSettings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'):
self.search = SearchModuleWindow(parent = self, model=self._menuTreeBuilder.GetModel())
self.search.showNotification.connect(lambda message: self.SetStatusText(message))
- self.notebook.AddPage(page = self.search, text = _("Search module"), name = 'search')
+ self.notebook.AddPage(page = self.search, text = _("Search modules"), name = 'search')
else:
self.search = None
More information about the grass-commit
mailing list