[GRASS-SVN] r42212 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 10 08:53:39 EDT 2010
Author: martinl
Date: 2010-05-10 08:53:37 -0400 (Mon, 10 May 2010)
New Revision: 42212
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
Log:
wxGUI: search module engine collapsible
(merge r42211 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py 2010-05-10 12:23:07 UTC (rev 42211)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/ghelp.py 2010-05-10 12:53:37 UTC (rev 42212)
@@ -64,7 +64,9 @@
class SearchModuleWindow(wx.Panel):
"""!Search module window (used in MenuTreeWindow)"""
- def __init__(self, parent, id = wx.ID_ANY, cmdPrompt = None, showChoice = True, **kwargs):
+ def __init__(self, parent, id = wx.ID_ANY, cmdPrompt = None,
+ showChoice = True, showTip = False, **kwargs):
+ self.showTip = showTip
self.showChoice = showChoice
self.cmdPrompt = cmdPrompt
@@ -88,11 +90,14 @@
style = wx.TE_PROCESS_ENTER)
self.search.Bind(wx.EVT_TEXT, self.OnSearchModule)
- if self.showChoice:
+ if self.showTip:
self.searchTip = menuform.StaticWrapText(parent = self, id = wx.ID_ANY,
size = (-1, 35))
-
+
+ if self.showChoice:
self.searchChoice = wx.Choice(parent = self, id = wx.ID_ANY)
+ if self.cmdPrompt:
+ self.searchChoice.SetItems(self.cmdPrompt.GetCommandItems())
self.searchChoice.Bind(wx.EVT_CHOICE, self.OnSelectModule)
self._layout()
@@ -107,11 +112,15 @@
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
+ if self.showTip:
+ gridSizer.Add(item = self.searchTip,
+ flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
+ row += 1
+
if self.showChoice:
- gridSizer.Add(item = self.searchTip,
- flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (1, 0), span = (1, 2))
gridSizer.Add(item = self.searchChoice,
- flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (2, 0), span = (1, 2))
+ flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, pos = (row, 0), span = (1, 2))
sizer.Add(item = gridSizer, proportion = 1)
@@ -137,6 +146,11 @@
text = event.GetString()
if not text:
self.cmdPrompt.SetFilter(None)
+ mList = self.cmdPrompt.GetCommandItems()
+ self.searchChoice.SetItems(mList)
+ if self.showTip:
+ self.searchTip.SetLabel(_("%d modules found") % len(mList))
+ event.Skip()
return
modules = dict()
@@ -162,9 +176,12 @@
modules[group].append(name)
self.cmdPrompt.SetFilter(modules)
- self.searchTip.SetLabel(_("%d modules found") % iFound)
+ if self.showTip:
+ self.searchTip.SetLabel(_("%d modules found") % iFound)
self.searchChoice.SetItems(self.cmdPrompt.GetCommandItems())
+ event.Skip()
+
def OnSelectModule(self, event):
"""!Module selected from choice, update command prompt"""
cmd = event.GetString().split(' ', 1)[0]
@@ -178,7 +195,8 @@
self.cmdPrompt.SetFocus()
desc = self.cmdPrompt.GetCommandDesc(cmd)
- self.searchTip.SetLabel(desc)
+ if self.showTip:
+ self.searchTip.SetLabel(desc)
class MenuTreeWindow(wx.Panel):
"""!Show menu tree"""
@@ -315,7 +333,7 @@
nItems = len(self.tree.itemsMarked)
if event.GetString():
- self.parent.SetStatusText(_("%d items match") % nItems, 0)
+ self.parent.SetStatusText(_("%d modules match") % nItems, 0)
else:
self.parent.SetStatusText("", 0)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-05-10 12:23:07 UTC (rev 42211)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-05-10 12:53:37 UTC (rev 42212)
@@ -1538,7 +1538,7 @@
label=" %s " % _("Command"))
self.cmd_prompt = prompt.GPromptSTC(parent = self)
- self.search = SearchModuleWindow(parent = self.panel, cmdPrompt = self.cmd_prompt)
+ self.search = SearchModuleWindow(parent = self.panel, cmdPrompt = self.cmd_prompt, showTip = True)
# get commands
items = self.cmd_prompt.GetCommandItems()
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2010-05-10 12:23:07 UTC (rev 42211)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2010-05-10 12:53:37 UTC (rev 42212)
@@ -187,11 +187,20 @@
# search & command prompt
self.cmd_prompt = prompt.GPromptSTC(parent = self)
- self.search = SearchModuleWindow(parent = self.panelPrompt, cmdPrompt = self.cmd_prompt)
-
if self.parent.GetName() != 'LayerManager':
- self.search.Hide()
+ self.search = None
self.cmd_prompt.Hide()
+ else:
+ self.infoCollapseLabelExp = _("Click here to show search module engine")
+ self.infoCollapseLabelCol = _("Click here to hide search module engine")
+ self.searchPane = wx.CollapsiblePane(parent = self.panelOutput,
+ label = self.infoCollapseLabelExp,
+ style = wx.CP_DEFAULT_STYLE |
+ wx.CP_NO_TLW_RESIZE | wx.EXPAND)
+ self.MakeSearchPaneContent(self.searchPane.GetPane())
+ self.searchPane.Collapse(True)
+ self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.OnSearchPaneChanged, self.searchPane)
+ self.search.Bind(wx.EVT_TEXT, self.OnUpdateStatusBar)
#
# stream redirection
@@ -234,15 +243,15 @@
OutputSizer = wx.BoxSizer(wx.VERTICAL)
PromptSizer = wx.BoxSizer(wx.VERTICAL)
ButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
-
+
+ if self.search and self.search.IsShown():
+ OutputSizer.Add(item=self.searchPane, proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=3)
OutputSizer.Add(item=self.cmd_output, proportion=1,
flag=wx.EXPAND | wx.ALL, border=3)
OutputSizer.Add(item=self.console_progressbar, proportion=0,
flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=3)
- if self.search.IsShown():
- PromptSizer.Add(item=self.search, proportion=0,
- flag=wx.EXPAND | wx.ALL, border=3)
PromptSizer.Add(item=self.cmd_prompt, proportion=1,
flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=3)
@@ -268,20 +277,40 @@
# split window
if self.parent.GetName() == 'LayerManager':
- self.SplitHorizontally(self.panelOutput, self.panelPrompt, -75)
- self.SetMinimumPaneSize(self.btn_cmd_clear.GetSize()[1] + 75)
+ self.SplitHorizontally(self.panelOutput, self.panelPrompt, -50)
+ self.SetMinimumPaneSize(self.btn_cmd_clear.GetSize()[1] + 50)
else:
self.SplitHorizontally(self.panelOutput, self.panelPrompt, -45)
self.SetMinimumPaneSize(self.btn_cmd_clear.GetSize()[1] + 10)
self.SetSashGravity(1.0)
- self.Fit()
-
# layout
self.SetAutoLayout(True)
self.Layout()
+ def MakeSearchPaneContent(self, pane):
+ """!Create search pane"""
+ border = wx.BoxSizer(wx.VERTICAL)
+
+ self.search = SearchModuleWindow(parent = pane, cmdPrompt = self.cmd_prompt)
+
+ border.Add(item = self.search, proportion = 1,
+ flag = wx.EXPAND | wx.ALL, border = 1)
+
+ pane.SetSizer(border)
+ border.Fit(pane)
+
+ def OnSearchPaneChanged(self, event):
+ """!Collapse search module box"""
+ if self.searchPane.IsExpanded():
+ self.searchPane.SetLabel(self.infoCollapseLabelCol)
+ else:
+ self.searchPane.SetLabel(self.infoCollapseLabelExp)
+
+ self.Layout()
+ self.SendSizeEvent()
+
def GetPanel(self, prompt = True):
"""!Get panel
@@ -541,6 +570,16 @@
"""!Get running command or None"""
return self.requestQ.get()
+ def OnUpdateStatusBar(self, event):
+ """!Update statusbar text"""
+ if event.GetString():
+ nItems = len(self.cmd_prompt.GetCommandItems())
+ self.parent.SetStatusText(_('%d modules match') % nItems, 0)
+ else:
+ self.parent.SetStatusText('', 0)
+
+ event.Skip()
+
def OnCmdOutput(self, event):
"""!Print command output"""
message = event.text
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2010-05-10 12:23:07 UTC (rev 42211)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2010-05-10 12:53:37 UTC (rev 42212)
@@ -561,6 +561,9 @@
else:
mList = self.moduleList
+ if not mList:
+ return items
+
prefixes = mList.keys()
prefixes.sort()
@@ -569,6 +572,8 @@
name = prefix + '.' + command
items.append(name)
+ items.sort()
+
return items
def _getListOfModules(self):
More information about the grass-commit
mailing list