[GRASS-SVN] r54024 - in grass/trunk/gui/wxpython: core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 25 02:44:05 PST 2012


Author: wenzeslaus
Date: 2012-11-25 02:44:05 -0800 (Sun, 25 Nov 2012)
New Revision: 54024

Modified:
   grass/trunk/gui/wxpython/core/events.py
   grass/trunk/gui/wxpython/core/gconsole.py
   grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI/GConsole: fixing usage of command event and fixing d commands without parameters (in Layer Manager)

Modified: grass/trunk/gui/wxpython/core/events.py
===================================================================
--- grass/trunk/gui/wxpython/core/events.py	2012-11-25 10:31:19 UTC (rev 54023)
+++ grass/trunk/gui/wxpython/core/events.py	2012-11-25 10:44:05 UTC (rev 54024)
@@ -5,12 +5,20 @@
 
 Put here only truly general events. Once you find that your event can be
 generated in more than one class, put your event here. Otherwise,
-leave it in your class file.
+leave it in your class file. Events are expected to be grass/gis related.
 
 General notice:
-Command events are propagated to parent windows. However they do not propagate 
+Command events are propagated to parent windows. However, they do not propagate 
 beyond dialogs. Events do not propagate at all.
+Command events works only with windows, not EvtHandlers, so for other objects
+than windows you need to have extra parameter - guiparent - which can be used
+for creating command events.
+\code
+mapEvent = gMapCreated(self._guiparent.GetId(), ...)
+wx.PostEvent(self._guiparent, mapEvent)
+\endcode
 
+ at todo naming conventions for events
 
 (C) 2012 by the GRASS Development Team
 

Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2012-11-25 10:31:19 UTC (rev 54023)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2012-11-25 10:44:05 UTC (rev 54024)
@@ -641,9 +641,9 @@
                 name = p.get('value')
                 if '@' not in name:
                     name = name + '@' + grass.gisenv()['MAPSET']
-                mapEvent = gMapCreated(wx.ID_ANY,
+                mapEvent = gMapCreated(self._guiparent.GetId(),
                                        name=name, ltype=prompt, add=None)
-                wx.PostEvent(self, mapEvent)
+                wx.PostEvent(self._guiparent, mapEvent)
 
         event.Skip()
 

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-25 10:31:19 UTC (rev 54023)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-25 10:44:05 UTC (rev 54024)
@@ -40,7 +40,7 @@
 sys.path.append(os.path.join(globalvar.ETCDIR, "python"))
 from grass.script          import core as grass
 
-from core.gcmd             import RunCommand, GError, GMessage
+from core.gcmd             import RunCommand, GError, GMessage, GException
 from core.settings         import UserSettings, GetDisplayVectSettings
 from core.utils            import SetAddOnPath, GetLayerNameFromCmd
 from core.events           import EVT_SHOW_NOTIFICATION, EVT_MAP_CREATED
@@ -566,6 +566,9 @@
             self.RunDisplayCmd(command)
         elif re.compile('r[3]?\.mapcalc').search(command[0]):
             self.OnMapCalculator(event = None, cmd = command)
+        else:
+            raise ValueError('Layer Manger special command (%s)'
+                             ' not supported.' % ' '.join(command))
 
     def RunDisplayCmd(self, command):
         """!Handles display commands.
@@ -610,10 +613,9 @@
             # add layer into layer tree
             lname, found = GetLayerNameFromCmd(command, fullyQualified = True,
                                                layerType = layertype)
-            if found:
-                self.GetLayerTree().AddLayer(ltype = layertype,
-                                             lname = lname,
-                                             lcmd = command)
+            self.GetLayerTree().AddLayer(ltype = layertype,
+                                         lname = lname,
+                                         lcmd = command)
 
     def GetLayerNotebook(self):
         """!Get Layers Notebook"""
@@ -1667,6 +1669,7 @@
                                        lgroup = None)
 
     def OnMapCreated(self, event):
+        """!Decides wheter the map should be added to layer tree."""
         if event.add is None:
             if UserSettings.Get(group = 'cmd',
                                 key = 'addNewLayer', subkey = 'enabled'):



More information about the grass-commit mailing list