annotate Lib/lib-tk/Dialog.py @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents b53604fad54b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47099
3b827f3647cb Step 1 of Tkinter renaming: move lib-tk modules into a new "tkinter" package.
Georg Brandl <georg@python.org>
parents: 28513
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
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
3 from Tkinter import *
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
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:
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
7 DIALOG_ICON = 'warning'
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 1853
diff changeset
8 else:
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
9 DIALOG_ICON = 'questhead'
2830
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):
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
13 def __init__(self, master=None, cnf={}, **kw):
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
14 cnf = _cnfmerge((cnf, kw))
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
15 self.widgetName = '__dialog__'
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
16 Widget._setup(self, master, cnf)
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
17 self.num = self.tk.getint(
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 15308
diff changeset
18 self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 15308
diff changeset
19 'tk_dialog', self._w,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 15308
diff changeset
20 cnf['title'], cnf['text'],
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 15308
diff changeset
21 cnf['bitmap'], cnf['default'],
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 15308
diff changeset
22 *cnf['strings']))
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
23 try: Widget.destroy(self)
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
24 except TclError: pass
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
25 def destroy(self): pass
1691
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():
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
28 d = Dialog(None, {'title': 'File Modified',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
29 'text':
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
30 'File "Python.h" has been modified'
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
31 ' since the last time it was saved.'
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
32 ' Do you want to save it before'
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
33 ' exiting the application.',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
34 'bitmap': DIALOG_ICON,
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
35 'default': 0,
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
36 'strings': ('Save File',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
37 'Discard Changes',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
38 'Return to Editor')})
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
39 print d.num
1691
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__':
15308
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
43 t = Button(None, {'text': 'Test',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
44 'command': _test,
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
45 Pack: {}})
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
46 q = Button(None, {'text': 'Quit',
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
47 'command': t.quit,
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
48 Pack: {}})
847ae40074d4 Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents: 2883
diff changeset
49 t.mainloop()