Mercurial > cpython-lru_cache-weakref
annotate Lib/tkinter/Dialog.py @ 5792:dffabc620e4e legacy-trunk
Tweak re_tests and test_re to differentiate between
groups that have no value and groups that are out of bounds.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 15 Jul 1997 15:49:52 +0000 |
| parents | 51c9cfff31f3 |
| children |
| rev | line source |
|---|---|
| 1691 | 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 | 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 | 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 | 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 | 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 | 23 try: Widget.destroy(self) |
| 24 except TclError: pass | |
| 25 def destroy(self): pass | |
| 26 | |
| 27 def _test(): | |
| 28 d = Dialog(None, {'title': 'File Modified', | |
| 29 'text': | |
| 30 'File "Python.h" has been modified' | |
| 31 ' since the last time it was saved.' | |
| 32 ' Do you want to save it before' | |
| 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 | 35 'default': 0, |
| 36 'strings': ('Save File', | |
| 37 'Discard Changes', | |
| 38 'Return to Editor')}) | |
| 39 print d.num | |
| 40 | |
| 41 | |
| 42 if __name__ == '__main__': | |
| 43 t = Button(None, {'text': 'Test', | |
| 44 'command': _test, | |
| 45 Pack: {}}) | |
| 46 q = Button(None, {'text': 'Quit', | |
| 47 'command': t.quit, | |
| 48 Pack: {}}) | |
| 49 t.mainloop() |
