ยปCore Development>Code coverage>Lib/lib-tk/tkCommonDialog.py

Python code coverage for Lib/lib-tk/tkCommonDialog.py

#countcontent
1n/a# base class for tk common dialogues
2n/a#
3n/a# this module provides a base class for accessing the common
4n/a# dialogues available in Tk 4.2 and newer. use tkFileDialog,
5n/a# tkColorChooser, and tkMessageBox to access the individual
6n/a# dialogs.
7n/a#
8n/a# written by Fredrik Lundh, May 1997
9n/a#
10n/a
11n/afrom Tkinter import *
12n/a
13n/aclass Dialog:
14n/a
15n/a command = None
16n/a
17n/a def __init__(self, master=None, **options):
18n/a
19n/a # FIXME: should this be placed on the module level instead?
20n/a if TkVersion < 4.2:
21n/a raise TclError, "this module requires Tk 4.2 or newer"
22n/a
23n/a self.master = master
24n/a self.options = options
25n/a if not master and options.get('parent'):
26n/a self.master = options['parent']
27n/a
28n/a def _fixoptions(self):
29n/a pass # hook
30n/a
31n/a def _fixresult(self, widget, result):
32n/a return result # hook
33n/a
34n/a def show(self, **options):
35n/a
36n/a # update instance options
37n/a for k, v in options.items():
38n/a self.options[k] = v
39n/a
40n/a self._fixoptions()
41n/a
42n/a # we need a dummy widget to properly process the options
43n/a # (at least as long as we use Tkinter 1.63)
44n/a w = Frame(self.master)
45n/a
46n/a try:
47n/a
48n/a s = w.tk.call(self.command, *w._options(self.options))
49n/a
50n/a s = self._fixresult(w, s)
51n/a
52n/a finally:
53n/a
54n/a try:
55n/a # get rid of the widget
56n/a w.destroy()
57n/a except:
58n/a pass
59n/a
60n/a return s