annotate Lib/tkinter/Dialog.py @ 5817:48b94de85bf3 legacy-trunk

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