[GRASS-SVN] r48133 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 5 12:27:56 EDT 2011


Author: martinl
Date: 2011-09-05 09:27:56 -0700 (Mon, 05 Sep 2011)
New Revision: 48133

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: fix GetNextId()


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-09-05 14:29:35 UTC (rev 48132)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-09-05 16:27:56 UTC (rev 48133)
@@ -136,10 +136,17 @@
         return len(self.GetItems())
 
     def GetNextId(self):
-        """!Get next id (data ignored)"""
+        """!Get next id (data ignored)
+
+        @return next id to be used (default: 1)
+        """
+        if len(self.items) < 1:
+            return 1
+        
         currId = self.items[-1].GetId()
         if currId > 0:
             return currId + 1
+        
         return 1
 
     def GetProperties(self):
@@ -2383,7 +2390,7 @@
         self.btnOk.SetDefault()
         self.btnOk.Enable(False)
 
-        self.cmd_prompt.Bind(wx.EVT_CHAR, self.OnText)
+        self.cmd_prompt.Bind(wx.EVT_KEY_UP, self.OnText)
         self.search.searchChoice.Bind(wx.EVT_CHOICE, self.OnText)
         self.Bind(wx.EVT_BUTTON, self.OnOk, self.btnOk)
         
@@ -2432,6 +2439,7 @@
         return cmd
     
     def OnOk(self, event):
+        """!Button 'OK' pressed"""
         self.btnOk.SetFocus()
         cmd = self.GetCmd()
         
@@ -2450,13 +2458,15 @@
         self.EndModal(wx.ID_OK)
         
     def OnText(self, event):
-        """!Text entered"""
+        """!Text in prompt changed"""
         if self.cmd_prompt.AutoCompActive():
             event.Skip()
             return
         
         if isinstance(event, wx.KeyEvent):
-            entry = self.cmd_prompt.GetTextLeft() # FIXME
+            entry = self.cmd_prompt.GetTextLeft()
+        elif isinstance(event, wx.stc.StyledTextEvent):
+            entry = event.GetText()
         else:
             entry = event.GetString()
         



More information about the grass-commit mailing list