1 # demo for ErrorDialogs.py
2 # usual wxWindows license stuff here.
3 # by Chris Fama, with thanks to Robin Dunn, and others on the wxPython-users
6 from wxPython
.wx
import *
7 from wxPython
.lib
.ErrorDialogs
import *
10 ID_BUTTON_wxPyNonFatalError
= 10001
11 ID_BUTTON_wxPyFatalError
= 10002
12 ID_BUTTON_wxPyFatalErrorDialog
= 10003
13 ID_BUTTON_wxPyNonFatalErrorDialog
= 10004
14 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
= 10005
15 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
= 10006
17 def ErrorDialogsDemoPanelFunc( parent
, call_fit
= true
, set_sizer
= true
):
18 item0
= wxBoxSizer( wxVERTICAL
)
20 item1
= wxStaticText( parent
, ID_TEXT
, "Please select one of the buttons below for an example using explicit errors...", wxDefaultPosition
, wxDefaultSize
, 0 )
21 item0
.AddWindow( item1
, 0, wxALIGN_CENTRE|wxALL
, 5 )
23 item2
= wxFlexGridSizer( 0, 2, 0, 0 )
25 item3
= wxButton( parent
, ID_BUTTON_wxPyNonFatalError
, "wxPyNonFatalError", wxDefaultPosition
, wxDefaultSize
, 0 )
26 item2
.AddWindow( item3
, 0, wxALIGN_CENTRE|wxALL
, 5 )
28 item4
= wxButton( parent
, ID_BUTTON_wxPyFatalError
, "wxPyFatalError", wxDefaultPosition
, wxDefaultSize
, 0 )
29 item2
.AddWindow( item4
, 0, wxALIGN_CENTRE|wxALL
, 5 )
31 item0
.AddSizer( item2
, 0, wxALIGN_CENTRE|wxALL
, 5 )
33 item5
= wxStaticText( parent
, ID_TEXT
, "Please select one of the buttons below for interpreter errors...", wxDefaultPosition
, wxDefaultSize
, 0 )
34 item0
.AddWindow( item5
, 0, wxALIGN_CENTRE|wxALL
, 5 )
36 item6
= wxFlexGridSizer( 0, 2, 0, 0 )
38 item7
= wxButton( parent
, ID_BUTTON_wxPyFatalErrorDialog
, "wxPyFatalErrorDialog", wxDefaultPosition
, wxDefaultSize
, 0 )
39 item6
.AddWindow( item7
, 0, wxALIGN_CENTRE|wxALL
, 5 )
41 item8
= wxButton( parent
, ID_BUTTON_wxPyNonFatalErrorDialog
, "wxPyNonFatalErrorDialog", wxDefaultPosition
, wxDefaultSize
, 0 )
42 item6
.AddWindow( item8
, 0, wxALIGN_CENTRE|wxALL
, 5 )
44 item9
= wxButton( parent
, ID_BUTTON_wxPyFatalErrorDialogWithTraceback
, "wxPyFatalErrorDialogWithTraceback", wxDefaultPosition
, wxDefaultSize
, 0 )
45 item6
.AddWindow( item9
, 0, wxALIGN_CENTRE|wxALL
, 5 )
47 item10
= wxButton( parent
, ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
, "wxPyNonFatalErrorDialogWithTraceback", wxDefaultPosition
, wxDefaultSize
, 0 )
49 item6
.AddWindow( item10
, 0, wxALIGN_CENTRE|wxALL
, 5 )
51 item0
.AddSizer( item6
, 0, wxALIGN_CENTRE|wxALL
, 5 )
53 item11
= wxFlexGridSizer( 0, 2, 0, 0 )
55 item0
.AddSizer( item11
, 0, wxALIGN_CENTRE|wxALL
, 5 )
58 parent
.SetAutoLayout( true
)
59 parent
.SetSizer( item0
)
62 item0
.SetSizeHints( parent
)
71 # End of generated file
73 class MyPanel(wxPanel
):
74 def __init__(self
,parent
=None):
75 wxPanel
.__init
__(self
,parent
,-1)
78 'programname': "sumthing",
79 'mailto': "me@sumwear",
80 'whendismissed': "from wxPython.wx import * ; wxBell()"}
81 self
.dialogs
= map(apply,
82 [wxPyNonFatalErrorDialogWithTraceback
,
83 wxPyNonFatalErrorDialog
,#WithTraceback
84 wxPyFatalErrorDialogWithTraceback
,
85 wxPyFatalErrorDialog
],#WithTraceback
88 ErrorDialogsDemoPanelFunc(self
)
91 ID_BUTTON_wxPyFatalErrorDialog
,
94 ID_BUTTON_wxPyNonFatalError
,
97 ID_BUTTON_wxPyFatalError
,
100 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
,
103 ID_BUTTON_wxPyNonFatalErrorDialog
,
106 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
,
108 EVT_CLOSE(self
,self
.OnClose
)
111 ID_BUTTON_wxPyFatalErrorDialog
: 3,
112 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
: 2,
113 ID_BUTTON_wxPyNonFatalErrorDialog
: 1,
114 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
: 0
117 def DoDialog(self
,event
):
119 if id in [ID_BUTTON_wxPyFatalError
,ID_BUTTON_wxPyNonFatalError
]:
120 if id == ID_BUTTON_wxPyFatalError
:
121 print "%s.DoDialog(): testing explicit wxPyFatalError..."\
123 wxPyFatalError(self
,"Test Non-fatal error.<p>"
124 "Nearly arbitrary HTML (i.e., that which is"
125 " understood by <B><I>wxHtmlWindow</i></b>)."
126 "<p><table border=\"2\"><tr><td>This</td><td>is</td></tr>"
127 "<tr><td>a</td><td>table</td></tr></table></p>")
129 print "%s.DoDialog(): testing explicit wxPyNonFatalError..."\
131 wxPyNonFatalError(self
,"Test Non-fatal error.<p>"
132 "Nearly arbitrary HTML (i.e., that which is"
133 " understood by <B><I>wxHtmlWindow</i></b>)."
134 "<p><table border=\"2\"><tr><td>This</td><td>is</td></tr>"
135 "<tr><td>a</td><td>table</td></tr></table></p>")
137 sys
.stderr
= self
.dialogs
[self
.IndexFromID
[id]]
138 print "%s.DoDialog(): testing %s..." % (self
,sys
.stderr
)
139 this_will_generate_a_NameError_exception
141 def OnClose(self
,evt
):
142 for d
in self
.dialogs
:
146 class MyFrame(wxFrame
):
147 def __init__(self
,parent
=None):
148 wxFrame
.__init
__(self
,parent
,-1,
149 "Please make a selection...",
151 self
. panel
= MyPanel(self
)
152 EVT_CLOSE (self
,self
.OnCloseWindow
)
154 def OnCloseWindow(self
,event
):
162 self
.SetTopWindow(frame
)
165 def runTest(pframe
, nb
, log
):
169 from wxPython
.lib
import ErrorDialogs
170 ErrorDialogs
._debug
= 1
172 if __name__
== "__main__":
173 sys
.stderr
= wxPyNonWindowingErrorHandler()
178 overview
= ErrorDialogs
.__doc
__