[GRASS-SVN] r52686 - grass/trunk/gui/wxpython/swipe

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 17 00:01:09 PDT 2012


Author: annakrat
Date: 2012-08-17 00:01:08 -0700 (Fri, 17 Aug 2012)
New Revision: 52686

Modified:
   grass/trunk/gui/wxpython/swipe/frame.py
Log:
wxGUI/swipe: check if raster exists

Modified: grass/trunk/gui/wxpython/swipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/swipe/frame.py	2012-08-17 04:39:28 UTC (rev 52685)
+++ grass/trunk/gui/wxpython/swipe/frame.py	2012-08-17 07:01:08 UTC (rev 52686)
@@ -9,7 +9,7 @@
 from core.render        import Map
 from mapdisp            import statusbar as sb
 from core.debug         import Debug
-from core.gcmd          import RunCommand
+from core.gcmd          import RunCommand, GError
 from mapdisp.statusbar  import EVT_AUTO_RENDER
 
 from swipe.toolbars  import SwipeMapToolbar, SwipeMainToolbar, SwipeMiscToolbar
@@ -280,9 +280,18 @@
         dlg = SwipeMapDialog(self, first = self.rasters['first'], second = self.rasters['second'])
         if dlg.ShowModal() == wx.ID_OK:
             maps = dlg.GetValues()
-            self.SetFirstRaster(name = maps[0])
-            self.SetSecondRaster(name = maps[1])
+            res1 = self.SetFirstRaster(name = maps[0])
+            res2 = self.SetSecondRaster(name = maps[1])
 
+            if not (res1 and res2):
+                message = ''
+                if not res1:
+                    message += _("Map <%s> not found. ") % maps[0]
+                if not res2:
+                    message += _("Map <%s> not found.") % maps[1]
+                GError(parent = self, message = message)
+                dlg.Destroy()
+
         dlg.Destroy()
         self.OnRender(event = None)
 
@@ -293,7 +302,10 @@
             self.rasters['first'] = raster['fullname']
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetFirstMap())
             self.OnZoomToMap(event = None)
+            return True
 
+        return False
+
     def SetSecondRaster(self, name):
         """!Set raster map to second Map"""
         raster = grass.find_file(name = name, element = 'cell')
@@ -301,7 +313,10 @@
             self.rasters['second'] = raster['fullname']
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetSecondMap())
             self.OnZoomToMap(event = None)
+            return True
 
+        return False
+
     def SetLayer(self, name, mapInstance):
         """!Sets layer in Map.
         



More information about the grass-commit mailing list