/[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 951 by frank, Wed May 21 14:20:32 2003 UTC revision 963 by jonathan, Wed May 21 17:23:53 2003 UTC
# Line 459  class MainWindow(DockFrame): Line 459  class MainWindow(DockFrame):
459          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
460              filename = dlg.GetPath()              filename = dlg.GetPath()
461              title = os.path.splitext(os.path.basename(filename))[0]              title = os.path.splitext(os.path.basename(filename))[0]
             store = self.application.Session().OpenShapefile(filename)  
             layer = Layer(title, store)  
462              map = self.canvas.Map()              map = self.canvas.Map()
463              has_layers = map.HasLayers()              has_layers = map.HasLayers()
464              try:              try:
465                  map.AddLayer(layer)                  store = self.application.Session().OpenShapefile(filename)
466              except IOError:              except IOError:
467                  # the layer couldn't be opened                  # the layer couldn't be opened
468                  self.RunMessageBox(_("Add Layer"),                  self.RunMessageBox(_("Add Layer"),
469                                     _("Can't open the file '%s'.") % filename)                                     _("Can't open the file '%s'.") % filename)
470              else:              else:
471                    layer = Layer(title, store)
472                    map.AddLayer(layer)
473                  if not has_layers:                  if not has_layers:
474                      # if we're adding a layer to an empty map, fit the                      # if we're adding a layer to an empty map, fit the
475                      # new map to the window                      # new map to the window
# Line 482  class MainWindow(DockFrame): Line 482  class MainWindow(DockFrame):
482          if dlg.ShowModal() == wxID_OK:          if dlg.ShowModal() == wxID_OK:
483              filename = dlg.GetPath()              filename = dlg.GetPath()
484              title = os.path.splitext(os.path.basename(filename))[0]              title = os.path.splitext(os.path.basename(filename))[0]
             layer = RasterLayer(title, filename)  
485              map = self.canvas.Map()              map = self.canvas.Map()
486              has_layers = map.HasLayers()              has_layers = map.HasLayers()
487              try:              try:
488                  map.AddLayer(layer)                  layer = RasterLayer(title, filename)
489              except IOError:              except IOError:
490                  # the layer couldn't be opened                  # the layer couldn't be opened
491                  self.RunMessageBox(_("Add Image Layer"),                  self.RunMessageBox(_("Add Image Layer"),
492                                     _("Can't open the file '%s'.") % filename)                                     _("Can't open the file '%s'.") % filename)
493              else:              else:
494                    map.AddLayer(layer)
495                  if not has_layers:                  if not has_layers:
496                      # if we're adding a layer to an empty map, fit the                      # if we're adding a layer to an empty map, fit the
497                      # new map to the window                      # new map to the window

Legend:
Removed from v.951  
changed lines
  Added in v.963

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26