PageRenderTime 39ms CodeModel.GetById 35ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-25/SWIG/Tools/WAD/Test/death.py

#
Python | 65 lines | 43 code | 21 blank | 1 comment | 1 complexity | 7f613ed6eaf1c2c03904d28d8fe2985d MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1import debug
 2from Tkinter import *
 3
 4def death_by_segmentation():
 5    debug.seg_crash()
 6
 7def death_by_bus():
 8    debug.bus_crash()
 9
10def death_by_abort():
11    debug.abort_crash(-1)
12
13def death_by_math():
14    debug.math_crash(37,0)
15
16def death_by_buffer():
17    debug.overflow_crash()
18
19def death(f):
20    ty = f.tvar.get()
21    if ty == 1:
22        death_by_segmentation()
23    elif ty == 2:
24        death_by_abort()  
25    elif ty == 3:
26        death_by_math()
27    elif ty == 4:
28        death_by_bus()
29    elif ty == 5:
30        death_by_buffer()
31
32class death_options(Frame):
33   def __init__(self):
34        Frame.__init__(self)
35        tvar = IntVar()
36        Radiobutton(self,text="Segmentation fault", variable=tvar, value=1).pack(anchor=W)
37        Radiobutton(self,text="Failed assertion", variable=tvar, value=2).pack(anchor=W)
38        Radiobutton(self,text="Math error", variable=tvar, value=3).pack(anchor=W)
39        Radiobutton(self,text="Bus error", variable=tvar, value=4).pack(anchor=W)
40        Radiobutton(self,text="Stack overflow", variable=tvar, value=5).pack(anchor=W)
41        Button(self,text="Die", command=lambda x=self: death(x)).pack(expand=1, fill=BOTH)
42        self.tvar = tvar
43        tvar.set(1)
44
45def death_wizard():
46    root = Tk()
47    l = Label(text="How would you like to die today?")
48    l.pack()
49    death_options().pack()
50    root.title("Death Wizard")
51death_wizard()
52
53#root.mainloop()
54
55
56
57
58
59
60
61
62
63
64
65