/[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 25 - (show annotations)
Wed Sep 5 13:36:13 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: 2151 byte(s)
Use the new argument to the MainWindow constructor to get rid of the
ugly hack that made main.app available early just so that the mapcanvas
could access the interactor object.

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 self.interactor = Interactor(None)
43 top = MainWindow(NULL, -1, self.interactor)
44 top.Show(true)
45 self.top = top
46 self.SetTopWindow(top)
47 self.session = None
48 self.create_session()
49
50 f = wxFrame(top, -1, 'test', wxDefaultPosition, wxSize(300, 300))
51 self.tree = tree.myTreeCtrlPanel(f, self)
52 f.Show(true)
53 return true
54
55 def SetSession(self, session):
56 oldsession = self.session
57 self.session = session
58 self.issue(SESSION_CHANGED)
59 self.interactor.SetSession(session)
60 self.set_map()
61 if oldsession is not None:
62 oldsession.Destroy()
63
64 def create_session(self):
65 # Create a simple default session
66 self.SetSession(create_empty_session())
67
68 def OpenSession(self, filename):
69 session = load_session(filename)
70 session.SetFilename(filename)
71 session.UnsetModified()
72 self.SetSession(session)
73
74 def SaveSession(self):
75 save_session(self.session, self.session.filename)
76
77 def set_map(self):
78 if self.session.HasMaps():
79 self.top.SetMap(self.session.Maps()[0])
80 else:
81 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