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

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

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

revision 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 235 by bh, Tue Jul 23 10:56:29 2002 UTC
# Line 1  Line 1 
1  # Copyright (C) 2001 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]>
5  #  #
6  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
7  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
# Line 11  Thuban's application object. Line 12  Thuban's application object.
12    
13  __version__ = "$Revision$"  __version__ = "$Revision$"
14    
15    import sys, os
16    import traceback
17    
18  from wxPython.wx import *  from wxPython.wx import *
19    
20  from Thuban.Lib.connector import Publisher  from Thuban.Lib.connector import Publisher
# Line 22  from Thuban.Model.load import load_sessi Line 26  from Thuban.Model.load import load_sessi
26  import view  import view
27  import tree  import tree
28  from interactor import Interactor  from interactor import Interactor
29  from mainwindow import MainWindow  import mainwindow
30    
31  from messages import SESSION_CHANGED  from messages import SESSION_CHANGED
32    
# Line 39  class ThubanApplication(wxApp, Publisher Line 43  class ThubanApplication(wxApp, Publisher
43      """      """
44    
45      def OnInit(self):      def OnInit(self):
46          # ugly hack to set the global app object before window-classes          self.read_startup_files()
         # are instantiated  
         import main  
         main.app = self  
47          self.interactor = Interactor(None)          self.interactor = Interactor(None)
48          top = MainWindow(NULL, -1)          top = self.CreateMainWindow()
49          top.Show(true)          top.Show(true)
50          self.top = top          self.top = top
51          self.SetTopWindow(top)          self.SetTopWindow(top)
52          self.session = None          self.session = None
53          self.create_session()          self.create_session()
   
         f = wxFrame(top, -1, 'test', wxDefaultPosition, wxSize(300, 300))  
         self.tree = tree.myTreeCtrlPanel(f, self)  
         f.Show(true)  
54          return true          return true
55    
56        def read_startup_files(self):
57            """Read the startup files."""
58            # for now the startup file is ~/.thuban/thubanstart.py
59            dir =os.path.expanduser("~/.thuban")
60            if os.path.isdir(dir):
61                sys.path.append(dir)
62                try:
63                    import thubanstart
64                except ImportError:
65                    tb = sys.exc_info()[2]
66                    try:
67                        if tb.tb_next is not None:
68                            # The ImportError exception was raised from
69                            # inside the thubanstart module.
70                            sys.stderr.write("Cannot import the thubanstart"
71                                             "module\n")
72                            traceback.print_exc(None, sys.stderr)
73                        else:
74                            # There's no thubanstart module.
75                            sys.stderr.write("No thubanstart module available\n")
76                    finally:
77                        # make sure we delete the traceback object,
78                        # otherwise there's be circular references involving
79                        # the current stack frame
80                        del tb
81                except:
82                    sys.stderr.write("Cannot import the thubanstart module\n")
83                    traceback.print_exc(None, sys.stderr)
84            else:
85                # There's no .thuban directory
86                sys.stderr.write("No ~/.thuban directory\n")
87    
88        def CreateMainWindow(self):
89            """Create and return the main window for the application.
90    
91            Override this in subclasses to instantiate the Thuban mainwindow
92            with different parameters or to use a different class for the
93            main window.
94    
95            when this method is called by OnInit self.interactor (to be used
96            for the interactor argument of the standard Thuban main window
97            class) has already been instantiated.
98            """
99            msg = ("This is the wxPython-based Graphical User Interface"
100                   " for exploring geographic data")
101            return mainwindow.MainWindow(NULL, -1, "Thuban", self, self.interactor,
102                                         initial_message = msg)
103    
104        def Session(self):
105            """Return the application's session object"""
106            return self.session
107    
108      def SetSession(self, session):      def SetSession(self, session):
109            """Make session the new session.
110    
111            Issue SESSION_CHANGED.
112            """
113          oldsession = self.session          oldsession = self.session
114          self.session = session          self.session = session
115          self.issue(SESSION_CHANGED)          self.issue(SESSION_CHANGED)

Legend:
Removed from v.6  
changed lines
  Added in v.235

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26