Mercurial > cpython-lru_cache-weakref
annotate Lib/lib-tk/ttk.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 9b472b24e5c9 |
| children | 917ae14831ec |
| rev | line source |
|---|---|
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1 """Ttk wrapper. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
2 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
3 This module provides classes to allow using Tk themed widget set. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
4 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
5 Ttk is based on a revised and enhanced version of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
6 TIP #48 (http://tip.tcl.tk/48) specified style engine. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
7 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
8 Its basic idea is to separate, to the extent possible, the code |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
9 implementing a widget's behavior from the code implementing its |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
10 appearance. Widget class bindings are primarily responsible for |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
11 maintaining the widget state and invoking callbacks, all aspects |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
12 of the widgets appearance lies at Themes. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
13 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
14 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
15 __version__ = "0.3.1" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
16 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
17 __author__ = "Guilherme Polo <ggpolo@gmail.com>" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
18 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
19 __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
20 "Labelframe", "LabelFrame", "Menubutton", "Notebook", "Panedwindow", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
21 "PanedWindow", "Progressbar", "Radiobutton", "Scale", "Scrollbar", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
22 "Separator", "Sizegrip", "Style", "Treeview", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
23 # Extensions |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
24 "LabeledScale", "OptionMenu", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
25 # functions |
|
51480
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
26 "tclobjs_to_py", "setup_master"] |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
27 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
28 import Tkinter |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
29 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
30 _flatten = Tkinter._flatten |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
31 |
|
51435
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
32 # Verify if Tk is new enough to not need the Tile package |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
33 _REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
34 |
|
51435
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
35 def _load_tile(master): |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
36 if _REQUIRE_TILE: |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
37 import os |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
38 tilelib = os.environ.get('TILE_LIBRARY') |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
39 if tilelib: |
| 53735 | 40 # append custom tile path to the list of directories that |
|
51435
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
41 # Tcl uses when attempting to resolve packages with the package |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
42 # command |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
43 master.tk.eval( |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
44 'global auto_path; ' |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
45 'lappend auto_path {%s}' % tilelib) |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
46 |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
47 master.tk.eval('package require tile') # TclError may be raised here |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
48 master._tile_loaded = True |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
49 |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
50 def _format_optdict(optdict, script=False, ignore=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
51 """Formats optdict to a tuple to pass it to tk.call. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
52 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
53 E.g. (script=False): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
54 {'foreground': 'blue', 'padding': [1, 2, 3, 4]} returns: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
55 ('-foreground', 'blue', '-padding', '1 2 3 4')""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
56 format = "%s" if not script else "{%s}" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
57 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
58 opts = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
59 for opt, value in optdict.iteritems(): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
60 if ignore and opt in ignore: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
61 continue |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
62 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
63 if isinstance(value, (list, tuple)): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
64 v = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
65 for val in value: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
66 if isinstance(val, basestring): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
67 v.append(unicode(val) if val else '{}') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
68 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
69 v.append(str(val)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
70 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
71 # format v according to the script option, but also check for |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
72 # space in any value in v in order to group them correctly |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
73 value = format % ' '.join( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
74 ('{%s}' if ' ' in val else '%s') % val for val in v) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
75 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
76 if script and value == '': |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
77 value = '{}' # empty string in Python is equivalent to {} in Tcl |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
78 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
79 opts.append(("-%s" % opt, value)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
80 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
81 # Remember: _flatten skips over None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
82 return _flatten(opts) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
83 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
84 def _format_mapdict(mapdict, script=False): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
85 """Formats mapdict to pass it to tk.call. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
86 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
87 E.g. (script=False): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
88 {'expand': [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
89 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
90 returns: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
91 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
92 ('-expand', '{active selected} grey focus {1, 2, 3, 4}')""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
93 # if caller passes a Tcl script to tk.call, all the values need to |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
94 # be grouped into words (arguments to a command in Tcl dialect) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
95 format = "%s" if not script else "{%s}" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
96 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
97 opts = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
98 for opt, value in mapdict.iteritems(): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
99 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
100 opt_val = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
101 # each value in mapdict is expected to be a sequence, where each item |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
102 # is another sequence containing a state (or several) and a value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
103 for statespec in value: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
104 state, val = statespec[:-1], statespec[-1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
105 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
106 if len(state) > 1: # group multiple states |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
107 state = "{%s}" % ' '.join(state) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
108 else: # single state |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
109 # if it is empty (something that evaluates to False), then |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
110 # format it to Tcl code to denote the "normal" state |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
111 state = state[0] or '{}' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
112 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
113 if isinstance(val, (list, tuple)): # val needs to be grouped |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
114 val = "{%s}" % ' '.join(map(str, val)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
115 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
116 opt_val.append("%s %s" % (state, val)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
117 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
118 opts.append(("-%s" % opt, format % ' '.join(opt_val))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
119 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
120 return _flatten(opts) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
121 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
122 def _format_elemcreate(etype, script=False, *args, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
123 """Formats args and kw according to the given element factory etype.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
124 spec = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
125 opts = () |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
126 if etype in ("image", "vsapi"): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
127 if etype == "image": # define an element based on an image |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
128 # first arg should be the default image name |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
129 iname = args[0] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
130 # next args, if any, are statespec/value pairs which is almost |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
131 # a mapdict, but we just need the value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
132 imagespec = _format_mapdict({None: args[1:]})[1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
133 spec = "%s %s" % (iname, imagespec) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
134 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
135 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
136 # define an element whose visual appearance is drawn using the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
137 # Microsoft Visual Styles API which is responsible for the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
138 # themed styles on Windows XP and Vista. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
139 # Availability: Tk 8.6, Windows XP and Vista. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
140 class_name, part_id = args[:2] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
141 statemap = _format_mapdict({None: args[2:]})[1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
142 spec = "%s %s %s" % (class_name, part_id, statemap) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
143 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
144 opts = _format_optdict(kw, script) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
145 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
146 elif etype == "from": # clone an element |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
147 # it expects a themename and optionally an element to clone from, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
148 # otherwise it will clone {} (empty element) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
149 spec = args[0] # theme name |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
150 if len(args) > 1: # elementfrom specified |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
151 opts = (args[1], ) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
152 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
153 if script: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
154 spec = '{%s}' % spec |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
155 opts = ' '.join(map(str, opts)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
156 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
157 return spec, opts |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
158 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
159 def _format_layoutlist(layout, indent=0, indent_size=2): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
160 """Formats a layout list so we can pass the result to ttk::style |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
161 layout and ttk::style settings. Note that the layout doesn't has to |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
162 be a list necessarily. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
163 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
164 E.g.: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
165 [("Menubutton.background", None), |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
166 ("Menubutton.button", {"children": |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
167 [("Menubutton.focus", {"children": |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
168 [("Menubutton.padding", {"children": |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
169 [("Menubutton.label", {"side": "left", "expand": 1})] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
170 })] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
171 })] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
172 }), |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
173 ("Menubutton.indicator", {"side": "right"}) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
174 ] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
175 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
176 returns: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
177 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
178 Menubutton.background |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
179 Menubutton.button -children { |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
180 Menubutton.focus -children { |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
181 Menubutton.padding -children { |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
182 Menubutton.label -side left -expand 1 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
183 } |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
184 } |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
185 } |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
186 Menubutton.indicator -side right""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
187 script = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
188 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
189 for layout_elem in layout: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
190 elem, opts = layout_elem |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
191 opts = opts or {} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
192 fopts = ' '.join(map(str, _format_optdict(opts, True, "children"))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
193 head = "%s%s%s" % (' ' * indent, elem, (" %s" % fopts) if fopts else '') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
194 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
195 if "children" in opts: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
196 script.append(head + " -children {") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
197 indent += indent_size |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
198 newscript, indent = _format_layoutlist(opts['children'], indent, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
199 indent_size) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
200 script.append(newscript) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
201 indent -= indent_size |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
202 script.append('%s}' % (' ' * indent)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
203 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
204 script.append(head) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
205 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
206 return '\n'.join(script), indent |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
207 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
208 def _script_from_settings(settings): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
209 """Returns an appropriate script, based on settings, according to |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
210 theme_settings definition to be used by theme_settings and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
211 theme_create.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
212 script = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
213 # a script will be generated according to settings passed, which |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
214 # will then be evaluated by Tcl |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
215 for name, opts in settings.iteritems(): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
216 # will format specific keys according to Tcl code |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
217 if opts.get('configure'): # format 'configure' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
218 s = ' '.join(map(unicode, _format_optdict(opts['configure'], True))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
219 script.append("ttk::style configure %s %s;" % (name, s)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
220 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
221 if opts.get('map'): # format 'map' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
222 s = ' '.join(map(unicode, _format_mapdict(opts['map'], True))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
223 script.append("ttk::style map %s %s;" % (name, s)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
224 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
225 if 'layout' in opts: # format 'layout' which may be empty |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
226 if not opts['layout']: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
227 s = 'null' # could be any other word, but this one makes sense |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
228 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
229 s, _ = _format_layoutlist(opts['layout']) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
230 script.append("ttk::style layout %s {\n%s\n}" % (name, s)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
231 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
232 if opts.get('element create'): # format 'element create' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
233 eopts = opts['element create'] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
234 etype = eopts[0] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
235 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
236 # find where args end, and where kwargs start |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
237 argc = 1 # etype was the first one |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
238 while argc < len(eopts) and not hasattr(eopts[argc], 'iteritems'): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
239 argc += 1 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
240 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
241 elemargs = eopts[1:argc] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
242 elemkw = eopts[argc] if argc < len(eopts) and eopts[argc] else {} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
243 spec, opts = _format_elemcreate(etype, True, *elemargs, **elemkw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
244 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
245 script.append("ttk::style element create %s %s %s %s" % ( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
246 name, etype, spec, opts)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
247 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
248 return '\n'.join(script) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
249 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
250 def _dict_from_tcltuple(ttuple, cut_minus=True): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
251 """Break tuple in pairs, format it properly, then build the return |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
252 dict. If cut_minus is True, the supposed '-' prefixing options will |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
253 be removed. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
254 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
255 ttuple is expected to contain an even number of elements.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
256 opt_start = 1 if cut_minus else 0 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
257 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
258 retdict = {} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
259 it = iter(ttuple) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
260 for opt, val in zip(it, it): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
261 retdict[str(opt)[opt_start:]] = val |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
262 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
263 return tclobjs_to_py(retdict) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
264 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
265 def _list_from_statespec(stuple): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
266 """Construct a list from the given statespec tuple according to the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
267 accepted statespec accepted by _format_mapdict.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
268 nval = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
269 for val in stuple: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
270 typename = getattr(val, 'typename', None) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
271 if typename is None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
272 nval.append(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
273 else: # this is a Tcl object |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
274 val = str(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
275 if typename == 'StateSpec': |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
276 val = val.split() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
277 nval.append(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
278 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
279 it = iter(nval) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
280 return [_flatten(spec) for spec in zip(it, it)] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
281 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
282 def _list_from_layouttuple(ltuple): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
283 """Construct a list from the tuple returned by ttk::layout, this is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
284 somewhat the reverse of _format_layoutlist.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
285 res = [] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
286 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
287 indx = 0 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
288 while indx < len(ltuple): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
289 name = ltuple[indx] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
290 opts = {} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
291 res.append((name, opts)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
292 indx += 1 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
293 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
294 while indx < len(ltuple): # grab name's options |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
295 opt, val = ltuple[indx:indx + 2] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
296 if not opt.startswith('-'): # found next name |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
297 break |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
298 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
299 opt = opt[1:] # remove the '-' from the option |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
300 indx += 2 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
301 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
302 if opt == 'children': |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
303 val = _list_from_layouttuple(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
304 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
305 opts[opt] = val |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
306 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
307 return res |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
308 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
309 def _val_or_dict(options, func, *args): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
310 """Format options then call func with args and options and return |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
311 the appropriate result. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
312 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
313 If no option is specified, a dict is returned. If a option is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
314 specified with the None value, the value for that option is returned. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
315 Otherwise, the function just sets the passed options and the caller |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
316 shouldn't be expecting a return value anyway.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
317 options = _format_optdict(options) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
318 res = func(*(args + options)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
319 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
320 if len(options) % 2: # option specified without a value, return its value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
321 return res |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
322 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
323 return _dict_from_tcltuple(res) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
324 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
325 def _convert_stringval(value): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
326 """Converts a value to, hopefully, a more appropriate Python object.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
327 value = unicode(value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
328 try: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
329 value = int(value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
330 except (ValueError, TypeError): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
331 pass |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
332 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
333 return value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
334 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
335 def tclobjs_to_py(adict): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
336 """Returns adict with its values converted from Tcl objects to Python |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
337 objects.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
338 for opt, val in adict.iteritems(): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
339 if val and hasattr(val, '__len__') and not isinstance(val, basestring): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
340 if getattr(val[0], 'typename', None) == 'StateSpec': |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
341 val = _list_from_statespec(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
342 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
343 val = map(_convert_stringval, val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
344 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
345 elif hasattr(val, 'typename'): # some other (single) Tcl object |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
346 val = _convert_stringval(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
347 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
348 adict[opt] = val |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
349 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
350 return adict |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
351 |
|
51480
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
352 def setup_master(master=None): |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
353 """If master is not None, itself is returned. If master is None, |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
354 the default master is returned if there is one, otherwise a new |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
355 master is created and returned. |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
356 |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
357 If it is not allowed to use the default root and master is None, |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
358 RuntimeError is raised.""" |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
359 if master is None: |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
360 if Tkinter._support_default_root: |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
361 master = Tkinter._default_root or Tkinter.Tk() |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
362 else: |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
363 raise RuntimeError( |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
364 "No master specified and Tkinter is " |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
365 "configured to not support default root") |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
366 return master |
|
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
367 |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
368 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
369 class Style(object): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
370 """Manipulate style database.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
371 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
372 _name = "ttk::style" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
373 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
374 def __init__(self, master=None): |
|
51480
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
375 master = setup_master(master) |
|
51435
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
376 |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
377 if not getattr(master, '_tile_loaded', False): |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
378 # Load tile now, if needed |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
379 _load_tile(master) |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
380 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
381 self.master = master |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
382 self.tk = self.master.tk |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
383 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
384 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
385 def configure(self, style, query_opt=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
386 """Query or sets the default value of the specified option(s) in |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
387 style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
388 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
389 Each key in kw is an option and each value is either a string or |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
390 a sequence identifying the value for that option.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
391 if query_opt is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
392 kw[query_opt] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
393 return _val_or_dict(kw, self.tk.call, self._name, "configure", style) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
394 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
395 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
396 def map(self, style, query_opt=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
397 """Query or sets dynamic values of the specified option(s) in |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
398 style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
399 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
400 Each key in kw is an option and each value should be a list or a |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
401 tuple (usually) containing statespecs grouped in tuples, or list, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
402 or something else of your preference. A statespec is compound of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
403 one or more states and then a value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
404 if query_opt is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
405 return _list_from_statespec( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
406 self.tk.call(self._name, "map", style, '-%s' % query_opt)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
407 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
408 return _dict_from_tcltuple( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
409 self.tk.call(self._name, "map", style, *(_format_mapdict(kw)))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
410 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
411 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
412 def lookup(self, style, option, state=None, default=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
413 """Returns the value specified for option in style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
414 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
415 If state is specified it is expected to be a sequence of one |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
416 or more states. If the default argument is set, it is used as |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
417 a fallback value in case no specification for option is found.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
418 state = ' '.join(state) if state else '' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
419 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
420 return self.tk.call(self._name, "lookup", style, '-%s' % option, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
421 state, default) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
422 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
423 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
424 def layout(self, style, layoutspec=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
425 """Define the widget layout for given style. If layoutspec is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
426 omitted, return the layout specification for given style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
427 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
428 layoutspec is expected to be a list or an object different than |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
429 None that evaluates to False if you want to "turn off" that style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
430 If it is a list (or tuple, or something else), each item should be |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
431 a tuple where the first item is the layout name and the second item |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
432 should have the format described below: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
433 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
434 LAYOUTS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
435 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
436 A layout can contain the value None, if takes no options, or |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
437 a dict of options specifying how to arrange the element. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
438 The layout mechanism uses a simplified version of the pack |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
439 geometry manager: given an initial cavity, each element is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
440 allocated a parcel. Valid options/values are: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
441 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
442 side: whichside |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
443 Specifies which side of the cavity to place the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
444 element; one of top, right, bottom or left. If |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
445 omitted, the element occupies the entire cavity. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
446 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
447 sticky: nswe |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
448 Specifies where the element is placed inside its |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
449 allocated parcel. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
450 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
451 children: [sublayout... ] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
452 Specifies a list of elements to place inside the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
453 element. Each element is a tuple (or other sequence) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
454 where the first item is the layout name, and the other |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
455 is a LAYOUT.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
456 lspec = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
457 if layoutspec: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
458 lspec = _format_layoutlist(layoutspec)[0] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
459 elif layoutspec is not None: # will disable the layout ({}, '', etc) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
460 lspec = "null" # could be any other word, but this may make sense |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
461 # when calling layout(style) later |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
462 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
463 return _list_from_layouttuple( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
464 self.tk.call(self._name, "layout", style, lspec)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
465 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
466 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
467 def element_create(self, elementname, etype, *args, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
468 """Create a new element in the current theme of given etype.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
469 spec, opts = _format_elemcreate(etype, False, *args, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
470 self.tk.call(self._name, "element", "create", elementname, etype, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
471 spec, *opts) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
472 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
473 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
474 def element_names(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
475 """Returns the list of elements defined in the current theme.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
476 return self.tk.call(self._name, "element", "names") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
477 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
478 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
479 def element_options(self, elementname): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
480 """Return the list of elementname's options.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
481 return self.tk.call(self._name, "element", "options", elementname) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
482 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
483 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
484 def theme_create(self, themename, parent=None, settings=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
485 """Creates a new theme. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
486 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
487 It is an error if themename already exists. If parent is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
488 specified, the new theme will inherit styles, elements and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
489 layouts from the specified parent theme. If settings are present, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
490 they are expected to have the same syntax used for theme_settings.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
491 script = _script_from_settings(settings) if settings else '' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
492 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
493 if parent: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
494 self.tk.call(self._name, "theme", "create", themename, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
495 "-parent", parent, "-settings", script) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
496 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
497 self.tk.call(self._name, "theme", "create", themename, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
498 "-settings", script) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
499 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
500 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
501 def theme_settings(self, themename, settings): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
502 """Temporarily sets the current theme to themename, apply specified |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
503 settings and then restore the previous theme. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
504 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
505 Each key in settings is a style and each value may contain the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
506 keys 'configure', 'map', 'layout' and 'element create' and they |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
507 are expected to have the same format as specified by the methods |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
508 configure, map, layout and element_create respectively.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
509 script = _script_from_settings(settings) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
510 self.tk.call(self._name, "theme", "settings", themename, script) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
511 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
512 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
513 def theme_names(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
514 """Returns a list of all known themes.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
515 return self.tk.call(self._name, "theme", "names") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
516 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
517 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
518 def theme_use(self, themename=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
519 """If themename is None, returns the theme in use, otherwise, set |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
520 the current theme to themename, refreshes all widgets and emits |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
521 a <<ThemeChanged>> event.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
522 if themename is None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
523 # Starting on Tk 8.6, checking this global is no longer needed |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
524 # since it allows doing self.tk.call(self._name, "theme", "use") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
525 return self.tk.eval("return $ttk::currentTheme") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
526 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
527 # using "ttk::setTheme" instead of "ttk::style theme use" causes |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
528 # the variable currentTheme to be updated, also, ttk::setTheme calls |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
529 # "ttk::style theme use" in order to change theme. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
530 self.tk.call("ttk::setTheme", themename) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
531 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
532 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
533 class Widget(Tkinter.Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
534 """Base class for Tk themed widgets.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
535 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
536 def __init__(self, master, widgetname, kw=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
537 """Constructs a Ttk Widget with the parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
538 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
539 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
540 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
541 class, cursor, takefocus, style |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
542 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
543 SCROLLABLE WIDGET OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
544 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
545 xscrollcommand, yscrollcommand |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
546 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
547 LABEL WIDGET OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
548 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
549 text, textvariable, underline, image, compound, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
550 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
551 WIDGET STATES |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
552 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
553 active, disabled, focus, pressed, selected, background, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
554 readonly, alternate, invalid |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
555 """ |
|
51480
dcffc72381e7
Turned setup_master public
Guilherme Polo <ggpolo@gmail.com>
parents:
51435
diff
changeset
|
556 master = setup_master(master) |
|
51435
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
557 if not getattr(master, '_tile_loaded', False): |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
558 # Load tile now, if needed |
|
2f1efff066b3
Eliminated the need to use ttk.__loadtk__ and the problems related it.
Guilherme Polo <ggpolo@gmail.com>
parents:
51131
diff
changeset
|
559 _load_tile(master) |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
560 Tkinter.Widget.__init__(self, master, widgetname, kw=kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
561 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
562 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
563 def identify(self, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
564 """Returns the name of the element at position x, y, or the empty |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
565 string if the point does not lie within any element. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
566 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
567 x and y are pixel coordinates relative to the widget.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
568 return self.tk.call(self._w, "identify", x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
569 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
570 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
571 def instate(self, statespec, callback=None, *args, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
572 """Test the widget's state. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
573 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
574 If callback is not specified, returns True if the widget state |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
575 matches statespec and False otherwise. If callback is specified, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
576 then it will be invoked with *args, **kw if the widget state |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
577 matches statespec. statespec is expected to be a sequence.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
578 ret = self.tk.call(self._w, "instate", ' '.join(statespec)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
579 if ret and callback: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
580 return callback(*args, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
581 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
582 return bool(ret) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
583 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
584 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
585 def state(self, statespec=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
586 """Modify or inquire widget state. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
587 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
588 Widget state is returned if statespec is None, otherwise it is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
589 set according to the statespec flags and then a new state spec |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
590 is returned indicating which flags were changed. statespec is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
591 expected to be a sequence.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
592 if statespec is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
593 statespec = ' '.join(statespec) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
594 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
595 return self.tk.splitlist(str(self.tk.call(self._w, "state", statespec))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
596 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
597 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
598 class Button(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
599 """Ttk Button widget, displays a textual label and/or image, and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
600 evaluates a command when pressed.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
601 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
602 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
603 """Construct a Ttk Button widget with the parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
604 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
605 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
606 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
607 class, compound, cursor, image, state, style, takefocus, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
608 text, textvariable, underline, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
609 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
610 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
611 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
612 command, default, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
613 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
614 Widget.__init__(self, master, "ttk::button", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
615 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
616 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
617 def invoke(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
618 """Invokes the command associated with the button.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
619 return self.tk.call(self._w, "invoke") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
620 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
621 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
622 class Checkbutton(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
623 """Ttk Checkbutton widget which is either in on- or off-state.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
624 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
625 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
626 """Construct a Ttk Checkbutton widget with the parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
627 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
628 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
629 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
630 class, compound, cursor, image, state, style, takefocus, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
631 text, textvariable, underline, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
632 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
633 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
634 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
635 command, offvalue, onvalue, variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
636 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
637 Widget.__init__(self, master, "ttk::checkbutton", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
638 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
639 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
640 def invoke(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
641 """Toggles between the selected and deselected states and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
642 invokes the associated command. If the widget is currently |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
643 selected, sets the option variable to the offvalue option |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
644 and deselects the widget; otherwise, sets the option variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
645 to the option onvalue. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
646 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
647 Returns the result of the associated command.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
648 return self.tk.call(self._w, "invoke") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
649 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
650 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
651 class Entry(Widget, Tkinter.Entry): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
652 """Ttk Entry widget displays a one-line text string and allows that |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
653 string to be edited by the user.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
654 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
655 def __init__(self, master=None, widget=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
656 """Constructs a Ttk Entry widget with the parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
657 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
658 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
659 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
660 class, cursor, style, takefocus, xscrollcommand |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
661 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
662 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
663 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
664 exportselection, invalidcommand, justify, show, state, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
665 textvariable, validate, validatecommand, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
666 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
667 VALIDATION MODES |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
668 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
669 none, key, focus, focusin, focusout, all |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
670 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
671 Widget.__init__(self, master, widget or "ttk::entry", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
672 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
673 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
674 def bbox(self, index): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
675 """Return a tuple of (x, y, width, height) which describes the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
676 bounding box of the character given by index.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
677 return self.tk.call(self._w, "bbox", index) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
678 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
679 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
680 def identify(self, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
681 """Returns the name of the element at position x, y, or the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
682 empty string if the coordinates are outside the window.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
683 return self.tk.call(self._w, "identify", x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
684 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
685 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
686 def validate(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
687 """Force revalidation, independent of the conditions specified |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
688 by the validate option. Returns False if validation fails, True |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
689 if it succeeds. Sets or clears the invalid state accordingly.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
690 return bool(self.tk.call(self._w, "validate")) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
691 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
692 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
693 class Combobox(Entry): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
694 """Ttk Combobox widget combines a text field with a pop-down list of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
695 values.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
696 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
697 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
698 """Construct a Ttk Combobox widget with the parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
699 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
700 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
701 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
702 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
703 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
704 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
705 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
706 exportselection, justify, height, postcommand, state, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
707 textvariable, values, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
708 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
709 # The "values" option may need special formatting, so leave to |
|
68588
cd8d3c2d3bce
#11565: Fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
68503
diff
changeset
|
710 # _format_optdict the responsibility to format it |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
711 if "values" in kw: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
712 kw["values"] = _format_optdict({'v': kw["values"]})[1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
713 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
714 Entry.__init__(self, master, "ttk::combobox", **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
715 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
716 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
717 def __setitem__(self, item, value): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
718 if item == "values": |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
719 value = _format_optdict({item: value})[1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
720 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
721 Entry.__setitem__(self, item, value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
722 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
723 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
724 def configure(self, cnf=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
725 """Custom Combobox configure, created to properly format the values |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
726 option.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
727 if "values" in kw: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
728 kw["values"] = _format_optdict({'v': kw["values"]})[1] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
729 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
730 return Entry.configure(self, cnf, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
731 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
732 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
733 def current(self, newindex=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
734 """If newindex is supplied, sets the combobox value to the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
735 element at position newindex in the list of values. Otherwise, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
736 returns the index of the current value in the list of values |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
737 or -1 if the current value does not appear in the list.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
738 return self.tk.call(self._w, "current", newindex) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
739 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
740 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
741 def set(self, value): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
742 """Sets the value of the combobox to value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
743 self.tk.call(self._w, "set", value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
744 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
745 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
746 class Frame(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
747 """Ttk Frame widget is a container, used to group other widgets |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
748 together.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
749 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
750 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
751 """Construct a Ttk Frame with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
752 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
753 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
754 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
755 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
756 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
757 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
758 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
759 borderwidth, relief, padding, width, height |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
760 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
761 Widget.__init__(self, master, "ttk::frame", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
762 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
763 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
764 class Label(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
765 """Ttk Label widget displays a textual label and/or image.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
766 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
767 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
768 """Construct a Ttk Label with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
769 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
770 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
771 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
772 class, compound, cursor, image, style, takefocus, text, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
773 textvariable, underline, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
774 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
775 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
776 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
777 anchor, background, font, foreground, justify, padding, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
778 relief, text, wraplength |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
779 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
780 Widget.__init__(self, master, "ttk::label", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
781 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
782 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
783 class Labelframe(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
784 """Ttk Labelframe widget is a container used to group other widgets |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
785 together. It has an optional label, which may be a plain text string |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
786 or another widget.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
787 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
788 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
789 """Construct a Ttk Labelframe with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
790 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
791 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
792 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
793 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
794 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
795 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
796 labelanchor, text, underline, padding, labelwidget, width, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
797 height |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
798 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
799 Widget.__init__(self, master, "ttk::labelframe", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
800 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
801 LabelFrame = Labelframe # Tkinter name compatibility |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
802 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
803 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
804 class Menubutton(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
805 """Ttk Menubutton widget displays a textual label and/or image, and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
806 displays a menu when pressed.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
807 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
808 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
809 """Construct a Ttk Menubutton with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
810 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
811 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
812 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
813 class, compound, cursor, image, state, style, takefocus, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
814 text, textvariable, underline, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
815 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
816 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
817 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
818 direction, menu |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
819 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
820 Widget.__init__(self, master, "ttk::menubutton", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
821 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
822 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
823 class Notebook(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
824 """Ttk Notebook widget manages a collection of windows and displays |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
825 a single one at a time. Each child window is associated with a tab, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
826 which the user may select to change the currently-displayed window.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
827 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
828 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
829 """Construct a Ttk Notebook with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
830 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
831 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
832 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
833 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
834 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
835 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
836 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
837 height, padding, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
838 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
839 TAB OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
840 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
841 state, sticky, padding, text, image, compound, underline |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
842 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
843 TAB IDENTIFIERS (tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
844 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
845 The tab_id argument found in several methods may take any of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
846 the following forms: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
847 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
848 * An integer between zero and the number of tabs |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
849 * The name of a child window |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
850 * A positional specification of the form "@x,y", which |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
851 defines the tab |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
852 * The string "current", which identifies the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
853 currently-selected tab |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
854 * The string "end", which returns the number of tabs (only |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
855 valid for method index) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
856 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
857 Widget.__init__(self, master, "ttk::notebook", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
858 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
859 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
860 def add(self, child, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
861 """Adds a new tab to the notebook. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
862 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
863 If window is currently managed by the notebook but hidden, it is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
864 restored to its previous position.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
865 self.tk.call(self._w, "add", child, *(_format_optdict(kw))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
866 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
867 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
868 def forget(self, tab_id): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
869 """Removes the tab specified by tab_id, unmaps and unmanages the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
870 associated window.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
871 self.tk.call(self._w, "forget", tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
872 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
873 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
874 def hide(self, tab_id): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
875 """Hides the tab specified by tab_id. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
876 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
877 The tab will not be displayed, but the associated window remains |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
878 managed by the notebook and its configuration remembered. Hidden |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
879 tabs may be restored with the add command.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
880 self.tk.call(self._w, "hide", tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
881 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
882 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
883 def identify(self, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
884 """Returns the name of the tab element at position x, y, or the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
885 empty string if none.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
886 return self.tk.call(self._w, "identify", x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
887 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
888 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
889 def index(self, tab_id): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
890 """Returns the numeric index of the tab specified by tab_id, or |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
891 the total number of tabs if tab_id is the string "end".""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
892 return self.tk.call(self._w, "index", tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
893 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
894 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
895 def insert(self, pos, child, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
896 """Inserts a pane at the specified position. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
897 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
898 pos is either the string end, an integer index, or the name of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
899 a managed child. If child is already managed by the notebook, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
900 moves it to the specified position.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
901 self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
902 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
903 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
904 def select(self, tab_id=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
905 """Selects the specified tab. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
906 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
907 The associated child window will be displayed, and the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
908 previously-selected window (if different) is unmapped. If tab_id |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
909 is omitted, returns the widget name of the currently selected |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
910 pane.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
911 return self.tk.call(self._w, "select", tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
912 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
913 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
914 def tab(self, tab_id, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
915 """Query or modify the options of the specific tab_id. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
916 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
917 If kw is not given, returns a dict of the tab option values. If option |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
918 is specified, returns the value of that option. Otherwise, sets the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
919 options to the corresponding values.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
920 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
921 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
922 return _val_or_dict(kw, self.tk.call, self._w, "tab", tab_id) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
923 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
924 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
925 def tabs(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
926 """Returns a list of windows managed by the notebook.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
927 return self.tk.call(self._w, "tabs") or () |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
928 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
929 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
930 def enable_traversal(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
931 """Enable keyboard traversal for a toplevel window containing |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
932 this notebook. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
933 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
934 This will extend the bindings for the toplevel window containing |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
935 this notebook as follows: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
936 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
937 Control-Tab: selects the tab following the currently selected |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
938 one |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
939 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
940 Shift-Control-Tab: selects the tab preceding the currently |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
941 selected one |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
942 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
943 Alt-K: where K is the mnemonic (underlined) character of any |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
944 tab, will select that tab. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
945 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
946 Multiple notebooks in a single toplevel may be enabled for |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
947 traversal, including nested notebooks. However, notebook traversal |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
948 only works properly if all panes are direct children of the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
949 notebook.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
950 # The only, and good, difference I see is about mnemonics, which works |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
951 # after calling this method. Control-Tab and Shift-Control-Tab always |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
952 # works (here at least). |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
953 self.tk.call("ttk::notebook::enableTraversal", self._w) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
954 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
955 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
956 class Panedwindow(Widget, Tkinter.PanedWindow): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
957 """Ttk Panedwindow widget displays a number of subwindows, stacked |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
958 either vertically or horizontally.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
959 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
960 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
961 """Construct a Ttk Panedwindow with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
962 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
963 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
964 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
965 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
966 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
967 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
968 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
969 orient, width, height |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
970 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
971 PANE OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
972 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
973 weight |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
974 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
975 Widget.__init__(self, master, "ttk::panedwindow", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
976 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
977 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
978 forget = Tkinter.PanedWindow.forget # overrides Pack.forget |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
979 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
980 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
981 def insert(self, pos, child, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
982 """Inserts a pane at the specified positions. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
983 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
984 pos is either the string end, and integer index, or the name |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
985 of a child. If child is already managed by the paned window, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
986 moves it to the specified position.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
987 self.tk.call(self._w, "insert", pos, child, *(_format_optdict(kw))) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
988 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
989 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
990 def pane(self, pane, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
991 """Query or modify the options of the specified pane. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
992 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
993 pane is either an integer index or the name of a managed subwindow. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
994 If kw is not given, returns a dict of the pane option values. If |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
995 option is specified then the value for that option is returned. |
|
68503
ee5350f1d0c2
#11515: fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55640
diff
changeset
|
996 Otherwise, sets the options to the corresponding values.""" |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
997 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
998 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
999 return _val_or_dict(kw, self.tk.call, self._w, "pane", pane) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1000 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1001 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1002 def sashpos(self, index, newpos=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1003 """If newpos is specified, sets the position of sash number index. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1004 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1005 May adjust the positions of adjacent sashes to ensure that |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1006 positions are monotonically increasing. Sash positions are further |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1007 constrained to be between 0 and the total size of the widget. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1008 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1009 Returns the new position of sash number index.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1010 return self.tk.call(self._w, "sashpos", index, newpos) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1011 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1012 PanedWindow = Panedwindow # Tkinter name compatibility |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1013 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1014 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1015 class Progressbar(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1016 """Ttk Progressbar widget shows the status of a long-running |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1017 operation. They can operate in two modes: determinate mode shows the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1018 amount completed relative to the total amount of work to be done, and |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1019 indeterminate mode provides an animated display to let the user know |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1020 that something is happening.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1021 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1022 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1023 """Construct a Ttk Progressbar with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1024 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1025 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1026 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1027 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1028 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1029 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1030 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1031 orient, length, mode, maximum, value, variable, phase |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1032 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1033 Widget.__init__(self, master, "ttk::progressbar", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1034 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1035 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1036 def start(self, interval=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1037 """Begin autoincrement mode: schedules a recurring timer event |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1038 that calls method step every interval milliseconds. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1039 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1040 interval defaults to 50 milliseconds (20 steps/second) if ommited.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1041 self.tk.call(self._w, "start", interval) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1042 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1043 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1044 def step(self, amount=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1045 """Increments the value option by amount. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1046 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1047 amount defaults to 1.0 if omitted.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1048 self.tk.call(self._w, "step", amount) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1049 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1050 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1051 def stop(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1052 """Stop autoincrement mode: cancels any recurring timer event |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1053 initiated by start.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1054 self.tk.call(self._w, "stop") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1055 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1056 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1057 class Radiobutton(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1058 """Ttk Radiobutton widgets are used in groups to show or change a |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1059 set of mutually-exclusive options.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1060 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1061 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1062 """Construct a Ttk Radiobutton with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1063 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1064 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1065 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1066 class, compound, cursor, image, state, style, takefocus, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1067 text, textvariable, underline, width |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1068 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1069 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1070 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1071 command, value, variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1072 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1073 Widget.__init__(self, master, "ttk::radiobutton", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1074 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1075 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1076 def invoke(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1077 """Sets the option variable to the option value, selects the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1078 widget, and invokes the associated command. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1079 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1080 Returns the result of the command, or an empty string if |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1081 no command is specified.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1082 return self.tk.call(self._w, "invoke") |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1083 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1084 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1085 class Scale(Widget, Tkinter.Scale): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1086 """Ttk Scale widget is typically used to control the numeric value of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1087 a linked variable that varies uniformly over some range.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1088 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1089 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1090 """Construct a Ttk Scale with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1091 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1092 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1093 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1094 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1095 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1096 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1097 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1098 command, from, length, orient, to, value, variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1099 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1100 Widget.__init__(self, master, "ttk::scale", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1101 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1102 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1103 def configure(self, cnf=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1104 """Modify or query scale options. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1105 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1106 Setting a value for any of the "from", "from_" or "to" options |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1107 generates a <<RangeChanged>> event.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1108 if cnf: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1109 kw.update(cnf) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1110 Widget.configure(self, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1111 if any(['from' in kw, 'from_' in kw, 'to' in kw]): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1112 self.event_generate('<<RangeChanged>>') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1113 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1114 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1115 def get(self, x=None, y=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1116 """Get the current value of the value option, or the value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1117 corresponding to the coordinates x, y if they are specified. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1118 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1119 x and y are pixel coordinates relative to the scale widget |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1120 origin.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1121 return self.tk.call(self._w, 'get', x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1122 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1123 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1124 class Scrollbar(Widget, Tkinter.Scrollbar): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1125 """Ttk Scrollbar controls the viewport of a scrollable widget.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1126 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1127 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1128 """Construct a Ttk Scrollbar with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1129 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1130 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1131 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1132 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1133 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1134 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1135 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1136 command, orient |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1137 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1138 Widget.__init__(self, master, "ttk::scrollbar", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1139 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1140 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1141 class Separator(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1142 """Ttk Separator widget displays a horizontal or vertical separator |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1143 bar.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1144 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1145 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1146 """Construct a Ttk Separator with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1147 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1148 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1149 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1150 class, cursor, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1151 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1152 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1153 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1154 orient |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1155 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1156 Widget.__init__(self, master, "ttk::separator", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1157 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1158 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1159 class Sizegrip(Widget): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1160 """Ttk Sizegrip allows the user to resize the containing toplevel |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1161 window by pressing and dragging the grip.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1162 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1163 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1164 """Construct a Ttk Sizegrip with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1165 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1166 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1167 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1168 class, cursor, state, style, takefocus |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1169 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1170 Widget.__init__(self, master, "ttk::sizegrip", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1171 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1172 |
|
55640
b7a571d4aaa7
Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents:
53735
diff
changeset
|
1173 class Treeview(Widget, Tkinter.XView, Tkinter.YView): |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1174 """Ttk Treeview widget displays a hierarchical collection of items. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1175 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1176 Each item has a textual label, an optional image, and an optional list |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1177 of data values. The data values are displayed in successive columns |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1178 after the tree label.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1179 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1180 def __init__(self, master=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1181 """Construct a Ttk Treeview with parent master. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1182 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1183 STANDARD OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1184 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1185 class, cursor, style, takefocus, xscrollcommand, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1186 yscrollcommand |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1187 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1188 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1189 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1190 columns, displaycolumns, height, padding, selectmode, show |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1191 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1192 ITEM OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1193 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1194 text, image, values, open, tags |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1195 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1196 TAG OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1197 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1198 foreground, background, font, image |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1199 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1200 Widget.__init__(self, master, "ttk::treeview", kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1201 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1202 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1203 def bbox(self, item, column=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1204 """Returns the bounding box (relative to the treeview widget's |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1205 window) of the specified item in the form x y width height. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1206 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1207 If column is specified, returns the bounding box of that cell. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1208 If the item is not visible (i.e., if it is a descendant of a |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1209 closed item or is scrolled offscreen), returns an empty string.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1210 return self.tk.call(self._w, "bbox", item, column) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1211 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1212 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1213 def get_children(self, item=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1214 """Returns a tuple of children belonging to item. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1215 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1216 If item is not specified, returns root children.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1217 return self.tk.call(self._w, "children", item or '') or () |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1218 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1219 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1220 def set_children(self, item, *newchildren): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1221 """Replaces item's child with newchildren. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1222 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1223 Children present in item that are not present in newchildren |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1224 are detached from tree. No items in newchildren may be an |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1225 ancestor of item.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1226 self.tk.call(self._w, "children", item, newchildren) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1227 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1228 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1229 def column(self, column, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1230 """Query or modify the options for the specified column. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1231 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1232 If kw is not given, returns a dict of the column option values. If |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1233 option is specified then the value for that option is returned. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1234 Otherwise, sets the options to the corresponding values.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1235 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1236 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1237 return _val_or_dict(kw, self.tk.call, self._w, "column", column) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1238 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1239 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1240 def delete(self, *items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1241 """Delete all specified items and all their descendants. The root |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1242 item may not be deleted.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1243 self.tk.call(self._w, "delete", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1244 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1245 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1246 def detach(self, *items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1247 """Unlinks all of the specified items from the tree. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1248 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1249 The items and all of their descendants are still present, and may |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1250 be reinserted at another point in the tree, but will not be |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1251 displayed. The root item may not be detached.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1252 self.tk.call(self._w, "detach", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1253 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1254 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1255 def exists(self, item): |
|
76104
9b472b24e5c9
Transplant 45287f2799f5 from default branch.
Georg Brandl <georg@python.org>
parents:
68588
diff
changeset
|
1256 """Returns True if the specified item is present in the tree, |
|
51131
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1257 False otherwise.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1258 return bool(self.tk.call(self._w, "exists", item)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1259 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1260 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1261 def focus(self, item=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1262 """If item is specified, sets the focus item to item. Otherwise, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1263 returns the current focus item, or '' if there is none.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1264 return self.tk.call(self._w, "focus", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1265 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1266 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1267 def heading(self, column, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1268 """Query or modify the heading options for the specified column. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1269 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1270 If kw is not given, returns a dict of the heading option values. If |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1271 option is specified then the value for that option is returned. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1272 Otherwise, sets the options to the corresponding values. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1273 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1274 Valid options/values are: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1275 text: text |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1276 The text to display in the column heading |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1277 image: image_name |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1278 Specifies an image to display to the right of the column |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1279 heading |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1280 anchor: anchor |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1281 Specifies how the heading text should be aligned. One of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1282 the standard Tk anchor values |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1283 command: callback |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1284 A callback to be invoked when the heading label is |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1285 pressed. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1286 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1287 To configure the tree column heading, call this with column = "#0" """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1288 cmd = kw.get('command') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1289 if cmd and not isinstance(cmd, basestring): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1290 # callback not registered yet, do it now |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1291 kw['command'] = self.master.register(cmd, self._substitute) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1292 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1293 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1294 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1295 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1296 return _val_or_dict(kw, self.tk.call, self._w, 'heading', column) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1297 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1298 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1299 def identify(self, component, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1300 """Returns a description of the specified component under the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1301 point given by x and y, or the empty string if no such component |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1302 is present at that position.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1303 return self.tk.call(self._w, "identify", component, x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1304 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1305 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1306 def identify_row(self, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1307 """Returns the item ID of the item at position y.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1308 return self.identify("row", 0, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1309 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1310 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1311 def identify_column(self, x): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1312 """Returns the data column identifier of the cell at position x. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1313 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1314 The tree column has ID #0.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1315 return self.identify("column", x, 0) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1316 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1317 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1318 def identify_region(self, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1319 """Returns one of: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1320 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1321 heading: Tree heading area. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1322 separator: Space between two columns headings; |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1323 tree: The tree area. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1324 cell: A data cell. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1325 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1326 * Availability: Tk 8.6""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1327 return self.identify("region", x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1328 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1329 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1330 def identify_element(self, x, y): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1331 """Returns the element at position x, y. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1332 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1333 * Availability: Tk 8.6""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1334 return self.identify("element", x, y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1335 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1336 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1337 def index(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1338 """Returns the integer index of item within its parent's list |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1339 of children.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1340 return self.tk.call(self._w, "index", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1341 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1342 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1343 def insert(self, parent, index, iid=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1344 """Creates a new item and return the item identifier of the newly |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1345 created item. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1346 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1347 parent is the item ID of the parent item, or the empty string |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1348 to create a new top-level item. index is an integer, or the value |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1349 end, specifying where in the list of parent's children to insert |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1350 the new item. If index is less than or equal to zero, the new node |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1351 is inserted at the beginning, if index is greater than or equal to |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1352 the current number of children, it is inserted at the end. If iid |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1353 is specified, it is used as the item identifier, iid must not |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1354 already exist in the tree. Otherwise, a new unique identifier |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1355 is generated.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1356 opts = _format_optdict(kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1357 if iid: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1358 res = self.tk.call(self._w, "insert", parent, index, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1359 "-id", iid, *opts) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1360 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1361 res = self.tk.call(self._w, "insert", parent, index, *opts) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1362 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1363 return res |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1364 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1365 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1366 def item(self, item, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1367 """Query or modify the options for the specified item. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1368 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1369 If no options are given, a dict with options/values for the item |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1370 is returned. If option is specified then the value for that option |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1371 is returned. Otherwise, sets the options to the corresponding |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1372 values as given by kw.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1373 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1374 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1375 return _val_or_dict(kw, self.tk.call, self._w, "item", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1376 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1377 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1378 def move(self, item, parent, index): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1379 """Moves item to position index in parent's list of children. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1380 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1381 It is illegal to move an item under one of its descendants. If |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1382 index is less than or equal to zero, item is moved to the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1383 beginning, if greater than or equal to the number of children, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1384 it is moved to the end. If item was detached it is reattached.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1385 self.tk.call(self._w, "move", item, parent, index) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1386 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1387 reattach = move # A sensible method name for reattaching detached items |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1388 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1389 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1390 def next(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1391 """Returns the identifier of item's next sibling, or '' if item |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1392 is the last child of its parent.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1393 return self.tk.call(self._w, "next", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1394 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1395 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1396 def parent(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1397 """Returns the ID of the parent of item, or '' if item is at the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1398 top level of the hierarchy.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1399 return self.tk.call(self._w, "parent", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1400 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1401 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1402 def prev(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1403 """Returns the identifier of item's previous sibling, or '' if |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1404 item is the first child of its parent.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1405 return self.tk.call(self._w, "prev", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1406 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1407 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1408 def see(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1409 """Ensure that item is visible. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1410 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1411 Sets all of item's ancestors open option to True, and scrolls |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1412 the widget if necessary so that item is within the visible |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1413 portion of the tree.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1414 self.tk.call(self._w, "see", item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1415 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1416 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1417 def selection(self, selop=None, items=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1418 """If selop is not specified, returns selected items.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1419 return self.tk.call(self._w, "selection", selop, items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1420 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1421 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1422 def selection_set(self, items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1423 """items becomes the new selection.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1424 self.selection("set", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1425 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1426 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1427 def selection_add(self, items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1428 """Add items to the selection.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1429 self.selection("add", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1430 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1431 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1432 def selection_remove(self, items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1433 """Remove items from the selection.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1434 self.selection("remove", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1435 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1436 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1437 def selection_toggle(self, items): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1438 """Toggle the selection state of each item in items.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1439 self.selection("toggle", items) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1440 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1441 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1442 def set(self, item, column=None, value=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1443 """With one argument, returns a dictionary of column/value pairs |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1444 for the specified item. With two arguments, returns the current |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1445 value of the specified column. With three arguments, sets the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1446 value of given column in given item to the specified value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1447 res = self.tk.call(self._w, "set", item, column, value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1448 if column is None and value is None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1449 return _dict_from_tcltuple(res, False) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1450 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1451 return res |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1452 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1453 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1454 def tag_bind(self, tagname, sequence=None, callback=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1455 """Bind a callback for the given event sequence to the tag tagname. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1456 When an event is delivered to an item, the callbacks for each |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1457 of the item's tags option are called.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1458 self._bind((self._w, "tag", "bind", tagname), sequence, callback, add=0) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1459 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1460 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1461 def tag_configure(self, tagname, option=None, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1462 """Query or modify the options for the specified tagname. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1463 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1464 If kw is not given, returns a dict of the option settings for tagname. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1465 If option is specified, returns the value for that option for the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1466 specified tagname. Otherwise, sets the options to the corresponding |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1467 values for the given tagname.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1468 if option is not None: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1469 kw[option] = None |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1470 return _val_or_dict(kw, self.tk.call, self._w, "tag", "configure", |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1471 tagname) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1472 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1473 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1474 def tag_has(self, tagname, item=None): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1475 """If item is specified, returns 1 or 0 depending on whether the |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1476 specified item has the given tagname. Otherwise, returns a list of |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1477 all items which have the specified tag. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1478 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1479 * Availability: Tk 8.6""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1480 return self.tk.call(self._w, "tag", "has", tagname, item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1481 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1482 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1483 # Extensions |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1484 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1485 class LabeledScale(Frame, object): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1486 """A Ttk Scale widget with a Ttk Label widget indicating its |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1487 current value. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1488 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1489 The Ttk Scale can be accessed through instance.scale, and Ttk Label |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1490 can be accessed through instance.label""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1491 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1492 def __init__(self, master=None, variable=None, from_=0, to=10, **kw): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1493 """Construct an horizontal LabeledScale with parent master, a |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1494 variable to be associated with the Ttk Scale widget and its range. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1495 If variable is not specified, a Tkinter.IntVar is created. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1496 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1497 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1498 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1499 compound: 'top' or 'bottom' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1500 Specifies how to display the label relative to the scale. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1501 Defaults to 'top'. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1502 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1503 self._label_top = kw.pop('compound', 'top') == 'top' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1504 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1505 Frame.__init__(self, master, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1506 self._variable = variable or Tkinter.IntVar(master) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1507 self._variable.set(from_) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1508 self._last_valid = from_ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1509 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1510 self.label = Label(self) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1511 self.scale = Scale(self, variable=self._variable, from_=from_, to=to) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1512 self.scale.bind('<<RangeChanged>>', self._adjust) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1513 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1514 # position scale and label according to the compound option |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1515 scale_side = 'bottom' if self._label_top else 'top' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1516 label_side = 'top' if scale_side == 'bottom' else 'bottom' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1517 self.scale.pack(side=scale_side, fill='x') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1518 tmp = Label(self).pack(side=label_side) # place holder |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1519 self.label.place(anchor='n' if label_side == 'top' else 's') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1520 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1521 # update the label as scale or variable changes |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1522 self.__tracecb = self._variable.trace_variable('w', self._adjust) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1523 self.bind('<Configure>', self._adjust) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1524 self.bind('<Map>', self._adjust) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1525 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1526 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1527 def destroy(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1528 """Destroy this widget and possibly its associated variable.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1529 try: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1530 self._variable.trace_vdelete('w', self.__tracecb) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1531 except AttributeError: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1532 # widget has been destroyed already |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1533 pass |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1534 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1535 del self._variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1536 Frame.destroy(self) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1537 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1538 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1539 def _adjust(self, *args): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1540 """Adjust the label position according to the scale.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1541 def adjust_label(): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1542 self.update_idletasks() # "force" scale redraw |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1543 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1544 x, y = self.scale.coords() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1545 if self._label_top: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1546 y = self.scale.winfo_y() - self.label.winfo_reqheight() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1547 else: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1548 y = self.scale.winfo_reqheight() + self.label.winfo_reqheight() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1549 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1550 self.label.place_configure(x=x, y=y) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1551 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1552 from_, to = self.scale['from'], self.scale['to'] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1553 if to < from_: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1554 from_, to = to, from_ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1555 newval = self._variable.get() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1556 if not from_ <= newval <= to: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1557 # value outside range, set value back to the last valid one |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1558 self.value = self._last_valid |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1559 return |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1560 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1561 self._last_valid = newval |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1562 self.label['text'] = newval |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1563 self.after_idle(adjust_label) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1564 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1565 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1566 def _get_value(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1567 """Return current scale value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1568 return self._variable.get() |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1569 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1570 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1571 def _set_value(self, val): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1572 """Set new scale value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1573 self._variable.set(val) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1574 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1575 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1576 value = property(_get_value, _set_value) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1577 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1578 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1579 class OptionMenu(Menubutton): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1580 """Themed OptionMenu, based after Tkinter's OptionMenu, which allows |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1581 the user to select a value from a menu.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1582 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1583 def __init__(self, master, variable, default=None, *values, **kwargs): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1584 """Construct a themed OptionMenu widget with master as the parent, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1585 the resource textvariable set to variable, the initially selected |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1586 value specified by the default parameter, the menu values given by |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1587 *values and additional keywords. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1588 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1589 WIDGET-SPECIFIC OPTIONS |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1590 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1591 style: stylename |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1592 Menubutton style. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1593 direction: 'above', 'below', 'left', 'right', or 'flush' |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1594 Menubutton direction. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1595 command: callback |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1596 A callback that will be invoked after selecting an item. |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1597 """ |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1598 kw = {'textvariable': variable, 'style': kwargs.pop('style', None), |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1599 'direction': kwargs.pop('direction', None)} |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1600 Menubutton.__init__(self, master, **kw) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1601 self['menu'] = Tkinter.Menu(self, tearoff=False) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1602 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1603 self._variable = variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1604 self._callback = kwargs.pop('command', None) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1605 if kwargs: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1606 raise Tkinter.TclError('unknown option -%s' % ( |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1607 kwargs.iterkeys().next())) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1608 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1609 self.set_menu(default, *values) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1610 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1611 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1612 def __getitem__(self, item): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1613 if item == 'menu': |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1614 return self.nametowidget(Menubutton.__getitem__(self, item)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1615 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1616 return Menubutton.__getitem__(self, item) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1617 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1618 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1619 def set_menu(self, default=None, *values): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1620 """Build a new menu of radiobuttons with *values and optionally |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1621 a default value.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1622 menu = self['menu'] |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1623 menu.delete(0, 'end') |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1624 for val in values: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1625 menu.add_radiobutton(label=val, |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1626 command=Tkinter._setit(self._variable, val, self._callback)) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1627 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1628 if default: |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1629 self._variable.set(default) |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1630 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1631 |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1632 def destroy(self): |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1633 """Destroy this widget and its associated variable.""" |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1634 del self._variable |
|
c101f78aed8b
Added the ttk module. See issue #2983: Ttk support for Tkinter.
Guilherme Polo <ggpolo@gmail.com>
parents:
diff
changeset
|
1635 Menubutton.destroy(self) |
