annotate Lib/tkinter/Dialog.py @ 2830:bd79cd768ff8 legacy-trunk

Tk 4.0 and Tcl 7.4 are now standard
author Guido van Rossum <guido@python.org>
date Fri, 14 Jul 1995 15:29:10 +0000
parents 9d4add42ee22
children 51c9cfff31f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Dialog.py -- Tkinter interface to the tk_dialog script.
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
2
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 from Tkinter import *
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
5 if TkVersion == 3.6:
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
6 DIALOG_ICON = 'warning'
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
7 else:
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
8 DIALOG_ICON = 'questhead'
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
9
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
10
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 class Dialog(Widget):
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 def __init__(self, master=None, cnf={}):
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
13 self.widgetName = '__dialog__'
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 Widget._setup(self, master, cnf)
1853
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
15 self.num = self.tk.getint(
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
16 apply(self.tk.call,
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
17 ('tk_dialog', self._w,
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
18 cnf['title'], cnf['text'],
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
19 cnf['bitmap'], cnf['default'])
9d4add42ee22 Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents: 1691
diff changeset
20 + cnf['strings']))
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 try: Widget.destroy(self)
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 except TclError: pass
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 def destroy(self): pass
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 def _test():
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 d = Dialog(None, {'title': 'File Modified',
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 'text':
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 'File "Python.h" has been modified'
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 ' since the last time it was saved.'
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 ' Do you want to save it before'
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 ' exiting the application.',
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
32 'bitmap': DIALOG_ICON,
1691
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 'default': 0,
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 'strings': ('Save File',
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 'Discard Changes',
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 'Return to Editor')})
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 print d.num
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 if __name__ == '__main__':
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 t = Button(None, {'text': 'Test',
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 'command': _test,
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 Pack: {}})
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 q = Button(None, {'text': 'Quit',
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 'command': t.quit,
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 Pack: {}})
d88af58e95cd Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 t.mainloop()