[GRASS-SVN] r51836 - grass/trunk/gui/wxpython/mapdisp

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 27 09:52:33 PDT 2012


Author: annakrat
Date: 2012-05-27 09:52:33 -0700 (Sun, 27 May 2012)
New Revision: 51836

Modified:
   grass/trunk/gui/wxpython/mapdisp/main.py
Log:
wxGUI: dmon supports zoom to extent and warns about missing cmd file (author Vaclav Petras)

Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py	2012-05-27 15:53:55 UTC (rev 51835)
+++ grass/trunk/gui/wxpython/mapdisp/main.py	2012-05-27 16:52:33 UTC (rev 51836)
@@ -222,6 +222,11 @@
         """
         return self._renderCmdFile(force, windres)
 
+class DMonFrame(MapFrame):
+    def OnZoomToMap(self, event):
+        layers = self.MapWindow.GetMap().GetListOfLayers()
+        self.MapWindow.ZoomToMap(layers = layers)
+        
 
 class MapApp(wx.App):
     def OnInit(self):
@@ -233,7 +238,7 @@
         else:
             self.Map = None
 
-        self.mapFrm = MapFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
+        self.mapFrm = DMonFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
                                size = monSize)
         # self.SetTopWindow(Map)
         self.mapFrm.GetMapWindow().SetAlwaysRenderEnabled(True)
@@ -270,12 +275,17 @@
             return
         
         # todo: events
-        if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp:
+        try:
+            currentCmdFileTime = os.path.getmtime(monFile['cmd'])
+            if currentCmdFileTime > self.cmdTimeStamp:
+                self.timer.Stop()
+                self.cmdTimeStamp = currentCmdFileTime
+                self.mapFrm.OnDraw(None)
+                self.mapFrm.GetMap().GetLayersFromCmdFile()
+                self.timer.Start(mtime)
+        except OSError, e:
+            grass.warning("%s" % e)
             self.timer.Stop()
-            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
-            self.mapFrm.OnDraw(None)
-            self.mapFrm.GetMap().GetLayersFromCmdFile()
-            self.timer.Start(mtime)
 
 if __name__ == "__main__":
     # set command variable



More information about the grass-commit mailing list