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

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

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

revision 226 by bh, Thu Jul 18 16:26:11 2002 UTC revision 2689 by dpinte, Thu Aug 3 09:57:24 2006 UTC
# Line 1  Line 1 
1  #! /usr/bin/python  # Copyright (C) 2001, 2002, 2003 by Intevation GmbH
 # Copyright (C) 2001, 2002 by Intevation GmbH  
2  # Authors:  # Authors:
3  # Jan-Oliver Wagner <[email protected]>  # Jan-Oliver Wagner <[email protected]>
4  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
# Line 14  The main entry point for the Thuban GUI. Line 13  The main entry point for the Thuban GUI.
13  __version__ = "$Revision$"  __version__ = "$Revision$"
14    
15  import sys  import sys
16    import getopt
17    
18  # import wxPython.wx here to get the side effects of the wxPython  import application
19  # import, especially setting the locale to the user's defaults throught  import Thuban.version
20  # GTK. We then set the locale again to the user's defaults, but this  
21  # time we're going through the standard python locale module, so all the  
22  # magic necessary to make python work properly is done. Without this,  class options:
23  # something harmless like float("1.2") may fail when run under a non-C  
24  # locale like de_DE      attribute_editing_enabled = False
 import wxPython.wx  
 try:  
     import locale  
     locale.setlocale(locale.LC_ALL, "")  
 except ImportError:  
     # the locale module may not be available on some systems  
     pass  
25    
 from application import ThubanApplication  
26    
27  def main():  def main():
28      """Instantiate the application object and run the application"""      """Instantiate the application object and run the application"""
29      app = ThubanApplication(0)  
30      if len(sys.argv) > 1:      if verify_versions():
31          app.OpenSession(sys.argv[1])          app = application.ThubanApplication(0)
32      app.top.ShowSessionTree()          opts, args = getopt.getopt(sys.argv[1:], '',
33      app.MainLoop()                                     ['enable-attribute-editing'])
34            for optchar, value in opts:
35                if optchar == '--enable-attribute-editing':
36                    options.attribute_editing_enabled = True
37                else:
38                    print >>sys.stderr, "Unknown option", optchar
39    
40            # If there was a non-flag argument it's the name of a thuban
41            # file.
42            if args:
43                app.OpenSession(args[0])
44    
45            app.MainLoop()
46            # sys.excepthook is set in ThubanApplication.OnInit()
47            sys.excepthook = sys.__excepthook__
48    
49    
50    def verify_versions():
51        """Check some library versions.
52    
53        Print a message containing any libraries which are wrong.
54        Return True if everything is OK, otherwise False.
55        """
56        
57        errors = Thuban.version.verify_versions()
58    
59        if len(errors) > 0:
60            msg = " The following version errors were detected:"
61    
62            for e in errors:
63                msg += "\n     " + e
64    
65    #       if use_msg_box:
66    #           # XXX: use a message box to display the errors
67    #           pass
68    
69            print "\n*******************************************************"
70            print msg
71            print "*******************************************************\n"
72    
73            return False
74    
75        return True

Legend:
Removed from v.226  
changed lines
  Added in v.2689

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26