[GRASS-dev] strange behavior of gselect.Select

Luca Delucchi lucadeluge at gmail.com
Wed Dec 30 06:54:46 PST 2015


Hi devs,

working on g.gui.tplot I have problems with gselect.Select in the Vector panel.
Right now there is a wx.EVT_TEXT event and it works well if the vector
temporal dataset is selected by the scroll down menu but it return
errors if the user try to write him self the name of the temporal
dataset, because for each added character it run the connected
function

GRASS_INFO_MESSAGE(13258,1): ERROR: Space time vector dataset <p> not found
GRASS_INFO_END(13258,1)
Traceback (most recent call last):
  File "/home/lucadelu/compilati/grass_trunk/dist.x86_64-unknown-linux-gnu/gui/wxpython/tplot/frame.py",
line 842, in OnVectorSelected
    column='name')
  File "/home/lucadelu/compilati/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",
line 461, in read_command
    return handle_errors(returncode, stdout, args, kwargs)
  File "/home/lucadelu/compilati/grass_trunk/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",
line 329, in handle_errors
    returncode=returncode)
grass.exceptions.CalledModuleError: L'esecuzione del modulo None
['t.vect.list', '-s', 'column=name', 'input=p'] รจ terminata con errori
Processo terminato con codice di return diverso da zero 1. Vedi gli
errori nel (error) output.

So I tried to change the event in wx.EVT_TEXT_ENTER this not working
at all, no error and no call to the function.

Instead if I use wx.EVT_COMBOBOX_CLOSEUP it works when I select the
temporal dataset but no when the user types the name.

My idea is to replace wx.EVT_TEXT with both wx.EVT_TEXT_ENTER and
wx.EVT_COMBOBOX_CLOSEUP as suggested in the attached patch but I would
like why wx.EVT_TEXT_ENTER is not working at all, do you have any
idea?

thanks

-- 
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org
-------------- next part --------------
Index: gui/wxpython/tplot/frame.py
===================================================================
--- gui/wxpython/tplot/frame.py	(revision 67424)
+++ gui/wxpython/tplot/frame.py	(working copy)
@@ -219,7 +219,9 @@
                                              id=wx.ID_ANY,
                                              size=globalvar.DIALOG_GSELECT_SIZE,
                                              type='stvds', multiple=True)
-        self.datasetSelectV.Bind(wx.EVT_TEXT, self.OnVectorSelected)
+        self.datasetSelectV.Bind(wx.EVT_TEXT_ENTER, self.OnVectorSelected)
+        self.datasetSelectV.Bind(wx.EVT_COMBOBOX_CLOSEUP,
+                                 self.OnVectorSelected)
 
         self.attribute = gselect.ColumnSelect(parent=self.controlPanelVector)
         self.attributeLabel = wx.StaticText(parent=self.controlPanelVector,
@@ -838,8 +840,14 @@
     def OnVectorSelected(self, event):
         """Update the controlbox related to stvds"""
         dataset = self.datasetSelectV.GetValue().strip()
-        vect_list = grass.read_command('t.vect.list', flags='s', input=dataset,
-                                       col='name')
+        try:
+            vect_list = grass.read_command('t.vect.list', flags='s',
+                                           input=dataset, column='name')
+        except Exception:
+            self.attribute.Clear()
+            GError(parent=self, message=_("Invalid input temporal dataset"),
+                   showTraceback=False)
+            return
         vect_list = list(set(sorted(vect_list.split())))
         for vec in vect_list:
             self.attribute.InsertColumns(vec, 1)


More information about the grass-dev mailing list