[GRASS-SVN] r55379 - in grass/trunk/gui/wxpython: mapdisp mapswipe

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 14 09:03:45 PDT 2013


Author: annakrat
Date: 2013-03-14 09:03:44 -0700 (Thu, 14 Mar 2013)
New Revision: 55379

Modified:
   grass/trunk/gui/wxpython/mapdisp/frame.py
   grass/trunk/gui/wxpython/mapdisp/mapwindow.py
   grass/trunk/gui/wxpython/mapdisp/statusbar.py
   grass/trunk/gui/wxpython/mapswipe/frame.py
Log:
wxGUI: change event by signal (EVT_AUTO_RENDER)

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2013-03-14 15:07:50 UTC (rev 55378)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2013-03-14 16:03:44 UTC (rev 55379)
@@ -126,7 +126,10 @@
         # fill statusbar manager
         self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
         self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
-        self.statusbarManager.AddStatusbarItem(sb.SbRender(self, statusbar = statusbar, position = 3))
+        sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
+        sbRender.autoRender.connect(lambda state: self.OnRender(None) if state else None)
+
+        self.statusbarManager.AddStatusbarItem(sbRender)
         
         self.statusbarManager.Update()
 
@@ -143,6 +146,7 @@
         self.MapWindow2D = BufferedWindow(self, giface = self._giface, id = wx.ID_ANY,
                                           Map = self.Map, frame = self, tree = self.tree,
                                           lmgr = self._layerManager, overlays = self.decorations)
+        self._giface.updateMap.connect(self.MapWindow2D.UpdateMap)
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
         self.MapWindow.SetCursor(self.cursors["default"])

Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2013-03-14 15:07:50 UTC (rev 55378)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2013-03-14 16:03:44 UTC (rev 55379)
@@ -83,8 +83,6 @@
         # Emitted when zoom of a window is changed
         self.zoomChanged = Signal('BufferedWindow.zoomChanged')
 
-        self._giface.updateMap.connect(self.UpdateMap)
-
         # event bindings
         self.Bind(wx.EVT_PAINT,           self.OnPaint)
         self.Bind(wx.EVT_SIZE,            self.OnSize)

Modified: grass/trunk/gui/wxpython/mapdisp/statusbar.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/statusbar.py	2013-03-14 15:07:50 UTC (rev 55378)
+++ grass/trunk/gui/wxpython/mapdisp/statusbar.py	2013-03-14 16:03:44 UTC (rev 55379)
@@ -44,7 +44,7 @@
 
 from grass.script  import core as grass
 
-wxAutoRender, EVT_AUTO_RENDER = NewEvent()
+from grass.pydispatch.signal import Signal
 
 class SbException:
     """! Exception class used in SbManager and SbItems"""
@@ -374,16 +374,10 @@
                                               subkey = 'enabled'))
         self.widget.Hide()
         self.widget.SetToolTip(wx.ToolTip (_("Enable/disable auto-rendering")))
-                                            
-        self.widget.Bind(wx.EVT_CHECKBOX, self.OnToggleRender)
-        
-    def OnToggleRender(self, event):
-        # (other items should call self.mapFrame.IsAutoRendered())
-        event = wxAutoRender(state = self.GetValue())
-        wx.PostEvent(self.mapFrame, event)
-        
-        if self.GetValue():
-            self.mapFrame.OnRender(None)
+                                           
+        self.autoRender = Signal('SbRender.autoRender')
+        self.widget.Bind(wx.EVT_CHECKBOX, lambda evt: 
+                                          self.autoRender.emit(state = self.GetValue()))
 
     def Update(self):
         self.Show()

Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py	2013-03-14 15:07:50 UTC (rev 55378)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py	2013-03-14 16:03:44 UTC (rev 55379)
@@ -26,8 +26,7 @@
 from core.render        import Map
 from mapdisp            import statusbar as sb
 from core.debug         import Debug
-from core.gcmd          import RunCommand, GError, GMessage
-from mapdisp.statusbar  import EVT_AUTO_RENDER
+from core.gcmd          import GError, GMessage
 
 from mapswipe.toolbars  import SwipeMapToolbar, SwipeMainToolbar, SwipeMiscToolbar
 from mapswipe.mapwindow import SwipeBufferedWindow
@@ -82,7 +81,6 @@
         self.InitStatusbar()
 
         self.Bind(wx.EVT_SIZE, self.OnSize)
-        self.Bind(EVT_AUTO_RENDER, self.OnAutoRenderChanged)
         self.Bind(wx.EVT_IDLE, self.OnIdle)
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
 
@@ -160,7 +158,9 @@
         # fill statusbar manager
         self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
         self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
-        self.statusbarManager.AddStatusbarItem(sb.SbRender(self, statusbar = statusbar, position = 3))
+        sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
+        sbRender.autoRender.connect(self.OnAutoRenderChanged)
+        self.statusbarManager.AddStatusbarItem(sbRender)
         
         self.statusbarManager.Update()
 
@@ -233,7 +233,7 @@
             self.ResetSlider()
             self.resize = False
 
-    def OnAutoRenderChanged(self, event):
+    def OnAutoRenderChanged(self, state):
         """!Auto rendering state changed."""
         style = self.splitter.GetWindowStyle()
         style ^= wx.SP_LIVE_UPDATE



More information about the grass-commit mailing list