[GRASS-SVN] r42104 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 4 05:05:28 EDT 2010


Author: martinl
Date: 2010-05-04 05:05:27 -0400 (Tue, 04 May 2010)
New Revision: 42104

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/help.py
Log:
wxGUI: SearchModuleWindow added
(merge r42103 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-05-04 09:02:19 UTC (rev 42103)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2010-05-04 09:05:27 UTC (rev 42104)
@@ -40,6 +40,7 @@
 
 from debug       import Debug
 from preferences import globalSettings as UserSettings
+from help        import SearchModuleWindow
 
 wxCmdOutput,   EVT_CMD_OUTPUT   = NewEvent()
 wxCmdProgress, EVT_CMD_PROGRESS = NewEvent()
@@ -163,7 +164,7 @@
         #
         self.requestQ = Queue.Queue()
         self.resultQ = Queue.Queue()
-
+        
         #
         # progress bar
         #
@@ -183,19 +184,11 @@
         self.Bind(EVT_CMD_RUN, self.OnCmdRun)
         self.Bind(EVT_CMD_DONE, self.OnCmdDone)
         
-        #
         # search & command prompt
-        #
-        self.searchBy = wx.Choice(parent = self.panelPrompt, id = wx.ID_ANY,
-                                  choices = [_("description"),
-                                             _("keywords")])
+        self.search = SearchModuleWindow(parent = self.panelPrompt)
         
-        self.search = wx.TextCtrl(parent = self.panelPrompt, id = wx.ID_ANY,
-                                  value = "", size = (-1, 25))
-        
         self.cmd_prompt = prompt.GPromptSTC(parent = self)
         if self.parent.GetName() != 'LayerManager':
-            self.searchBy.Hide()
             self.search.Hide()
             self.cmd_prompt.Hide()
         
@@ -226,7 +219,7 @@
                                    size=(125,-1))
         self.btn_abort.SetToolTipString(_("Abort the running command"))
         self.btn_abort.Enable(False)
-
+        
         self.btn_cmd_clear.Bind(wx.EVT_BUTTON,     self.cmd_prompt.OnCmdErase)
         self.btn_console_clear.Bind(wx.EVT_BUTTON, self.ClearHistory)
         self.btn_console_save.Bind(wx.EVT_BUTTON,  self.SaveHistory)
@@ -241,25 +234,16 @@
         """!Do layout"""
         OutputSizer = wx.BoxSizer(wx.VERTICAL)
         PromptSizer = wx.BoxSizer(wx.VERTICAL)
-        SearchSizer = wx.BoxSizer(wx.HORIZONTAL)
         ButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
-
+        
         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.searchBy.IsShown():
-            SearchSizer.Add(item = wx.StaticText(parent = self.panelPrompt, id = wx.ID_ANY,
-                                                 label = _("Find module:")),
-                            proportion = 0, flag = wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border = 3)
-        SearchSizer.Add(item = self.searchBy,
-                        proportion = 0, flag = wx.LEFT, border = 3)
-        SearchSizer.Add(item = self.search,
-                        proportion = 1, flag = wx.LEFT | wx.EXPAND, border = 3)
-        
-        PromptSizer.Add(item=SearchSizer, proportion=0,
-                        flag=wx.EXPAND | wx.ALL, border=1)
+        if self.search.IsShown():
+            PromptSizer.Add(item=self.search, proportion=0,
+                            flag=wx.EXPAND | wx.ALL, border=1)
         PromptSizer.Add(item=self.cmd_prompt, proportion=1,
                         flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=3)
         
@@ -569,7 +553,7 @@
         iFound = 0
         for module, data in self.cmd_prompt.moduleDesc.iteritems():
             found = False
-            if self.searchBy.GetSelection() == 0: # -> description
+            if self.search.GetSelection() == 'description': # -> description
                 if text in data['desc']:
                     found = True
             else: # -> keywords

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/help.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/help.py	2010-05-04 09:02:19 UTC (rev 42103)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/help.py	2010-05-04 09:05:27 UTC (rev 42104)
@@ -5,6 +5,7 @@
 
 Classes:
  - HelpWindow
+ - FindModuleWindow
  - MenuTreeWindow
  - AboutWindow
 
@@ -56,24 +57,16 @@
         #        sizer.SetSizeHints(self)
         self.Layout()
 
