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

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

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

revision 1579 by bh, Tue Aug 12 12:34:07 2003 UTC revision 1786 by bh, Wed Oct 8 10:39:11 2003 UTC
# Line 13  __version__ = "$Revision$" Line 13  __version__ = "$Revision$"
13  # $Source$  # $Source$
14  # $Id$  # $Id$
15    
16  import os, sys, math  import os
17  from wxPython.wx import *  from wxPython.wx import *
18    
19  from Thuban import _  from Thuban import _
20    
21  from Thuban.Model.proj import Projection, ProjFile  from Thuban.Model.proj import Projection, ProjFile
22    
23  from Thuban.Model.resource import get_user_proj_files, get_system_proj_files, \  from Thuban.Model.resource import get_user_proj_file, get_system_proj_file, \
24                                    read_proj_file, write_proj_file                                    read_proj_file, write_proj_file
25  from Thuban.UI.dialogs import NonModalNonParentDialog  from Thuban.UI.dialogs import NonModalNonParentDialog
26    
# Line 207  class ProjFrame(NonModalNonParentDialog) Line 207  class ProjFrame(NonModalNonParentDialog)
207      def _OnProjAvail(self, event):      def _OnProjAvail(self, event):
208          self.__DoOnProjAvail()          self.__DoOnProjAvail()
209    
210        def show_warnings(self, title, filename, warnings):
211            """Show the warnings (a list of strings) in a dialog
212    
213            If the list is empty no dialog will be shown.
214            """
215            if warnings:
216                text = (_('Warnings when reading "%s":\n\n%s')
217                        % (filename, "\n\n".join(warnings)))
218                self.parent.RunMessageBox(title, text)
219    
220      def _OnImport(self, event):      def _OnImport(self, event):
221    
222          dlg = wxFileDialog(self, _("Import"), style = wxOPEN)          dlg = wxFileDialog(self, _("Import"), style = wxOPEN)
# Line 215  class ProjFrame(NonModalNonParentDialog) Line 225  class ProjFrame(NonModalNonParentDialog)
225              path = dlg.GetPath()              path = dlg.GetPath()
226    
227              try:              try:
228                  projFile = read_proj_file(path)                  projFile, warnings = read_proj_file(path)
229                    self.show_warnings(_("Warnings"), path, warnings)
230                  for proj in projFile.GetProjections():                  for proj in projFile.GetProjections():
231                      self.__usrProjFile.Add(proj)                      self.__usrProjFile.Add(proj)
232                  write_proj_file(self.__usrProjFile)                  write_proj_file(self.__usrProjFile)
# Line 500  class ProjFrame(NonModalNonParentDialog) Line 511  class ProjFrame(NonModalNonParentDialog)
511          #          #
512          self.availprojs.Append("<None>", (None, None))          self.availprojs.Append("<None>", (None, None))
513    
514          projfile = get_system_proj_files()          projfile, warnings = get_system_proj_file()
515          projfile = projfile[0]          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)
516          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
517              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.GetName(), [proj, projfile])
518          self.__sysProjFile = projfile          self.__sysProjFile = projfile
519    
520          projfile = get_user_proj_files()          projfile, warnings = get_user_proj_file()
521          projfile = projfile[0]          self.show_warnings(_("Warnings"), projfile.GetFilename(), warnings)
522          for proj in projfile.GetProjections():          for proj in projfile.GetProjections():
523              self.availprojs.Append(proj.GetName(), [proj, projfile])              self.availprojs.Append(proj.GetName(), [proj, projfile])
524          self.__usrProjFile = projfile          self.__usrProjFile = projfile

Legend:
Removed from v.1579  
changed lines
  Added in v.1786

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26