浏览代码

wxGUI: fix interactive prompting (option not found)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37791 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 16 年之前
父节点
当前提交
8fc76b2442
共有 2 个文件被更改,包括 24 次插入11 次删除
  1. 22 9
      gui/wxpython/gui_modules/prompt.py
  2. 2 2
      gui/wxpython/wxgui.py

+ 22 - 9
gui/wxpython/gui_modules/prompt.py

@@ -70,7 +70,8 @@ class GPrompt:
             cmdinput = TextCtrlAutoComplete(parent = cmdprompt, id = wx.ID_ANY,
             cmdinput = TextCtrlAutoComplete(parent = cmdprompt, id = wx.ID_ANY,
                                             value = "",
                                             value = "",
                                             style = wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER,
                                             style = wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER,
-                                            size = (-1, winHeight))
+                                            size = (-1, winHeight),
+                                            statusbar = self.parent.statusbar)
         except NotImplementedError:
         except NotImplementedError:
             # wx.PopupWindow may be not available in wxMac
             # wx.PopupWindow may be not available in wxMac
             # see http://trac.wxwidgets.org/ticket/9377
             # see http://trac.wxwidgets.org/ticket/9377
@@ -218,13 +219,16 @@ class PromptListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         
         
 class TextCtrlAutoComplete(wx.TextCtrl, listmix.ColumnSorterMixin):
 class TextCtrlAutoComplete(wx.TextCtrl, listmix.ColumnSorterMixin):
-    def __init__ (self, parent, id = wx.ID_ANY, choices = [], **kwargs):
+    def __init__ (self, parent, statusbar, 
+                  id = wx.ID_ANY, choices = [], **kwargs):
         """!Constructor works just like wx.TextCtrl except you can pass in a
         """!Constructor works just like wx.TextCtrl except you can pass in a
         list of choices.  You can also change the choice list at any time
         list of choices.  You can also change the choice list at any time
         by calling setChoices.
         by calling setChoices.
         
         
         Inspired by http://wiki.wxpython.org/TextCtrlAutoComplete
         Inspired by http://wiki.wxpython.org/TextCtrlAutoComplete
         """
         """
+        self.statusbar = statusbar
+        
         if kwargs.has_key('style'):
         if kwargs.has_key('style'):
             kwargs['style'] = wx.TE_PROCESS_ENTER | kwargs['style']
             kwargs['style'] = wx.TE_PROCESS_ENTER | kwargs['style']
         else:
         else:
@@ -482,13 +486,22 @@ class TextCtrlAutoComplete(wx.TextCtrl, listmix.ColumnSorterMixin):
             self.dropdownlistbox.Select(self.dropdownlistbox.GetFirstSelected(), False)
             self.dropdownlistbox.Select(self.dropdownlistbox.GetFirstSelected(), False)
             if self._hideOnNoMatch:
             if self._hideOnNoMatch:
                 self._showDropDown(False)
                 self._showDropDown(False)
-            
-            if self._module and cmd[-1][-2] == '=':
-                optType = self._module.get_param(cmd[-1][:-2])['prompt']
-                if optType in ('raster', 'vector'):
-                    # -> raster/vector map
-                    self.SetChoices(self._choicesMap[optType], optType)
-                                            
+                if self._module and '=' not in cmd[-1]:
+                    message = ''
+                    if cmd[-1][0] == '-': # flag
+                        message = "Warning: flag <%s> not found in '%s'" % \
+                            (cmd[-1][1:], self._module.name)
+                    else: # option
+                        message = "Warning: option <%s> not found in '%s'" % \
+                            (cmd[-1], self._module.name)
+                    self.statusbar.SetStatusText(message)
+        
+        if self._module and len(cmd[-1]) == 2 and cmd[-1][-2] == '=':
+            optType = self._module.get_param(cmd[-1][:-2])['prompt']
+            if optType in ('raster', 'vector'):
+                # -> raster/vector map
+                self.SetChoices(self._choicesMap[optType], optType)
+        
         self._listItemVisible()
         self._listItemVisible()
         
         
         event.Skip()
         event.Skip()

+ 2 - 2
gui/wxpython/wxgui.py

@@ -127,10 +127,10 @@ class GMFrame(wx.Frame):
         # -> self.notebook, self.goutput, self.outpage
         # -> self.notebook, self.goutput, self.outpage
         self.notebook  = self.__createNoteBook()
         self.notebook  = self.__createNoteBook()
         self.menubar, self.menudata = self.__createMenuBar()
         self.menubar, self.menudata = self.__createMenuBar()
+        self.statusbar = self.CreateStatusBar(number=1)
         self.cmdprompt, self.cmdinput = self.__createCommandPrompt()
         self.cmdprompt, self.cmdinput = self.__createCommandPrompt()
         self.toolbar   = self.__createToolBar()
         self.toolbar   = self.__createToolBar()
-        self.statusbar = self.CreateStatusBar(number=1)
-
+        
         # bindings
         # bindings
         self.Bind(wx.EVT_CLOSE,     self.OnCloseWindow)
         self.Bind(wx.EVT_CLOSE,     self.OnCloseWindow)
         self.Bind(wx.EVT_LEFT_DOWN, self.AddRaster, self.notebook)
         self.Bind(wx.EVT_LEFT_DOWN, self.AddRaster, self.notebook)