Guido van Rossum | f713247 | 1994-06-27 08:00:16 +0000 | [diff] [blame] | 1 | # Dialog.py -- Tkinter interface to the tk_dialog script. |
| 2 | from Tkinter import * |
| 3 | |
| 4 | class Dialog(Widget): |
| 5 | def __init__(self, master=None, cnf={}): |
| 6 | Widget._setup(self, master, cnf) |
| 7 | self.num = apply(self.tk.call, |
| 8 | ('tk_dialog', self._w, |
| 9 | cnf['title'], cnf['text'], |
| 10 | cnf['bitmap'], cnf['default']) |
| 11 | + cnf['strings']) |
| 12 | try: Widget.destroy(self) |
| 13 | except TclError: pass |
| 14 | def destroy(self): pass |
| 15 | |
| 16 | def _test(): |
| 17 | d = Dialog(None, {'title': 'File Modified', |
| 18 | 'text': |
| 19 | 'File "Python.h" has been modified' |
| 20 | ' since the last time it was saved.' |
| 21 | ' Do you want to save it before' |
| 22 | ' exiting the application.', |
| 23 | 'bitmap': 'warning', |
| 24 | 'default': 0, |
| 25 | 'strings': ('Save File', |
| 26 | 'Discard Changes', |
| 27 | 'Return to Editor')}) |
| 28 | print d.num |
| 29 | |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | t = Button(None, {'text': 'Test', |
| 33 | 'command': _test, |
| 34 | Pack: {}}) |
| 35 | q = Button(None, {'text': 'Quit', |
| 36 | 'command': t.quit, |
| 37 | Pack: {}}) |
| 38 | t.mainloop() |