PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

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

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