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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6 - (show annotations)
Tue Aug 28 15:41:52 2001 UTC (23 years, 6 months ago) by bh
Original Path: trunk/thuban/Thuban/UI/application.py
File MIME type: text/x-python
File size: 2276 byte(s)
import all the source files

1 # Copyright (C) 2001 by Intevation GmbH
2 # Authors:
3 # Jan-Oliver Wagner <[email protected]>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with Thuban for details.
7
8 """
9 Thuban's application object.
10 """
11
12 __version__ = "$Revision$"
13
14 from wxPython.wx import *
15
16 from Thuban.Lib.connector import Publisher
17
18 from Thuban.Model.session import create_empty_session
19 from Thuban.Model.save import save_session
20 from Thuban.Model.load import load_session
21
22 import view
23 import tree
24 from interactor import Interactor
25 from mainwindow import MainWindow
26
27 from messages import SESSION_CHANGED
28
29
30
31 class ThubanApplication(wxApp, Publisher):
32
33 """
34 Thuban's application class.
35
36 All wxWindows programs have to have an instance of an application
37 class derived from wxApp. In Thuban the application class holds
38 references to the main window, the session and the interactor.
39 """
40
41 def OnInit(self):
42 # ugly hack to set the global app object before window-classes
43 # are instantiated
44 import main
45 main.app = self
46 self.interactor = Interactor(None)
47 top = MainWindow(NULL, -1)
48 top.Show(true)
49 self.top = top
50 self.SetTopWindow(top)
51 self.session = None
52 self.create_session()
53
54 f = wxFrame(top, -1, 'test', wxDefaultPosition, wxSize(300, 300))
55 self.tree = tree.myTreeCtrlPanel(f, self)
56 f.Show(true)
57 return true
58
59 def SetSession(self, session):
60 oldsession = self.session
61 self.session = session
62 self.issue(SESSION_CHANGED)
63 self.interactor.SetSession(session)
64 self.set_map()
65 if oldsession is not None:
66 oldsession.Destroy()
67
68 def create_session(self):
69 # Create a simple default session
70 self.SetSession(create_empty_session())
71
72 def OpenSession(self, filename):
73 session = load_session(filename)
74 session.SetFilename(filename)
75 session.UnsetModified()
76 self.SetSession(session)
77
78 def SaveSession(self):
79 save_session(self.session, self.session.filename)
80
81 def set_map(self):
82 if self.session.HasMaps():
83 self.top.SetMap(self.session.Maps()[0])
84 else:
85 self.top.SetMap(None)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26