ยปCore Development>Code coverage>Lib/tkinter/dialog.py

Python code coverage for Lib/tkinter/dialog.py

#countcontent
1n/a# dialog.py -- Tkinter interface to the tk_dialog script.
2n/a
3n/afrom tkinter import *
4n/afrom tkinter import _cnfmerge
5n/a
6n/aDIALOG_ICON = 'questhead'
7n/a
8n/a
9n/aclass Dialog(Widget):
10n/a def __init__(self, master=None, cnf={}, **kw):
11n/a cnf = _cnfmerge((cnf, kw))
12n/a self.widgetName = '__dialog__'
13n/a Widget._setup(self, master, cnf)
14n/a self.num = self.tk.getint(
15n/a self.tk.call(
16n/a 'tk_dialog', self._w,
17n/a cnf['title'], cnf['text'],
18n/a cnf['bitmap'], cnf['default'],
19n/a *cnf['strings']))
20n/a try: Widget.destroy(self)
21n/a except TclError: pass
22n/a def destroy(self): pass
23n/a
24n/adef _test():
25n/a d = Dialog(None, {'title': 'File Modified',
26n/a 'text':
27n/a 'File "Python.h" has been modified'
28n/a ' since the last time it was saved.'
29n/a ' Do you want to save it before'
30n/a ' exiting the application.',
31n/a 'bitmap': DIALOG_ICON,
32n/a 'default': 0,
33n/a 'strings': ('Save File',
34n/a 'Discard Changes',
35n/a 'Return to Editor')})
36n/a print(d.num)
37n/a
38n/a
39n/aif __name__ == '__main__':
40n/a t = Button(None, {'text': 'Test',
41n/a 'command': _test,
42n/a Pack: {}})
43n/a q = Button(None, {'text': 'Quit',
44n/a 'command': t.quit,
45n/a Pack: {}})
46n/a t.mainloop()