/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/mainwindow.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1620 by bh, Wed Aug 20 13:14:22 2003 UTC revision 1622 by jan, Thu Aug 21 11:56:06 2003 UTC
# Line 456  class MainWindow(DockFrame): Line 456  class MainWindow(DockFrame):
456          dialog.Raise()          dialog.Raise()
457    
458      def AddLayer(self):      def AddLayer(self):
459          dlg = wxFileDialog(self, _("Select a data file"), ".", "", "*.*",          dlg = wxFileDialog(self, _("Select one or more data files"), ".", "",
460                             wxOPEN)                             _("Shapefiles (*.shp)") + "|*.shp|" +
461                               _("All Files (*.*)") + "|*.*",
462                               wxOPEN | wxMULTIPLE)
463          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
464              filename = dlg.GetPath()              filenames = dlg.GetPaths()
465              title = os.path.splitext(os.path.basename(filename))[0]              for filename in filenames:
466              map = self.canvas.Map()                  title = os.path.splitext(os.path.basename(filename))[0]
467              has_layers = map.HasLayers()                  map = self.canvas.Map()
468              try:                  has_layers = map.HasLayers()
469                  store = self.application.Session().OpenShapefile(filename)                  try:
470              except IOError:                      store = self.application.Session().OpenShapefile(filename)
471                  # the layer couldn't be opened                  except IOError:
472                  self.RunMessageBox(_("Add Layer"),                      # the layer couldn't be opened
473                                     _("Can't open the file '%s'.") % filename)                      self.RunMessageBox(_("Add Layer"),
474              else:                                         _("Can't open the file '%s'.")%filename)
475                  layer = Layer(title, store)                  else:
476                  map.AddLayer(layer)                      layer = Layer(title, store)
477                  if not has_layers:                      map.AddLayer(layer)
478                      # if we're adding a layer to an empty map, fit the                      if not has_layers:
479                      # new map to the window                          # if we're adding a layer to an empty map, fit the
480                      self.canvas.FitMapToWindow()                          # new map to the window
481                            self.canvas.FitMapToWindow()
482          dlg.Destroy()          dlg.Destroy()
483    
484      def AddRasterLayer(self):      def AddRasterLayer(self):

Legend:
Removed from v.1620  
changed lines
  Added in v.1622

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26