Mercurial > cpython-lru_cache-weakref
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 |
| 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 * |
| 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 | 11 class Dialog(Widget): |
| 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 | 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 | 21 try: Widget.destroy(self) |
| 22 except TclError: pass | |
| 23 def destroy(self): pass | |
| 24 | |
| 25 def _test(): | |
| 26 d = Dialog(None, {'title': 'File Modified', | |
| 27 'text': | |
| 28 'File "Python.h" has been modified' | |
| 29 ' since the last time it was saved.' | |
| 30 ' Do you want to save it before' | |
| 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 | 33 'default': 0, |
| 34 'strings': ('Save File', | |
| 35 'Discard Changes', | |
| 36 'Return to Editor')}) | |
| 37 print d.num | |
| 38 | |
| 39 | |
| 40 if __name__ == '__main__': | |
| 41 t = Button(None, {'text': 'Test', | |
| 42 'command': _test, | |
| 43 Pack: {}}) | |
| 44 q = Button(None, {'text': 'Quit', | |
| 45 'command': t.quit, | |
| 46 Pack: {}}) | |
| 47 t.mainloop() |
