File: wxglade.pyw

package info (click to toggle)
wxglade 1%3A1.1.1%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,592 kB
  • sloc: python: 30,644; javascript: 740; makefile: 169; cpp: 99; perl: 90; lisp: 62; xml: 61; sh: 3
file content (84 lines) | stat: -rw-r--r-- 2,228 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python

"""
Entry point of wxGlade on windows

@copyright: 2002-2004 Alberto Griggio
@copyright: 2015-2016 Carsten Grohmann
@copyright: 2017 Dietmar Schwertberger
@license: MIT (see LICENSE.txt) - THIS PROGRAM COMES WITH NO WARRANTY
"""

import sys, traceback
import gettext
t = gettext.translation(domain="wxglade", localedir="locale", fallback=True)
t.install("wxglade")

import config
import wxglade

msg   = u''  # Message to show in the message box (see {show_error_details())
title = u''  # Title of the message box


def show_error_details():
    "Show a message box; msg and title have to be set before"

    # ctypes has introduced with Python 2.5, but wxGlade is supported with
    # Python 2.4 too. Thereby ctypes will be used if available only.
    try:
        import ctypes
    except ImportError:
        return

    MB_OK = 0x0
    ICON_STOP = 0x10
    MessageBox = ctypes.windll.user32.MessageBoxW
    MessageBox(None, msg, title, MB_OK | ICON_STOP)


try:
    # run the main function and exit on success
    wxglade.run_main()

except SystemExit as details:
    code = details.code
    title = u'Abnormal Termination of wxGlade'
    if isinstance(code, int) and code != 0:
        msg = u"""\
wxGlade is terminating abnormally with an error.

Please check the wxGlade log file to get more information.

The exit code is: %d
The log file is : %s""" % (code, config.log_file)
    elif isinstance(code, basestring):
        msg = u"""\
wxGlade is terminating abnormally with an error.

Please read the error section in the wxGlade manual for
more details. The wxGlade log file may contain additional
information.

The error message is: %s
The log file is: %s""" % (code, config.log_file)

except:
    exc_type, exc_value, exc_tb = sys.exc_info()
    if exc_type not in [None, SystemExit]:
        exc_traceback = '\r\n'.join(traceback.format_tb(exc_tb))

        title = u'Internal Error in wxGlade'
        msg = u"""\
An internal error occurred while starting wxGlade

This is a bug - please report it and attach the log file.

Error log file: %s
Error type:     %s
Error summary:  %s
Error details:
%s""" % (config.log_file, exc_type, exc_value, exc_traceback)

if msg:
    show_error_details()