-class MenuTreeWindow(wx.Panel):
-    """!Show menu tree"""
+class SearchModuleWindow(wx.Panel):
+    """!Search module window (used in MenuTreeWindow)"""
     def __init__(self, parent, id = wx.ID_ANY, **kwargs):
-        self.parent = parent # LayerManager
-        
         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)"))        
-        # tree
-        self.tree = MenuTree(parent = self, data = menudata.ManagerData())
-        self.tree.Load()
+        self._searchDict = { _('label')    : 'label', # i18n workaround
+                             _('help')     : 'help',
+                             _('command')  : 'command',
+                             _('keywords') : 'keywords' }
         
-        self.searchDict = { _('label')    : 'label', # i18n workaround
-                            _('help')     : 'help',
-                            _('command')  : 'command',
-                            _('keywords') : 'keywords' }
-        # search
         self.searchBy = wx.Choice(parent = self, id = wx.ID_ANY,
                                   choices = [_('label'),
                                              _('help'),
@@ -85,6 +78,49 @@
                                   value = "", size = (-1, 25),
                                   style = wx.TE_PROCESS_ENTER)
         
+        self._layout()
+
+    def _layout(self):
+        """!Do layout"""
+                # search
+        sizer = wx.BoxSizer(wx.HORIZONTAL)
+        sizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
+                                       label = _("Find module by:")),
+                  proportion = 0,
+                  flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
+                  border = 3)
+        sizer.Add(item = self.searchBy, proportion = 0,
+                  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT,
+                  border = 5)
+        sizer.Add(item = self.search, proportion = 1,
+                  flag = wx.EXPAND | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL,
+                  border = 5)
+        
+        self.SetSizer(sizer)
+        sizer.Fit(self)
+
+    def GetSelection(self):
+        """!Get selected element"""
+        selection = self.searchBy.GetStringSelection()
+        
+        return self._searchDict[selection]
+    
+class MenuTreeWindow(wx.Panel):
+    """!Show menu tree"""
+    def __init__(self, parent, id = wx.ID_ANY, **kwargs):
+        self.parent = parent # LayerManager
+        
+        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)"))
+        # tree
+        self.tree = MenuTree(parent = self, data = menudata.ManagerData())
+        self.tree.Load()
+
+        # search widget
+        self.search = SearchModuleWindow(parent = self)
+        
         # buttons
         self.btnRun   = wx.Button(self, id = wx.ID_OK, label = _("Run"))
         self.btnRun.SetToolTipString(_("Run selected command"))
@@ -92,10 +128,10 @@
         
         # 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.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated)
-        self.tree.Bind(wx.EVT_TREE_SEL_CHANGED,    self.OnItemSelected)
         
         self._layout()
         
@@ -110,20 +146,6 @@
         dataSizer.Add(item = self.tree, proportion =1,
                       flag = wx.EXPAND)
         
-        # search
-        searchSizer = wx.BoxSizer(wx.HORIZONTAL)
-        searchSizer.Add(item = wx.StaticText(parent = self, id = wx.ID_ANY,
-                                             label = _("Search:")),
-                        proportion = 0,
-                        flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
-                        border = 3)
-        searchSizer.Add(item = self.searchBy, proportion = 0,
-                        flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT,
-                        border = 5)
-        searchSizer.Add(item = self.search, proportion = 1,
-                        flag = wx.EXPAND | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL,
-                        border = 5)
-        
         # buttons
         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
         btnSizer.Add(item = self.btnRun, proportion = 0,
@@ -132,7 +154,7 @@
         sizer.Add(item = dataSizer, proportion = 1,
                   flag = wx.EXPAND | wx.ALL, border = 5)
 
-        sizer.Add(item = searchSizer, proportion=0,
+        sizer.Add(item = self.search, proportion=0,
                   flag = wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 5)
         
         sizer.Add(item = btnSizer, proportion=0,
@@ -233,7 +255,7 @@
 
     def OnUpdateStatusBar(self, event):
         """!Update statusbar text"""
-        element = self.searchDict[self.searchBy.GetStringSelection()]
+        element = self.search.GetSelection()
         self.tree.itemsMarked = self.SearchItems(element = element,
                                                  value = event.GetString())
         self.tree.itemSelected = None



More information about the grass-commit mailing list