[Thuban-commits] r2771 - in trunk/thuban: . Thuban/UI

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue May 22 15:47:50 CEST 2007


Author: bernhard
Date: 2007-05-22 15:47:49 +0200 (Tue, 22 May 2007)
New Revision: 2771

Modified:
   trunk/thuban/ChangeLog
   trunk/thuban/Thuban/UI/mainwindow.py
Log:
* Thuban/UI/mainwindow.py: using a loop for several raster filenames.
Thanks to Jachym Cepicky and Bernhard Herzog. Closes [#403] "can not
add raster layer". And adds the ability to open more then one raster
file from one open dialog by multiple selection.


Modified: trunk/thuban/ChangeLog
===================================================================
--- trunk/thuban/ChangeLog	2007-05-22 08:54:41 UTC (rev 2770)
+++ trunk/thuban/ChangeLog	2007-05-22 13:47:49 UTC (rev 2771)
@@ -1,3 +1,10 @@
+2007-05022  Bernhard Reiter <bernhard at intevation.de>
+
+	* Thuban/UI/mainwindow.py: using a loop for several raster filenames.
+	Thanks to Jachym Cepicky and Bernhard Herzog. Closes [#403] "can not
+	add raster layer". And adds the ability to open more then one raster
+	file from one open dialog by multiple selection.
+
 2007-05-22  Bernhard Herzog  <bh at intevation.de>
 
 	* Extensions/ogr/ogrshapes.py: Move the __future__ import to the

Modified: trunk/thuban/Thuban/UI/mainwindow.py
===================================================================
--- trunk/thuban/Thuban/UI/mainwindow.py	2007-05-22 08:54:41 UTC (rev 2770)
+++ trunk/thuban/Thuban/UI/mainwindow.py	2007-05-22 13:47:49 UTC (rev 2771)
@@ -589,25 +589,26 @@
     def AddRasterLayer(self):
         dlg = wx.FileDialog(self, _("Select an image file"),
                            self.application.Path("data"), "", "*.*",
-                           wx.OPEN)
+                           wx.OPEN | wx.MULTIPLE)
         if dlg.ShowModal() == wx.ID_OK:
             filenames = map(internal_from_wxstring, dlg.GetPaths())
-            title = os.path.splitext(os.path.basename(filename))[0]
-            mymap = self.canvas.Map()
-            has_layers = mymap.HasLayers()
-            try:
-                layer = RasterLayer(title, filename)
-            except IOError:
-                # the layer couldn't be opened
-                self.RunMessageBox(_("Add Image Layer"),
-                                   _("Can't open the file '%s'.") % filename)
-            else:
-                mymap.AddLayer(layer)
-                if not has_layers:
-                    # if we're adding a layer to an empty map, fit the
-                    # new map to the window
-                    self.canvas.FitMapToWindow()
-                self.application.SetPath("data", filename)
+            for filename in filenames:
+                title = os.path.splitext(os.path.basename(filename))[0]
+                mymap = self.canvas.Map()
+                has_layers = mymap.HasLayers()
+                try:
+                    layer = RasterLayer(title, filename)
+                except IOError:
+                    # the layer couldn't be opened
+                    self.RunMessageBox(_("Add Image Layer"),
+                                    _("Can't open the file '%s'.") % filename)
+                else:
+                    mymap.AddLayer(layer)
+                    if not has_layers:
+                        # if we're adding a layer to an empty map, fit the
+                        # new map to the window
+                        self.canvas.FitMapToWindow()
+                    self.application.SetPath("data", filename)
         dlg.Destroy()
 
     def AddDBLayer(self):



More information about the Thuban-commits mailing list