Переглянути джерело

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,
                                             value = "",
                                             style = wx.TE_LINEWRAP | wx.TE_PROCESS_ENTER,
-                                            size = (-1, winHeight))
+                                            size = (-1, winHeight),
+                                            statusbar = self.parent.statusbar)
         except NotImplementedError:
             # wx.PopupWindow may be not available in wxMac
             # see http://trac.wxwidgets.org/ticket/9377
@@ -218,13 +219,16 @@ class PromptListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         
 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
         list of choices.  You can also change the choice list at any time
         by calling setChoices.
         
         Inspired by http://wiki.wxpython.org/TextCtrlAutoComplete
         """
+        self.statusbar = statusbar
+        
         if kwargs.has_key('style'):
             kwargs['style'] = wx.TE_PROCESS_ENTER | kwargs['style']
         else:
@@ -482,13 +486,22 @@ class TextCtrlAutoComplete(wx.TextCtrl, listmix.ColumnSorterMixin):
             self.dropdownlistbox.Select(self.dropdownlistbox.GetFirstSelected(), False)
             if self._hideOnNoMatch:
                 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()
         
         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.__createNoteBook()
         self.menubar, self.menudata = self.__createMenuBar()
+        self.statusbar = self.CreateStatusBar(number=1)
         self.cmdprompt, self.cmdinput = self.__createCommandPrompt()
         self.toolbar   = self.__createToolBar()
-        self.statusbar = self.CreateStatusBar(number=1)
-
+        
         # bindings
         self.Bind(wx.EVT_CLOSE,     self.OnCloseWindow)
         self.Bind(wx.EVT_LEFT_DOWN, self.AddRaster, self.notebook)