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