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]> |
7 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
8 |
|
|
9 |
""" |
""" |
10 |
The main entry point for the Thuban GUI. |
The main entry point for the Thuban GUI. |
11 |
""" |
""" |
12 |
|
|
13 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
14 |
|
|
15 |
import sys |
import sys |
16 |
|
import getopt |
17 |
|
|
18 |
from application import ThubanApplication |
import application |
19 |
|
import Thuban.version |
20 |
|
|
21 |
from wxPython.wx import wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER,\ |
|
22 |
wxPlatform |
class options: |
23 |
import wxproj |
|
24 |
|
attribute_editing_enabled = False |
25 |
|
|
26 |
|
|
27 |
def main(): |
def main(): |
28 |
"""Instantiate the application object and run the application""" |
"""Instantiate the application object and run the application""" |
29 |
|
|
30 |
if verify_versions(): |
if verify_versions(): |
31 |
app = ThubanApplication(0) |
app = application.ThubanApplication(0) |
32 |
if len(sys.argv) > 1: |
opts, args = getopt.getopt(sys.argv[1:], '', |
33 |
app.OpenSession(sys.argv[1]) |
['enable-attribute-editing']) |
34 |
app.MainLoop() |
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 |
|
|
|
def wxCHECK_VERSION(major,minor,release): \ |
|
|
return (wxMAJOR_VERSION > (major) or \ |
|
|
(wxMAJOR_VERSION == (major) \ |
|
|
and wxMINOR_VERSION > (minor)) or \ |
|
|
(wxMAJOR_VERSION == (major) \ |
|
|
and wxMINOR_VERSION == (minor) \ |
|
|
and wxRELEASE_NUMBER >= (release))) |
|
49 |
|
|
50 |
def verify_versions(): |
def verify_versions(): |
51 |
"""Check some library versions. |
"""Check some library versions. |
52 |
|
|
53 |
Print a message containing any libraries which are wrong. |
Print a message containing any libraries which are wrong. |
54 |
Return True if everything is OK, otherwise False. |
Return True if everything is OK, otherwise False. |
|
|
|
|
Specifically, check the following libraries: |
|
|
|
|
|
wxPython >= v2.4.0 |
|
|
Python >= v2.2.1 |
|
|
proj >= v4.4.5 |
|
|
gtk > v1.2.0 |
|
55 |
""" |
""" |
|
|
|
|
errors = [] |
|
|
|
|
|
if not wxCHECK_VERSION(2, 4, 0): |
|
|
errors.append("wxPython < 2.4.0") |
|
|
|
|
|
if sys.hexversion < 0x0202010f: |
|
|
errors.append("Python < 2.2.1") |
|
56 |
|
|
57 |
# |
errors = Thuban.version.verify_versions() |
|
# This only tells someone that they COMPILED thuban with the wrong |
|
|
# version of proj. If they are running prebuilt binaries |
|
|
# check_version should always return true. |
|
|
# |
|
|
if not wxproj.check_version(4, 4, 5): |
|
|
errors.append("proj < 4.4.5") |
|
|
|
|
|
if wxPlatform == "__WXGTK__": |
|
|
if not wxproj.check_version_gtk(1, 2, 0): |
|
|
errors.append("gtk < 1.2") |
|
58 |
|
|
59 |
if len(errors) > 0: |
if len(errors) > 0: |
60 |
msg = " The following version errors were detected:" |
msg = " The following version errors were detected:" |