1 |
jan |
1703 |
# Copyright (c) 2003 by Intevation GmbH |
2 |
|
|
# Authors: |
3 |
|
|
# Jan-Oliver Wagnber <[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 |
|
|
__version__ = "$Revision$" |
9 |
|
|
|
10 |
|
|
import sys |
11 |
|
|
|
12 |
dpinte |
2700 |
import wx |
13 |
jan |
1703 |
|
14 |
|
|
from Thuban import _ |
15 |
|
|
|
16 |
dpinte |
2700 |
class ExceptionDialog(wx.Dialog): |
17 |
jan |
1703 |
|
18 |
|
|
"""The exception dialog shows the exception message and then allows |
19 |
|
|
to either proceed with the application or to exit it. In the |
20 |
|
|
latter case, sys.exit(1) is applied immediately. |
21 |
|
|
""" |
22 |
|
|
|
23 |
|
|
def __init__(self, parent, message, title = _('Thuban: Internal Error')): |
24 |
dpinte |
2700 |
wx.Dialog.__init__(self, parent, -1, title, |
25 |
|
|
wx.DefaultPosition, |
26 |
|
|
style = wx.RESIZE_BORDER|wx.CAPTION|wx.DIALOG_MODAL) |
27 |
jan |
1703 |
|
28 |
|
|
self.parent = parent |
29 |
|
|
self.dialog_layout(message) |
30 |
dpinte |
2700 |
|
31 |
jan |
1703 |
def dialog_layout(self, message): |
32 |
dpinte |
2700 |
top_box = wx.BoxSizer(wx.VERTICAL) |
33 |
jan |
1703 |
|
34 |
dpinte |
2700 |
textBox = wx.TextCtrl(self, -1, message, |
35 |
|
|
style=wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_LINEWRAP) |
36 |
jan |
1703 |
w, h = (500, 300) |
37 |
|
|
textBox.SetSizeHints(w, h) |
38 |
|
|
textBox.SetSize((w, h)) |
39 |
|
|
|
40 |
dpinte |
2700 |
top_box.Add(textBox, 1, wx.EXPAND|wx.ALL, 10) |
41 |
jan |
1703 |
|
42 |
dpinte |
2700 |
box = wx.BoxSizer(wx.HORIZONTAL) |
43 |
|
|
box.Add(wx.Button(self, wx.ID_OK, _("Proceed")), 0, wx.ALL, 4) |
44 |
|
|
box.Add(wx.Button(self, wx.ID_CANCEL, _("Exit Thuban now")), 0, wx.ALL, 4) |
45 |
|
|
top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10) |
46 |
jan |
1703 |
|
47 |
dpinte |
2700 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK) |
48 |
|
|
self.Bind(wx.EVT_BUTTON, self.OnExit, id=wx.ID_CANCEL) |
49 |
jan |
1703 |
|
50 |
|
|
self.SetAutoLayout(True) |
51 |
|
|
self.SetSizer(top_box) |
52 |
|
|
top_box.Fit(self) |
53 |
|
|
top_box.SetSizeHints(self) |
54 |
|
|
|
55 |
|
|
def OnOK(self, event): |
56 |
dpinte |
2700 |
self.EndModal(wx.ID_OK) |
57 |
jan |
1703 |
|
58 |
|
|
def OnExit(self, event): |
59 |
|
|
sys.exit(1) |
60 |
|
|
|
61 |
|
|
def run_exception_dialog(parent, message, title = _('Thuban: Internal Error')): |
62 |
|
|
dialog = ExceptionDialog(parent, message, title) |
63 |
|
|
dialog.ShowModal() |
64 |
|
|
dialog.Destroy() |