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 *
9 ID_BUTTON_wxPyFatalErrorDialog
= 10001
10 ID_BUTTON_wxPyNonFatalErrorDialog
= 10002
11 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
= 10003
12 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
= 10004
14 def ErrorDialogsDemoPanelFunc( parent
, call_fit
= true
, set_sizer
= true
):
15 item0
= wxBoxSizer( wxVERTICAL
)
17 item1
= wxStaticText( parent
, -1, "Please select one of the buttons below...", wxDefaultPosition
, wxDefaultSize
, 0 )
18 item0
.AddWindow( item1
, 0, wxALIGN_CENTRE|wxALL
, 5 )
20 item2
= wxFlexGridSizer( 0, 2, 0, 0 )
22 item6
= wxButton( parent
, ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
, "wxPyNonFatalErrorDialogWithTraceback", wxDefaultPosition
, wxDefaultSize
, 0 )
24 item2
.AddWindow( item6
, 0, wxALIGN_CENTRE|wxALL
, 5 )
26 item3
= wxButton( parent
, ID_BUTTON_wxPyFatalErrorDialog
, "wxPyFatalErrorDialog", wxDefaultPosition
, wxDefaultSize
, 0 )
27 item2
.AddWindow( item3
, 0, wxALIGN_CENTRE|wxALL
, 5 )
29 item4
= wxButton( parent
, ID_BUTTON_wxPyNonFatalErrorDialog
, "wxPyNonFatalErrorDialog", wxDefaultPosition
, wxDefaultSize
, 0 )
30 item2
.AddWindow( item4
, 0, wxALIGN_CENTRE|wxALL
, 5 )
32 item5
= wxButton( parent
, ID_BUTTON_wxPyFatalErrorDialogWithTraceback
, "wxPyFatalErrorDialogWithTraceback", wxDefaultPosition
, wxDefaultSize
, 0 )
33 item2
.AddWindow( item5
, 0, wxALIGN_CENTRE|wxALL
, 5 )
35 item0
.AddSizer( item2
, 0, wxALIGN_CENTRE|wxALL
, 5 )
38 parent
.SetAutoLayout( true
)
39 parent
.SetSizer( item0
)
42 item0
.SetSizeHints( parent
)
46 # End of generated bit
48 class MyPanel(wxPanel
):
49 def __init__(self
,parent
=None):
50 wxPanel
.__init
__(self
,parent
,-1)
53 'programname': "sumthing",
54 'mailto': "me@sumwear",
55 'whendismissed': "from wxPython.wx import * ; wxBell()"}
56 self
.dialogs
= map(apply,
57 [wxPyNonFatalErrorDialogWithTraceback
,
58 wxPyNonFatalErrorDialog
,#WithTraceback
59 wxPyFatalErrorDialogWithTraceback
,
60 wxPyFatalErrorDialog
],#WithTraceback
63 ErrorDialogsDemoPanelFunc(self
)
66 ID_BUTTON_wxPyFatalErrorDialog
,
69 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
,
72 ID_BUTTON_wxPyNonFatalErrorDialog
,
75 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
,
77 EVT_CLOSE(self
,self
.OnClose
)
80 ID_BUTTON_wxPyFatalErrorDialog
: 3,
81 ID_BUTTON_wxPyFatalErrorDialogWithTraceback
: 2,
82 ID_BUTTON_wxPyNonFatalErrorDialog
: 1,
83 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback
: 0
86 def DoDialog(self
,event
):
87 sys
.stderr
= self
.dialogs
[self
.IndexFromID
[event
.GetId()]]
88 print "%s.DoDialog(): testing %s..." % (self
,sys
.stderr
)
89 this_will_generate_a_NameError_exception
91 def OnClose(self
,evt
):
92 for d
in self
.dialogs
:
96 class MyFrame(wxFrame
):
97 def __init__(self
,parent
=None):
98 wxFrame
.__init
__(self
,parent
,-1,
99 "Please make a selection...",
101 self
. panel
= MyPanel(self
)
102 EVT_CLOSE (self
,self
.OnCloseWindow
)
104 def OnCloseWindow(self
,event
):
112 self
.SetTopWindow(frame
)
115 def runTest(pframe
, nb
, log
):
119 from wxPython
.lib
import ErrorDialogs
120 ErrorDialogs
._debug
= 1
122 if __name__
== "__main__":
123 sys
.stderr
= wxPyNonWindowingErrorHandler()
128 overview
= ErrorDialogs
.__doc
__