]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ErrorDialogs.py
regenerated after adding DEBUG_ options
[wxWidgets.git] / wxPython / demo / ErrorDialogs.py
CommitLineData
79f1bf32
RD
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
4# mailing list.
5
6from wxPython.wx import *
7from wxPython.lib.ErrorDialogs import *
8_debug = 0
5e217089
RD
9ID_TEXT = 10000
10ID_BUTTON_wxPyNonFatalError = 10001
11ID_BUTTON_wxPyFatalError = 10002
12ID_BUTTON_wxPyFatalErrorDialog = 10003
13ID_BUTTON_wxPyNonFatalErrorDialog = 10004
14ID_BUTTON_wxPyFatalErrorDialogWithTraceback = 10005
15ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback = 10006
79f1bf32 16
1e4a197e 17def ErrorDialogsDemoPanelFunc( parent, call_fit = True, set_sizer = True ):
79f1bf32 18 item0 = wxBoxSizer( wxVERTICAL )
1e4a197e 19
5e217089 20 item1 = wxStaticText( parent, ID_TEXT, "Please select one of the buttons below for an example using explicit errors...", wxDefaultPosition, wxDefaultSize, 0 )
79f1bf32
RD
21 item0.AddWindow( item1, 0, wxALIGN_CENTRE|wxALL, 5 )
22
23 item2 = wxFlexGridSizer( 0, 2, 0, 0 )
1e4a197e 24
5e217089 25 item3 = wxButton( parent, ID_BUTTON_wxPyNonFatalError, "wxPyNonFatalError", wxDefaultPosition, wxDefaultSize, 0 )
79f1bf32
RD
26 item2.AddWindow( item3, 0, wxALIGN_CENTRE|wxALL, 5 )
27
5e217089 28 item4 = wxButton( parent, ID_BUTTON_wxPyFatalError, "wxPyFatalError", wxDefaultPosition, wxDefaultSize, 0 )
79f1bf32
RD
29 item2.AddWindow( item4, 0, wxALIGN_CENTRE|wxALL, 5 )
30
79f1bf32
RD
31 item0.AddSizer( item2, 0, wxALIGN_CENTRE|wxALL, 5 )
32
5e217089
RD
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 )
35
36 item6 = wxFlexGridSizer( 0, 2, 0, 0 )
1e4a197e 37
5e217089
RD
38 item7 = wxButton( parent, ID_BUTTON_wxPyFatalErrorDialog, "wxPyFatalErrorDialog", wxDefaultPosition, wxDefaultSize, 0 )
39 item6.AddWindow( item7, 0, wxALIGN_CENTRE|wxALL, 5 )
40
41 item8 = wxButton( parent, ID_BUTTON_wxPyNonFatalErrorDialog, "wxPyNonFatalErrorDialog", wxDefaultPosition, wxDefaultSize, 0 )
42 item6.AddWindow( item8, 0, wxALIGN_CENTRE|wxALL, 5 )
43
44 item9 = wxButton( parent, ID_BUTTON_wxPyFatalErrorDialogWithTraceback, "wxPyFatalErrorDialogWithTraceback", wxDefaultPosition, wxDefaultSize, 0 )
45 item6.AddWindow( item9, 0, wxALIGN_CENTRE|wxALL, 5 )
46
47 item10 = wxButton( parent, ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback, "wxPyNonFatalErrorDialogWithTraceback", wxDefaultPosition, wxDefaultSize, 0 )
48 item10.SetDefault()
49 item6.AddWindow( item10, 0, wxALIGN_CENTRE|wxALL, 5 )
50
51 item0.AddSizer( item6, 0, wxALIGN_CENTRE|wxALL, 5 )
52
53 item11 = wxFlexGridSizer( 0, 2, 0, 0 )
1e4a197e 54
5e217089
RD
55 item0.AddSizer( item11, 0, wxALIGN_CENTRE|wxALL, 5 )
56
1e4a197e
RD
57 if set_sizer == True:
58 parent.SetAutoLayout( True )
79f1bf32 59 parent.SetSizer( item0 )
1e4a197e 60 if call_fit == True:
79f1bf32
RD
61 item0.Fit( parent )
62 item0.SetSizeHints( parent )
1e4a197e 63
79f1bf32
RD
64 return item0
65
5e217089
RD
66# Menu bar functions
67
68# Bitmap functions
69
70
71# End of generated file
79f1bf32
RD
72
73class MyPanel(wxPanel):
74 def __init__(self,parent=None):
75 wxPanel.__init__(self,parent,-1)
76 args = (None, -1)
77 kwargs = {
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
86 (args,) * 4,
87 (kwargs,) * 4)
88 ErrorDialogsDemoPanelFunc(self)
89
90 EVT_BUTTON(self,
91 ID_BUTTON_wxPyFatalErrorDialog,
92 self.DoDialog)
5e217089
RD
93 EVT_BUTTON(self,
94 ID_BUTTON_wxPyNonFatalError,
95 self.DoDialog)
96 EVT_BUTTON(self,
97 ID_BUTTON_wxPyFatalError,
98 self.DoDialog)
79f1bf32
RD
99 EVT_BUTTON(self,
100 ID_BUTTON_wxPyFatalErrorDialogWithTraceback,
101 self.DoDialog)
102 EVT_BUTTON(self,
103 ID_BUTTON_wxPyNonFatalErrorDialog,
104 self.DoDialog)
105 EVT_BUTTON(self,
106 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback,
107 self.DoDialog)
1e4a197e
RD
108
109
79f1bf32
RD
110 IndexFromID = {
111 ID_BUTTON_wxPyFatalErrorDialog: 3,
112 ID_BUTTON_wxPyFatalErrorDialogWithTraceback: 2,
113 ID_BUTTON_wxPyNonFatalErrorDialog: 1,
114 ID_BUTTON_wxPyNonFatalErrorDialogWithTraceback: 0
115 }
116
117 def DoDialog(self,event):
5e217089
RD
118 id = event.GetId()
119 if id in [ID_BUTTON_wxPyFatalError,ID_BUTTON_wxPyNonFatalError]:
120 if id == ID_BUTTON_wxPyFatalError:
121 print "%s.DoDialog(): testing explicit wxPyFatalError..."\
122 % self
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>")
128 else:
129 print "%s.DoDialog(): testing explicit wxPyNonFatalError..."\
130 % self
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>")
136 else:
137 sys.stderr = self.dialogs[self.IndexFromID[id]]
138 print "%s.DoDialog(): testing %s..." % (self,sys.stderr)
139 this_will_generate_a_NameError_exception
79f1bf32 140
1e4a197e 141 def ShutdownDemo(self):
79f1bf32 142 for d in self.dialogs:
1e4a197e
RD
143 d.Destroy()
144
145
79f1bf32
RD
146
147class MyFrame(wxFrame):
148 def __init__(self,parent=None):
149 wxFrame.__init__(self,parent,-1,
150 "Please make a selection...",
151 )
152 self. panel = MyPanel(self)
153 EVT_CLOSE (self,self.OnCloseWindow)
154
155 def OnCloseWindow(self,event):
156 self.panel.Close()
157 self.Destroy()
158
159class MyApp(wxApp):
160 def OnInit(self):
161 frame = MyFrame()
1e4a197e 162 frame.Show(True)
79f1bf32 163 self.SetTopWindow(frame)
1e4a197e 164 return True
79f1bf32
RD
165
166def runTest(pframe, nb, log):
167 panel = MyPanel(nb)
168 return panel
169
170from wxPython.lib import ErrorDialogs
171ErrorDialogs._debug = 1
172
173if __name__ == "__main__":
174 sys.stderr = wxPyNonWindowingErrorHandler()
175 app = MyApp(0)
176 app.MainLoop()
177 sys.exit()
178else:
179 overview = ErrorDialogs.__doc__