annotate Lib/tkinter/__init__.py @ 79691:05c8928362ee

Merge __next__ method link fixes with 3.3.
author Ezio Melotti <ezio.melotti@gmail.com>
date Fri, 12 Oct 2012 13:46:37 +0300
parents 83da5729e362
children 657caf5d3eb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1 """Wrapper functions for Tcl/Tk.
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
3 Tkinter provides classes which allow the display, positioning and
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
4 control of widgets. Toplevel widgets are Tk and Toplevel. Other
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
5 widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
6 Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
7 LabelFrame and PanedWindow.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
8
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
9 Properties of the widgets are specified with keyword arguments.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
10 Keyword arguments have the same name as the corresponding resource
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
11 under Tk.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
12
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
13 Widgets are positioned with one of the geometry managers Place, Pack
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
14 or Grid. These managers can be called with methods place, pack, grid
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
15 available in every Widget.
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
16
19638
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
17 Actions are bound to events by resources (e.g. keyword argument
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
18 command) or with the method bind.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
19
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
20 Example (Hello, World):
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
21 import tkinter
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
22 from tkinter.constants import *
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
23 tk = tkinter.Tk()
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
24 frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
25 frame.pack(fill=BOTH,expand=1)
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
26 label = tkinter.Label(frame, text="Hello, World")
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
27 label.pack(fill=X, expand=1)
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
28 button = tkinter.Button(frame,text="Exit",command=tk.destroy)
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
29 button.pack(side=BOTTOM)
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
30 tk.mainloop()
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
31 """
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
32
9763
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
33 import sys
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
34 if sys.platform == "win32":
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
35 # Attempt to configure Tcl/Tk without requiring PATH
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
36 from tkinter import _fix
75864
d42f264f291e Issue #3035: Unused functions from tkinter are marked as pending peprecated.
Andrew Svetlov <andrew.svetlov@gmail.com>
parents: 75598
diff changeset
37
d42f264f291e Issue #3035: Unused functions from tkinter are marked as pending peprecated.
Andrew Svetlov <andrew.svetlov@gmail.com>
parents: 75598
diff changeset
38 import warnings
d42f264f291e Issue #3035: Unused functions from tkinter are marked as pending peprecated.
Andrew Svetlov <andrew.svetlov@gmail.com>
parents: 75598
diff changeset
39
9763
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
40 import _tkinter # If this fails your Python may not be configured for Tk
5123
05fffd55b014 Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents: 5096
diff changeset
41 TclError = _tkinter.TclError
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
42 from tkinter.constants import *
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 2585
diff changeset
43
75864
d42f264f291e Issue #3035: Unused functions from tkinter are marked as pending peprecated.
Andrew Svetlov <andrew.svetlov@gmail.com>
parents: 75598
diff changeset
44
26428
0103f0b75fe2 Rename want_objects to wantobjects throughout, for consistency.
Martin v. Löwis <martin@v.loewis.de>
parents: 26416
diff changeset
45 wantobjects = 1
26416
bd09e3a2d536 Patch #518625: Return objects in Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 25754
diff changeset
46
16517
eee67a84e5fa String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15540
diff changeset
47 TkVersion = float(_tkinter.TK_VERSION)
eee67a84e5fa String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15540
diff changeset
48 TclVersion = float(_tkinter.TCL_VERSION)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
5944
1bd68e4464ce Get READABLE c.s. from _tkinter instead of conditional definition.
Guido van Rossum <guido@python.org>
parents: 5868
diff changeset
50 READABLE = _tkinter.READABLE
1bd68e4464ce Get READABLE c.s. from _tkinter instead of conditional definition.
Guido van Rossum <guido@python.org>
parents: 5868
diff changeset
51 WRITABLE = _tkinter.WRITABLE
1bd68e4464ce Get READABLE c.s. from _tkinter instead of conditional definition.
Guido van Rossum <guido@python.org>
parents: 5868
diff changeset
52 EXCEPTION = _tkinter.EXCEPTION
6012
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
53
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
54
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
55 def _flatten(seq):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
56 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
57 res = ()
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
58 for item in seq:
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
59 if isinstance(item, (tuple, list)):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
60 res = res + _flatten(item)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
61 elif item is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
62 res = res + (item,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
63 return res
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
64
12953
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
65 try: _flatten = _tkinter._flatten
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
66 except AttributeError: pass
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
67
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
68 def _cnfmerge(cnfs):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
69 """Internal function."""
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
70 if isinstance(cnfs, dict):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
71 return cnfs
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
72 elif isinstance(cnfs, (type(None), str)):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
73 return cnfs
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
74 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
75 cnf = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
76 for c in _flatten(cnfs):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
77 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
78 cnf.update(c)
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
79 except (AttributeError, TypeError) as msg:
40775
4cdf21a0dbbc Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents: 40587
diff changeset
80 print("_cnfmerge: fallback due to:", msg)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
81 for k, v in c.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
82 cnf[k] = v
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
83 return cnf
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
84
12953
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
85 try: _cnfmerge = _tkinter._cnfmerge
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
86 except AttributeError: pass
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
87
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
88 class Event:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
89 """Container for the properties of an event.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
90
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
91 Instances of this type are generated if one of the following events occurs:
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
92
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
93 KeyPress, KeyRelease - for keyboard events
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
94 ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
95 Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
96 Colormap, Gravity, Reparent, Property, Destroy, Activate,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
97 Deactivate - for window events.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
98
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
99 If a callback function for one of these events is registered
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
100 using bind, bind_all, bind_class, or tag_bind, the callback is
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
101 called with an Event as first argument. It will have the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
102 following attributes (in braces are the event types for which
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
103 the attribute is valid):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
104
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
105 serial - serial number of event
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
106 num - mouse button pressed (ButtonPress, ButtonRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
107 focus - whether the window has the focus (Enter, Leave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
108 height - height of the exposed window (Configure, Expose)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
109 width - width of the exposed window (Configure, Expose)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
110 keycode - keycode of the pressed key (KeyPress, KeyRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
111 state - state of the event as a number (ButtonPress, ButtonRelease,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
112 Enter, KeyPress, KeyRelease,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
113 Leave, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
114 state - state as a string (Visibility)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
115 time - when the event occurred
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
116 x - x-position of the mouse
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
117 y - y-position of the mouse
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
118 x_root - x-position of the mouse on the screen
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
119 (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
120 y_root - y-position of the mouse on the screen
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
121 (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
122 char - pressed character (KeyPress, KeyRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
123 send_event - see X/Windows documentation
35850
f6d8b0de134a Fix typos.
Walter Dörwald <walter@livinglogic.de>
parents: 35282
diff changeset
124 keysym - keysym of the event as a string (KeyPress, KeyRelease)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
125 keysym_num - keysym of the event as a number (KeyPress, KeyRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
126 type - type of the event as a number
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
127 widget - widget in which the event occurred
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
128 delta - delta of wheel movement (MouseWheel)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
129 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
130 pass
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
131
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
132 _support_default_root = 1
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
133 _default_root = None
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
134
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
135 def NoDefaultRoot():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
136 """Inhibit setting of default root window.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
137
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
138 Call this function to inhibit that the first instance of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
139 Tk is used for windows without an explicit parent window.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
140 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
141 global _support_default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
142 _support_default_root = 0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
143 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
144 _default_root = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
145 del _default_root
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
146
1671
953e74eac006 Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents: 1669
diff changeset
147 def _tkerror(err):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
148 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
149 pass
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
150
1714
db0eaef42cb9 Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents: 1709
diff changeset
151 def _exit(code='0'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
152 """Internal function. Calling it will throw the exception SystemExit."""
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
153 raise SystemExit(code)
1714
db0eaef42cb9 Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents: 1709
diff changeset
154
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
155 _varnum = 0
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
156 class Variable:
28642
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
157 """Class to define value holders for e.g. buttons.
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
158
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
159 Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
160 that constrain the type of the value returned from get()."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
161 _default = ""
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
162 _tk = None
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
163 def __init__(self, master=None, value=None, name=None):
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
164 """Construct a variable
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
165
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
166 MASTER can be given as master widget.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
167 VALUE is an optional value (defaults to "")
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
168 NAME is an optional Tcl name (defaults to PY_VARnum).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
169
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
170 If NAME matches an existing variable and VALUE is omitted
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
171 then the existing value is retained.
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
172 """
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
173 # check for type of NAME parameter to override weird error message
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
174 # raised from Modules/_tkinter.c:SetVar like:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
175 # TypeError: setvar() takes exactly 3 arguments (2 given)
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
176 if name is not None and not isinstance(name, str):
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
177 raise TypeError("name must be a string")
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
178 global _varnum
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
179 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
180 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
181 self._master = master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
182 self._tk = master.tk
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
183 if name:
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
184 self._name = name
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
185 else:
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
186 self._name = 'PY_VAR' + repr(_varnum)
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
187 _varnum += 1
46222
aed698c8647b Merged revisions 62021,62029,62035-62038,62043-62044,62052-62053 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 44428
diff changeset
188 if value is not None:
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
189 self.initialize(value)
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
190 elif not self._tk.call("info", "exists", self._name):
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
191 self.initialize(self._default)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
192 def __del__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
193 """Unset the variable in Tcl."""
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
194 if (self._tk is not None and self._tk.call("info", "exists",
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
195 self._name)):
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
196 self._tk.globalunsetvar(self._name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
197 def __str__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
198 """Return the name of the variable in Tcl."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
199 return self._name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
200 def set(self, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
201 """Set the variable to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
202 return self._tk.globalsetvar(self._name, value)
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
203 initialize = set
28642
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
204 def get(self):
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
205 """Return value of variable."""
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
206 return self._tk.globalgetvar(self._name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
207 def trace_variable(self, mode, callback):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
208 """Define a trace callback for the variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
209
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
210 MODE is one of "r", "w", "u" for read, write, undefine.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
211 CALLBACK must be a function which is called when
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
212 the variable is read, written or undefined.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
213
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
214 Return the name of the callback.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
215 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
216 cbname = self._master._register(callback)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
217 self._tk.call("trace", "variable", self._name, mode, cbname)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
218 return cbname
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
219 trace = trace_variable
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
220 def trace_vdelete(self, mode, cbname):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
221 """Delete the trace callback for a variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
222
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
223 MODE is one of "r", "w", "u" for read, write, undefine.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
224 CBNAME is the name of the callback returned from trace_variable or trace.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
225 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
226 self._tk.call("trace", "vdelete", self._name, mode, cbname)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
227 self._master.deletecommand(cbname)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
228 def trace_vinfo(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
229 """Return all trace callback information."""
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
230 return [self._tk.split(x) for x in self._tk.splitlist(
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
231 self._tk.call("trace", "vinfo", self._name))]
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
232 def __eq__(self, other):
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
233 """Comparison for equality (==).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
234
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
235 Note: if the Variable's master matters to behavior
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
236 also compare self._master == other._master
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
237 """
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
238 return self.__class__.__name__ == other.__class__.__name__ \
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
239 and self._name == other._name
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
240
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
241 class StringVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
242 """Value holder for strings variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
243 _default = ""
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
244 def __init__(self, master=None, value=None, name=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
245 """Construct a string variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
246
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
247 MASTER can be given as master widget.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
248 VALUE is an optional value (defaults to "")
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
249 NAME is an optional Tcl name (defaults to PY_VARnum).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
250
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
251 If NAME matches an existing variable and VALUE is omitted
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
252 then the existing value is retained.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
253 """
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
254 Variable.__init__(self, master, value, name)
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
255
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
256 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
257 """Return value of variable as string."""
28639
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
258 value = self._tk.globalgetvar(self._name)
43577
ace45b361e87 Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents: 43020
diff changeset
259 if isinstance(value, str):
28639
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
260 return value
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
261 return str(value)
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
262
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
263 class IntVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
264 """Value holder for integer variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
265 _default = 0
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
266 def __init__(self, master=None, value=None, name=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
267 """Construct an integer variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
268
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
269 MASTER can be given as master widget.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
270 VALUE is an optional value (defaults to 0)
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
271 NAME is an optional Tcl name (defaults to PY_VARnum).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
272
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
273 If NAME matches an existing variable and VALUE is omitted
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
274 then the existing value is retained.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
275 """
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
276 Variable.__init__(self, master, value, name)
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
277
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
278 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
279 """Return the value of the variable as an integer."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
280 return getint(self._tk.globalgetvar(self._name))
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
281
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
282 class DoubleVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
283 """Value holder for float variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
284 _default = 0.0
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
285 def __init__(self, master=None, value=None, name=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
286 """Construct a float variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
287
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
288 MASTER can be given as master widget.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
289 VALUE is an optional value (defaults to 0.0)
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
290 NAME is an optional Tcl name (defaults to PY_VARnum).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
291
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
292 If NAME matches an existing variable and VALUE is omitted
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
293 then the existing value is retained.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
294 """
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
295 Variable.__init__(self, master, value, name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
296
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
297 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
298 """Return the value of the variable as a float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
299 return getdouble(self._tk.globalgetvar(self._name))
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
300
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
301 class BooleanVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
302 """Value holder for boolean variables."""
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
303 _default = False
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
304 def __init__(self, master=None, value=None, name=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
305 """Construct a boolean variable.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
306
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
307 MASTER can be given as master widget.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
308 VALUE is an optional value (defaults to False)
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
309 NAME is an optional Tcl name (defaults to PY_VARnum).
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
310
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
311 If NAME matches an existing variable and VALUE is omitted
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
312 then the existing value is retained.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
313 """
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
314 Variable.__init__(self, master, value, name)
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
315
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
316 def get(self):
28639
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
317 """Return the value of the variable as a bool."""
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
318 try:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
319 return self._tk.getboolean(self._tk.globalgetvar(self._name))
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
320 except TclError:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
321 raise ValueError("invalid literal for getboolean()")
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
322
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
323 def mainloop(n=0):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
324 """Run the main loop of Tcl."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
325 _default_root.tk.mainloop(n)
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
326
8209
34cca832a4af Another optimization, probably of negligeable effect: instead of
Guido van Rossum <guido@python.org>
parents: 8207
diff changeset
327 getint = int
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
328
8209
34cca832a4af Another optimization, probably of negligeable effect: instead of
Guido van Rossum <guido@python.org>
parents: 8207
diff changeset
329 getdouble = float
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
330
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
331 def getboolean(s):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
332 """Convert true and false to integer values 1 and 0."""
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
333 try:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
334 return _default_root.tk.getboolean(s)
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
335 except TclError:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
336 raise ValueError("invalid literal for getboolean()")
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
337
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
338 # Methods defined on both toplevel and interior widgets
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
339 class Misc:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
340 """Internal class.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
341
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
342 Base class which defines methods common for interior widgets."""
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
343
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
344 # XXX font command?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
345 _tclCommands = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
346 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
347 """Internal function.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
348
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
349 Delete all Tcl commands created for
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
350 this widget in the Tcl interpreter."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
351 if self._tclCommands is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
352 for name in self._tclCommands:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
353 #print '- Tkinter: deleted command', name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
354 self.tk.deletecommand(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
355 self._tclCommands = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
356 def deletecommand(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
357 """Internal function.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
358
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
359 Delete the Tcl command provided in NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
360 #print '- Tkinter: deleted command', name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
361 self.tk.deletecommand(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
362 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
363 self._tclCommands.remove(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
364 except ValueError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
365 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
366 def tk_strictMotif(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
367 """Set Tcl internal variable, whether the look and feel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
368 should adhere to Motif.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
369
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
370 A parameter of 1 means adhere to Motif (e.g. no color
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
371 change if mouse passes over slider).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
372 Returns the set value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
373 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
374 'set', 'tk_strictMotif', boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
375 def tk_bisque(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
376 """Change the color scheme to light brown as used in Tk 3.6 and before."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
377 self.tk.call('tk_bisque')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
378 def tk_setPalette(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
379 """Set a new color scheme for all widget elements.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
380
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
381 A single color as argument will cause that all colors of Tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
382 widget elements are derived from this.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
383 Alternatively several keyword parameters and its associated
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
384 colors can be given. The following keywords are valid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
385 activeBackground, foreground, selectColor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
386 activeForeground, highlightBackground, selectBackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
387 background, highlightColor, selectForeground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
388 disabledForeground, insertBackground, troughColor."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
389 self.tk.call(('tk_setPalette',)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
390 + _flatten(args) + _flatten(kw.items()))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
391 def tk_menuBar(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
392 """Do not use. Needed in Tk 3.6 and earlier."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
393 pass # obsolete since Tk 4.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
394 def wait_variable(self, name='PY_VAR'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
395 """Wait until the variable is modified.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
396
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
397 A parameter of type IntVar, StringVar, DoubleVar or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
398 BooleanVar must be given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
399 self.tk.call('tkwait', 'variable', name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
400 waitvar = wait_variable # XXX b/w compat
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
401 def wait_window(self, window=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
402 """Wait until a WIDGET is destroyed.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
403
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
404 If no parameter is given self is used."""
15540
9d43129c8c55 Update the code to better reflect recommended style:
Fred Drake <fdrake@acm.org>
parents: 15308
diff changeset
405 if window is None:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
406 window = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
407 self.tk.call('tkwait', 'window', window._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
408 def wait_visibility(self, window=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
409 """Wait until the visibility of a WIDGET changes
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
410 (e.g. it appears).
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
411
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
412 If no parameter is given self is used."""
15540
9d43129c8c55 Update the code to better reflect recommended style:
Fred Drake <fdrake@acm.org>
parents: 15308
diff changeset
413 if window is None:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
414 window = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
415 self.tk.call('tkwait', 'visibility', window._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
416 def setvar(self, name='PY_VAR', value='1'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
417 """Set Tcl variable NAME to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
418 self.tk.setvar(name, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
419 def getvar(self, name='PY_VAR'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
420 """Return value of Tcl variable NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
421 return self.tk.getvar(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
422 getint = int
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
423 getdouble = float
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
424 def getboolean(self, s):
28645
b9745cd791bf Remove extra space in docstring
Neal Norwitz <nnorwitz@gmail.com>
parents: 28642
diff changeset
425 """Return a boolean value for Tcl boolean values true and false given as parameter."""
75569
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
426 try:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
427 return self.tk.getboolean(s)
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
428 except TclError:
79bb99ec2464 Issue #1178863: Separate initialisation from setting when initializing
Martin v. Löwis <martin@v.loewis.de>
parents: 73345
diff changeset
429 raise ValueError("invalid literal for getboolean()")
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
430 def focus_set(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
431 """Direct input focus to this widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
432
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
433 If the application currently does not have the focus
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
434 this widget will get the focus if the application gets
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
435 the focus through the window manager."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
436 self.tk.call('focus', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
437 focus = focus_set # XXX b/w compat?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
438 def focus_force(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
439 """Direct input focus to this widget even if the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
440 application does not have the focus. Use with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
441 caution!"""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
442 self.tk.call('focus', '-force', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
443 def focus_get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
444 """Return the widget which has currently the focus in the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
445 application.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
446
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
447 Use focus_displayof to allow working with several
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
448 displays. Return None if application does not have
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
449 the focus."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
450 name = self.tk.call('focus')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
451 if name == 'none' or not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
452 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
453 def focus_displayof(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
454 """Return the widget which has currently the focus on the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
455 display where this widget is located.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
456
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
457 Return None if the application does not have the focus."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
458 name = self.tk.call('focus', '-displayof', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
459 if name == 'none' or not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
460 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
461 def focus_lastfor(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
462 """Return the widget which would have the focus if top level
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
463 for this widget gets the focus from the window manager."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
464 name = self.tk.call('focus', '-lastfor', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
465 if name == 'none' or not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
466 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
467 def tk_focusFollowsMouse(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
468 """The widget under mouse will get automatically focus. Can not
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
469 be disabled easily."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
470 self.tk.call('tk_focusFollowsMouse')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
471 def tk_focusNext(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
472 """Return the next widget in the focus order which follows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
473 widget which has currently the focus.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
474
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
475 The focus order first goes to the next child, then to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
476 the children of the child recursively and then to the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
477 next sibling which is higher in the stacking order. A
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
478 widget is omitted if it has the takefocus resource set
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
479 to 0."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
480 name = self.tk.call('tk_focusNext', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
481 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
482 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
483 def tk_focusPrev(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
484 """Return previous widget in the focus order. See tk_focusNext for details."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
485 name = self.tk.call('tk_focusPrev', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
486 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
487 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
488 def after(self, ms, func=None, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
489 """Call function once after given time.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
490
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
491 MS specifies the time in milliseconds. FUNC gives the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
492 function which shall be called. Additional parameters
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
493 are given as parameters to the function call. Return
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
494 identifier to cancel scheduling with after_cancel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
495 if not func:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
496 # I'd rather use time.sleep(ms*0.001)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
497 self.tk.call('after', ms)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
498 else:
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
499 def callit():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
500 try:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
501 func(*args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
502 finally:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
503 try:
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
504 self.deletecommand(name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
505 except TclError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
506 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
507 name = self._register(callit)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
508 return self.tk.call('after', ms, name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
509 def after_idle(self, func, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
510 """Call FUNC once if the Tcl main loop has no event to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
511 process.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
512
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
513 Return an identifier to cancel the scheduling with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
514 after_cancel."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
515 return self.after('idle', func, *args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
516 def after_cancel(self, id):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
517 """Cancel scheduling of function identified with ID.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
518
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
519 Identifier returned by after or after_idle must be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
520 given as first parameter."""
29372
20e1ad3ae8bb Patch #749191: Delete commands in after_cancel. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents: 29248
diff changeset
521 try:
29729
37216e1c6747 Fix SF bug #763637, 2.3b2 unpack tuple of wrong size in after_cancel
Neal Norwitz <nnorwitz@gmail.com>
parents: 29372
diff changeset
522 data = self.tk.call('after', 'info', id)
37216e1c6747 Fix SF bug #763637, 2.3b2 unpack tuple of wrong size in after_cancel
Neal Norwitz <nnorwitz@gmail.com>
parents: 29372
diff changeset
523 # In Tk 8.3, splitlist returns: (script, type)
37216e1c6747 Fix SF bug #763637, 2.3b2 unpack tuple of wrong size in after_cancel
Neal Norwitz <nnorwitz@gmail.com>
parents: 29372
diff changeset
524 # In Tk 8.4, splitlist may return (script, type) or (script,)
37216e1c6747 Fix SF bug #763637, 2.3b2 unpack tuple of wrong size in after_cancel
Neal Norwitz <nnorwitz@gmail.com>
parents: 29372
diff changeset
525 script = self.tk.splitlist(data)[0]
29372
20e1ad3ae8bb Patch #749191: Delete commands in after_cancel. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents: 29248
diff changeset
526 self.deletecommand(script)
20e1ad3ae8bb Patch #749191: Delete commands in after_cancel. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents: 29248
diff changeset
527 except TclError:
20e1ad3ae8bb Patch #749191: Delete commands in after_cancel. Will backport to 2.2.
Martin v. Löwis <martin@v.loewis.de>
parents: 29248
diff changeset
528 pass
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
529 self.tk.call('after', 'cancel', id)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
530 def bell(self, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
531 """Ring a display's bell."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
532 self.tk.call(('bell',) + self._displayof(displayof))
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
533
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
534 # Clipboard handling:
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
535 def clipboard_get(self, **kw):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
536 """Retrieve data from the clipboard on window's display.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
537
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
538 The window keyword defaults to the root window of the Tkinter
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
539 application.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
540
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
541 The type keyword specifies the form in which the data is
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
542 to be returned and should be an atom name such as STRING
76975
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
543 or FILE_NAME. Type defaults to STRING, except on X11, where the default
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
544 is to try UTF8_STRING and fall back to STRING.
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
545
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
546 This command is equivalent to:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
547
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
548 selection_get(CLIPBOARD)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
549 """
76975
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
550 if 'type' not in kw and self._windowingsystem == 'x11':
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
551 try:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
552 kw['type'] = 'UTF8_STRING'
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
553 return self.tk.call(('clipboard', 'get') + self._options(kw))
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
554 except TclError:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
555 del kw['type']
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
556 return self.tk.call(('clipboard', 'get') + self._options(kw))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 37042
diff changeset
557
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
558 def clipboard_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
559 """Clear the data in the Tk clipboard.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
560
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
561 A widget specified for the optional displayof keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
562 argument specifies the target display."""
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
563 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
564 self.tk.call(('clipboard', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
565 def clipboard_append(self, string, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
566 """Append STRING to the Tk clipboard.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
567
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
568 A widget specified at the optional displayof keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
569 argument specifies the target display. The clipboard
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
570 can be retrieved with selection_get."""
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
571 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
572 self.tk.call(('clipboard', 'append') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
573 + ('--', string))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
574 # XXX grab current w/o window argument
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
575 def grab_current(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
576 """Return widget which has currently the grab in this application
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
577 or None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
578 name = self.tk.call('grab', 'current', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
579 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
580 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
581 def grab_release(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
582 """Release grab for this widget if currently set."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
583 self.tk.call('grab', 'release', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
584 def grab_set(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
585 """Set grab for this widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
586
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
587 A grab directs all events to this and descendant
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
588 widgets in the application."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
589 self.tk.call('grab', 'set', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
590 def grab_set_global(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
591 """Set global grab for this widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
592
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
593 A global grab directs all events to this and
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
594 descendant widgets on the display. Use with caution -
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
595 other applications do not get events anymore."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
596 self.tk.call('grab', 'set', '-global', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
597 def grab_status(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
598 """Return None, "local" or "global" if this widget has
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
599 no, a local or a global grab."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
600 status = self.tk.call('grab', 'status', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
601 if status == 'none': status = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
602 return status
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
603 def option_add(self, pattern, value, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
604 """Set a VALUE (second parameter) for an option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
605 PATTERN (first parameter).
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
606
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
607 An optional third parameter gives the numeric priority
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
608 (defaults to 80)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
609 self.tk.call('option', 'add', pattern, value, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
610 def option_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
611 """Clear the option database.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
612
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
613 It will be reloaded if option_add is called."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
614 self.tk.call('option', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
615 def option_get(self, name, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
616 """Return the value for an option NAME for this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
617 with CLASSNAME.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
618
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
619 Values with higher priority override lower values."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
620 return self.tk.call('option', 'get', self._w, name, className)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
621 def option_readfile(self, fileName, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
622 """Read file FILENAME into the option database.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
623
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
624 An optional second parameter gives the numeric
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
625 priority."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
626 self.tk.call('option', 'readfile', fileName, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
627 def selection_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
628 """Clear the current X selection."""
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
629 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
630 self.tk.call(('selection', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
631 def selection_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
632 """Return the contents of the current X selection.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
633
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
634 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
635 the selection and defaults to PRIMARY. A keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
636 parameter displayof specifies a widget on the display
76975
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
637 to use. A keyword parameter type specifies the form of data to be
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
638 fetched, defaulting to STRING except on X11, where UTF8_STRING is tried
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
639 before STRING."""
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
640 if 'displayof' not in kw: kw['displayof'] = self._w
76975
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
641 if 'type' not in kw and self._windowingsystem == 'x11':
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
642 try:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
643 kw['type'] = 'UTF8_STRING'
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
644 return self.tk.call(('selection', 'get') + self._options(kw))
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
645 except TclError:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
646 del kw['type']
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
647 return self.tk.call(('selection', 'get') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
648 def selection_handle(self, command, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
649 """Specify a function COMMAND to call if the X
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
650 selection owned by this widget is queried by another
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
651 application.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
652
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
653 This function must return the contents of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
654 selection. The function will be called with the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
655 arguments OFFSET and LENGTH which allows the chunking
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
656 of very long selections. The following keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
657 parameters can be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
658 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
659 type - type of the selection (e.g. STRING, FILE_NAME)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
660 name = self._register(command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
661 self.tk.call(('selection', 'handle') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
662 + (self._w, name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
663 def selection_own(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
664 """Become owner of X selection.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
665
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
666 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
667 the selection (default PRIMARY)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
668 self.tk.call(('selection', 'own') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
669 self._options(kw) + (self._w,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
670 def selection_own_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
671 """Return owner of X selection.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
672
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
673 The following keyword parameter can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
674 be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
675 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
676 type - type of the selection (e.g. STRING, FILE_NAME)."""
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
677 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
678 name = self.tk.call(('selection', 'own') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
679 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
680 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
681 def send(self, interp, cmd, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
682 """Send Tcl command CMD to different interpreter INTERP to be executed."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
683 return self.tk.call(('send', interp, cmd) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
684 def lower(self, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
685 """Lower this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
686 self.tk.call('lower', self._w, belowThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
687 def tkraise(self, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
688 """Raise this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
689 self.tk.call('raise', self._w, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
690 lift = tkraise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
691 def colormodel(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
692 """Useless. Not implemented in Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
693 return self.tk.call('tk', 'colormodel', self._w, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
694 def winfo_atom(self, name, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
695 """Return integer which represents atom NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
696 args = ('winfo', 'atom') + self._displayof(displayof) + (name,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
697 return getint(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
698 def winfo_atomname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
699 """Return name of atom with identifier ID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
700 args = ('winfo', 'atomname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
701 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
702 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
703 def winfo_cells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
704 """Return number of cells in the colormap for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
705 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
706 self.tk.call('winfo', 'cells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
707 def winfo_children(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
708 """Return a list of all widgets which are children of this widget."""
22608
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
709 result = []
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
710 for child in self.tk.splitlist(
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
711 self.tk.call('winfo', 'children', self._w)):
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
712 try:
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
713 # Tcl sometimes returns extra windows, e.g. for
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
714 # menus; those need to be skipped
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
715 result.append(self._nametowidget(child))
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
716 except KeyError:
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
717 pass
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
718 return result
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
719
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
720 def winfo_class(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
721 """Return window class name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
722 return self.tk.call('winfo', 'class', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
723 def winfo_colormapfull(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
724 """Return true if at the last color request the colormap was full."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
725 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
726 self.tk.call('winfo', 'colormapfull', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
727 def winfo_containing(self, rootX, rootY, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
728 """Return the widget which is at the root coordinates ROOTX, ROOTY."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
729 args = ('winfo', 'containing') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
730 + self._displayof(displayof) + (rootX, rootY)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
731 name = self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
732 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
733 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
734 def winfo_depth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
735 """Return the number of bits per pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
736 return getint(self.tk.call('winfo', 'depth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
737 def winfo_exists(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
738 """Return true if this widget exists."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
739 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
740 self.tk.call('winfo', 'exists', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
741 def winfo_fpixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
742 """Return the number of pixels for the given distance NUMBER
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
743 (e.g. "3c") as float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
744 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
745 'winfo', 'fpixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
746 def winfo_geometry(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
747 """Return geometry string for this widget in the form "widthxheight+X+Y"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
748 return self.tk.call('winfo', 'geometry', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
749 def winfo_height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
750 """Return height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
751 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
752 self.tk.call('winfo', 'height', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
753 def winfo_id(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
754 """Return identifier ID for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
755 return self.tk.getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
756 self.tk.call('winfo', 'id', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
757 def winfo_interps(self, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
758 """Return the name of all Tcl interpreters for this display."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
759 args = ('winfo', 'interps') + self._displayof(displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
760 return self.tk.splitlist(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
761 def winfo_ismapped(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
762 """Return true if this widget is mapped."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
763 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
764 self.tk.call('winfo', 'ismapped', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
765 def winfo_manager(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
766 """Return the window mananger name for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
767 return self.tk.call('winfo', 'manager', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
768 def winfo_name(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
769 """Return the name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
770 return self.tk.call('winfo', 'name', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
771 def winfo_parent(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
772 """Return the name of the parent of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
773 return self.tk.call('winfo', 'parent', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
774 def winfo_pathname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
775 """Return the pathname of the widget given by ID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
776 args = ('winfo', 'pathname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
777 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
778 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
779 def winfo_pixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
780 """Rounded integer value of winfo_fpixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
781 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
782 self.tk.call('winfo', 'pixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
783 def winfo_pointerx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
784 """Return the x coordinate of the pointer on the root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
785 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
786 self.tk.call('winfo', 'pointerx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
787 def winfo_pointerxy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
788 """Return a tuple of x and y coordinates of the pointer on the root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
789 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
790 self.tk.call('winfo', 'pointerxy', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
791 def winfo_pointery(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
792 """Return the y coordinate of the pointer on the root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
793 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
794 self.tk.call('winfo', 'pointery', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
795 def winfo_reqheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
796 """Return requested height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
797 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
798 self.tk.call('winfo', 'reqheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
799 def winfo_reqwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
800 """Return requested width of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
801 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
802 self.tk.call('winfo', 'reqwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
803 def winfo_rgb(self, color):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
804 """Return tuple of decimal values for red, green, blue for
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
805 COLOR in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
806 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
807 self.tk.call('winfo', 'rgb', self._w, color))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
808 def winfo_rootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
809 """Return x coordinate of upper left corner of this widget on the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
810 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
811 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
812 self.tk.call('winfo', 'rootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
813 def winfo_rooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
814 """Return y coordinate of upper left corner of this widget on the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
815 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
816 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
817 self.tk.call('winfo', 'rooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
818 def winfo_screen(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
819 """Return the screen name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
820 return self.tk.call('winfo', 'screen', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
821 def winfo_screencells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
822 """Return the number of the cells in the colormap of the screen
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
823 of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
824 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
825 self.tk.call('winfo', 'screencells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
826 def winfo_screendepth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
827 """Return the number of bits per pixel of the root window of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
828 screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
829 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
830 self.tk.call('winfo', 'screendepth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
831 def winfo_screenheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
832 """Return the number of pixels of the height of the screen of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
833 in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
834 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
835 self.tk.call('winfo', 'screenheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
836 def winfo_screenmmheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
837 """Return the number of pixels of the height of the screen of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
838 this widget in mm."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
839 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
840 self.tk.call('winfo', 'screenmmheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
841 def winfo_screenmmwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
842 """Return the number of pixels of the width of the screen of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
843 this widget in mm."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
844 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
845 self.tk.call('winfo', 'screenmmwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
846 def winfo_screenvisual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
847 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
848 staticcolor, staticgray, or truecolor for the default
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
849 colormodel of this screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
850 return self.tk.call('winfo', 'screenvisual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
851 def winfo_screenwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
852 """Return the number of pixels of the width of the screen of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
853 this widget in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
854 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
855 self.tk.call('winfo', 'screenwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
856 def winfo_server(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
857 """Return information of the X-Server of the screen of this widget in
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
858 the form "XmajorRminor vendor vendorVersion"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
859 return self.tk.call('winfo', 'server', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
860 def winfo_toplevel(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
861 """Return the toplevel widget of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
862 return self._nametowidget(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
863 'winfo', 'toplevel', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
864 def winfo_viewable(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
865 """Return true if the widget and all its higher ancestors are mapped."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
866 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
867 self.tk.call('winfo', 'viewable', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
868 def winfo_visual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
869 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
870 staticcolor, staticgray, or truecolor for the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
871 colormodel of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
872 return self.tk.call('winfo', 'visual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
873 def winfo_visualid(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
874 """Return the X identifier for the visual for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
875 return self.tk.call('winfo', 'visualid', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
876 def winfo_visualsavailable(self, includeids=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
877 """Return a list of all visuals available for the screen
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
878 of this widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
879
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
880 Each item in the list consists of a visual name (see winfo_visual), a
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
881 depth and if INCLUDEIDS=1 is given also the X identifier."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
882 data = self.tk.split(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
883 self.tk.call('winfo', 'visualsavailable', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
884 includeids and 'includeids' or None))
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
885 if isinstance(data, str):
13907
446c3616c323 -- don't mess up in winfo_visualsavailable if the system only
Fredrik Lundh <fredrik@pythonware.com>
parents: 13906
diff changeset
886 data = [self.tk.split(data)]
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
887 return [self.__winfo_parseitem(x) for x in data]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
888 def __winfo_parseitem(self, t):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
889 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
890 return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
891 def __winfo_getint(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
892 """Internal function."""
16517
eee67a84e5fa String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15540
diff changeset
893 return int(x, 0)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
894 def winfo_vrootheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
895 """Return the height of the virtual root window associated with this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
896 widget in pixels. If there is no virtual root window return the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
897 height of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
898 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
899 self.tk.call('winfo', 'vrootheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
900 def winfo_vrootwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
901 """Return the width of the virtual root window associated with this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
902 widget in pixel. If there is no virtual root window return the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
903 width of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
904 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
905 self.tk.call('winfo', 'vrootwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
906 def winfo_vrootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
907 """Return the x offset of the virtual root relative to the root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
908 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
909 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
910 self.tk.call('winfo', 'vrootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
911 def winfo_vrooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
912 """Return the y offset of the virtual root relative to the root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
913 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
914 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
915 self.tk.call('winfo', 'vrooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
916 def winfo_width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
917 """Return the width of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
918 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
919 self.tk.call('winfo', 'width', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
920 def winfo_x(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
921 """Return the x coordinate of the upper left corner of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
922 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
923 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
924 self.tk.call('winfo', 'x', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
925 def winfo_y(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
926 """Return the y coordinate of the upper left corner of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
927 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
928 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
929 self.tk.call('winfo', 'y', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
930 def update(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
931 """Enter event loop until all pending events have been processed by Tcl."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
932 self.tk.call('update')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
933 def update_idletasks(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
934 """Enter event loop until all idle callbacks have been called. This
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
935 will update the display of windows but not process events caused by
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
936 the user."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
937 self.tk.call('update', 'idletasks')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
938 def bindtags(self, tagList=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
939 """Set or get the list of bindtags for this widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
940
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
941 With no argument return the list of all bindtags associated with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
942 this widget. With a list of strings as argument the bindtags are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
943 set to this list. The bindtags determine in which order events are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
944 processed (see bind)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
945 if tagList is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
946 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
947 self.tk.call('bindtags', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
948 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
949 self.tk.call('bindtags', self._w, tagList)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
950 def _bind(self, what, sequence, func, add, needcleanup=1):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
951 """Internal function."""
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
952 if isinstance(func, str):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
953 self.tk.call(what + (sequence, func))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
954 elif func:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
955 funcid = self._register(func, self._substitute,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
956 needcleanup)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
957 cmd = ('%sif {"[%s %s]" == "break"} break\n'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
958 %
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
959 (add and '+' or '',
19102
9ec5611cfe9c Patch #403514: precompute _subst_format_str to avoid a call to
Martin v. Löwis <martin@v.loewis.de>
parents: 16517
diff changeset
960 funcid, self._subst_format_str))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
961 self.tk.call(what + (sequence, cmd))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
962 return funcid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
963 elif sequence:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
964 return self.tk.call(what + (sequence,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
965 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
966 return self.tk.splitlist(self.tk.call(what))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
967 def bind(self, sequence=None, func=None, add=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
968 """Bind to this widget at event SEQUENCE a call to function FUNC.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
969
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
970 SEQUENCE is a string of concatenated event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
971 patterns. An event pattern is of the form
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
972 <MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
973 of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
974 Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
975 B3, Alt, Button4, B4, Double, Button5, B5 Triple,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
976 Mod1, M1. TYPE is one of Activate, Enter, Map,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
977 ButtonPress, Button, Expose, Motion, ButtonRelease
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
978 FocusIn, MouseWheel, Circulate, FocusOut, Property,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
979 Colormap, Gravity Reparent, Configure, KeyPress, Key,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
980 Unmap, Deactivate, KeyRelease Visibility, Destroy,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
981 Leave and DETAIL is the button number for ButtonPress,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
982 ButtonRelease and DETAIL is the Keysym for KeyPress and
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
983 KeyRelease. Examples are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
984 <Control-Button-1> for pressing Control and mouse button 1 or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
985 <Alt-A> for pressing A and the Alt key (KeyPress can be omitted).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
986 An event pattern can also be a virtual event of the form
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
987 <<AString>> where AString can be arbitrary. This
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
988 event can be generated by event_generate.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
989 If events are concatenated they must appear shortly
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
990 after each other.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
991
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
992 FUNC will be called if the event sequence occurs with an
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
993 instance of Event as argument. If the return value of FUNC is
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
994 "break" no further bound function is invoked.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
995
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
996 An additional boolean parameter ADD specifies whether FUNC will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
997 be called additionally to the other bound function or whether
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
998 it will replace the previous function.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
999
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1000 Bind will return an identifier to allow deletion of the bound function with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1001 unbind without memory leak.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1002
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1003 If FUNC or SEQUENCE is omitted the bound function or list
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1004 of bound events are returned."""
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1005
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1006 return self._bind(('bind', self._w), sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1007 def unbind(self, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1008 """Unbind for this widget for event SEQUENCE the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1009 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1010 self.tk.call('bind', self._w, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1011 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1012 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1013 def bind_all(self, sequence=None, func=None, add=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1014 """Bind to all widgets at an event SEQUENCE a call to function FUNC.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1015 An additional boolean parameter ADD specifies whether FUNC will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1016 be called additionally to the other bound function or whether
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1017 it will replace the previous function. See bind for the return value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1018 return self._bind(('bind', 'all'), sequence, func, add, 0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1019 def unbind_all(self, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1020 """Unbind for all widgets for event SEQUENCE all functions."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1021 self.tk.call('bind', 'all' , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1022 def bind_class(self, className, sequence=None, func=None, add=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1023
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1024 """Bind to widgets with bindtag CLASSNAME at event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1025 SEQUENCE a call of function FUNC. An additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1026 boolean parameter ADD specifies whether FUNC will be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1027 called additionally to the other bound function or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1028 whether it will replace the previous function. See bind for
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1029 the return value."""
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1030
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1031 return self._bind(('bind', className), sequence, func, add, 0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1032 def unbind_class(self, className, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1033 """Unbind for a all widgets with bindtag CLASSNAME for event SEQUENCE
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1034 all functions."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1035 self.tk.call('bind', className , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1036 def mainloop(self, n=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1037 """Call the mainloop of Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1038 self.tk.mainloop(n)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1039 def quit(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1040 """Quit the Tcl interpreter. All widgets will be destroyed."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1041 self.tk.quit()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1042 def _getints(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1043 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1044 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1045 return tuple(map(getint, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1046 def _getdoubles(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1047 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1048 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1049 return tuple(map(getdouble, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1050 def _getboolean(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1051 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1052 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1053 return self.tk.getboolean(string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1054 def _displayof(self, displayof):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1055 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1056 if displayof:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1057 return ('-displayof', displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1058 if displayof is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1059 return ('-displayof', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1060 return ()
76975
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1061 @property
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1062 def _windowingsystem(self):
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1063 """Internal function."""
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1064 try:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1065 return self._root()._windowingsystem_cached
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1066 except AttributeError:
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1067 ws = self._root()._windowingsystem_cached = \
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1068 self.tk.call('tk', 'windowingsystem')
41382250e5e1 Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 73165
diff changeset
1069 return ws
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1070 def _options(self, cnf, kw = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1071 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1072 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1073 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1074 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1075 cnf = _cnfmerge(cnf)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1076 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1077 for k, v in cnf.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1078 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1079 if k[-1] == '_': k = k[:-1]
73165
8e57b5d8f58f Closes #13258: Use callable() built-in in the standard library.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 68489
diff changeset
1080 if callable(v):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1081 v = self._register(v)
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1082 elif isinstance(v, (tuple, list)):
47455
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1083 nv = []
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1084 for item in v:
47455
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1085 if isinstance(item, int):
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1086 nv.append(str(item))
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1087 elif isinstance(item, str):
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1088 nv.append(('{%s}' if ' ' in item else '%s') % item)
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1089 else:
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1090 break
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1091 else:
47455
a76e49b219a2 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47384
diff changeset
1092 v = ' '.join(nv)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1093 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1094 return res
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1095 def nametowidget(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1096 """Return the Tkinter instance of a widget identified by
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1097 its Tcl name NAME."""
48619
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1098 name = str(name).split('.')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1099 w = self
48619
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1100
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1101 if not name[0]:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1102 w = w._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1103 name = name[1:]
48619
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1104
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1105 for n in name:
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1106 if not n:
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1107 break
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1108 w = w.children[n]
d587aa5e824d Merged revisions 65399 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents: 48592
diff changeset
1109
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1110 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1111 _nametowidget = nametowidget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1112 def _register(self, func, subst=None, needcleanup=1):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1113 """Return a newly created Tcl function. If this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1114 function is called, the Python function FUNC will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1115 be executed. An optional function SUBST can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1116 be given which will be executed before FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1117 f = CallWrapper(func, subst, self).__call__
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
1118 name = repr(id(f))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1119 try:
44026
48af6375207e Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Christian Heimes <christian@cheimes.de>
parents: 43577
diff changeset
1120 func = func.__func__
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1121 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1122 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1123 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1124 name = name + func.__name__
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1125 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1126 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1127 self.tk.createcommand(name, f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1128 if needcleanup:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1129 if self._tclCommands is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1130 self._tclCommands = []
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1131 self._tclCommands.append(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1132 return name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1133 register = _register
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1134 def _root(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1135 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1136 w = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1137 while w.master: w = w.master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1138 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1139 _subst_format = ('%#', '%b', '%f', '%h', '%k',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1140 '%s', '%t', '%w', '%x', '%y',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1141 '%A', '%E', '%K', '%N', '%W', '%T', '%X', '%Y', '%D')
19102
9ec5611cfe9c Patch #403514: precompute _subst_format_str to avoid a call to
Martin v. Löwis <martin@v.loewis.de>
parents: 16517
diff changeset
1142 _subst_format_str = " ".join(_subst_format)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1143 def _substitute(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1144 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1145 if len(args) != len(self._subst_format): return args
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1146 getboolean = self.tk.getboolean
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1147
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1148 getint = int
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1149 def getint_event(s):
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1150 """Tk changed behavior in 8.4.2, returning "??" rather more often."""
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1151 try:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1152 return int(s)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1153 except ValueError:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1154 return s
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1155
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1156 nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1157 # Missing: (a, c, d, m, o, v, B, R)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1158 e = Event()
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1159 # serial field: valid vor all events
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1160 # number of button: ButtonPress and ButtonRelease events only
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1161 # height field: Configure, ConfigureRequest, Create,
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1162 # ResizeRequest, and Expose events only
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1163 # keycode field: KeyPress and KeyRelease events only
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1164 # time field: "valid for events that contain a time field"
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1165 # width field: Configure, ConfigureRequest, Create, ResizeRequest,
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1166 # and Expose events only
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1167 # x field: "valid for events that contain a x field"
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1168 # y field: "valid for events that contain a y field"
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1169 # keysym as decimal: KeyPress and KeyRelease events only
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1170 # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress,
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1171 # KeyRelease,and Motion events
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1172 e.serial = getint(nsign)
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1173 e.num = getint_event(b)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1174 try: e.focus = getboolean(f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1175 except TclError: pass
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1176 e.height = getint_event(h)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1177 e.keycode = getint_event(k)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1178 e.state = getint_event(s)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1179 e.time = getint_event(t)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1180 e.width = getint_event(w)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1181 e.x = getint_event(x)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1182 e.y = getint_event(y)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1183 e.char = A
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1184 try: e.send_event = getboolean(E)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1185 except TclError: pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1186 e.keysym = K
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1187 e.keysym_num = getint_event(N)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1188 e.type = T
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1189 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1190 e.widget = self._nametowidget(W)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1191 except KeyError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1192 e.widget = W
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1193 e.x_root = getint_event(X)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1194 e.y_root = getint_event(Y)
14453
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1195 try:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1196 e.delta = getint(D)
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1197 except ValueError:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1198 e.delta = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1199 return (e,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1200 def _report_exception(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1201 """Internal function."""
37042
7ada16a14968 Remove sys.exc_type, sys.exc_value, sys.exc_traceback
Neal Norwitz <nnorwitz@gmail.com>
parents: 35850
diff changeset
1202 exc, val, tb = sys.exc_info()
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1203 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1204 root.report_callback_exception(exc, val, tb)
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1205 def _configure(self, cmd, cnf, kw):
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1206 """Internal function."""
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1207 if kw:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1208 cnf = _cnfmerge((cnf, kw))
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1209 elif cnf:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1210 cnf = _cnfmerge(cnf)
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1211 if cnf is None:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1212 cnf = {}
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1213 for x in self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1214 self.tk.call(_flatten((self._w, cmd)))):
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1215 cnf[x[0][1:]] = (x[0][1:],) + x[1:]
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1216 return cnf
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
1217 if isinstance(cnf, str):
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1218 x = self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1219 self.tk.call(_flatten((self._w, cmd, '-'+cnf))))
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1220 return (x[0][1:],) + x[1:]
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1221 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1222 # These used to be defined in Widget:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1223 def configure(self, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1224 """Configure resources of a widget.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1225
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1226 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1227 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1228 the allowed keyword arguments call the method keys.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1229 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1230 return self._configure('configure', cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1231 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1232 def cget(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1233 """Return the resource value for a KEY given as string."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1234 return self.tk.call(self._w, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1235 __getitem__ = cget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1236 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1237 self.configure({key: value})
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1238 def keys(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1239 """Return a list of all resource names of this widget."""
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1240 return [x[0][1:] for x in
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1241 self.tk.split(self.tk.call(self._w, 'configure'))]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1242 def __str__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1243 """Return the window path name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1244 return self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1245 # Pack methods that apply to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1246 _noarg_ = ['_noarg_']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1247 def pack_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1248 """Set or get the status for propagation of geometry information.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1249
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1250 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1251 of the slaves will determine the size of this widget. If no argument
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1252 is given the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1253 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1254 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1255 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1256 'pack', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1257 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1258 self.tk.call('pack', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1259 propagate = pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1260 def pack_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1261 """Return a list of all slaves of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1262 in its packing order."""
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1263 return [self._nametowidget(x) for x in
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1264 self.tk.splitlist(
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1265 self.tk.call('pack', 'slaves', self._w))]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1266 slaves = pack_slaves
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1267 # Place method that applies to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1268 def place_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1269 """Return a list of all slaves of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1270 in its packing order."""
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1271 return [self._nametowidget(x) for x in
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1272 self.tk.splitlist(
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1273 self.tk.call(
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1274 'place', 'slaves', self._w))]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1275 # Grid methods that apply to the master
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1276 def grid_anchor(self, anchor=None): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1277 """The anchor value controls how to place the grid within the
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1278 master when no row/column has any weight.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1279
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1280 The default anchor is nw."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1281 self.tk.call('grid', 'anchor', self._w, anchor)
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1282 anchor = grid_anchor
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1283 def grid_bbox(self, column=None, row=None, col2=None, row2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1284 """Return a tuple of integer coordinates for the bounding
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1285 box of this widget controlled by the geometry manager grid.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1286
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1287 If COLUMN, ROW is given the bounding box applies from
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1288 the cell with row and column 0 to the specified
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1289 cell. If COL2 and ROW2 are given the bounding box
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1290 starts at that cell.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1291
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1292 The returned integers specify the offset of the upper left
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1293 corner in the master widget and the width and height.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1294 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1295 args = ('grid', 'bbox', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1296 if column is not None and row is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1297 args = args + (column, row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1298 if col2 is not None and row2 is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1299 args = args + (col2, row2)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1300 return self._getints(self.tk.call(*args)) or None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1301 bbox = grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1302 def _grid_configure(self, command, index, cnf, kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1303 """Internal function."""
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
1304 if isinstance(cnf, str) and not kw:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1305 if cnf[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1306 cnf = cnf[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1307 if cnf[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1308 cnf = '-'+cnf
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1309 options = (cnf,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1310 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1311 options = self._options(cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1312 if not options:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1313 res = self.tk.call('grid',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1314 command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1315 words = self.tk.splitlist(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1316 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1317 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1318 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1319 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1320 if not value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1321 value = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1322 elif '.' in value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1323 value = getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1324 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1325 value = getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1326 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1327 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1328 res = self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1329 ('grid', command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1330 + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1331 if len(options) == 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1332 if not res: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1333 # In Tk 7.5, -width can be a float
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1334 if '.' in res: return getdouble(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1335 return getint(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1336 def grid_columnconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1337 """Configure column INDEX of a grid.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1338
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1339 Valid resources are minsize (minimum size of the column),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1340 weight (how much does additional space propagate to this column)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1341 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1342 return self._grid_configure('columnconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1343 columnconfigure = grid_columnconfigure
20414
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1344 def grid_location(self, x, y):
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1345 """Return a tuple of column and row which identify the cell
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1346 at which the pixel at position X and Y inside the master
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1347 widget is located."""
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1348 return self._getints(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1349 self.tk.call(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1350 'grid', 'location', self._w, x, y)) or None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1351 def grid_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1352 """Set or get the status for propagation of geometry information.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1353
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1354 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1355 of the slaves will determine the size of this widget. If no argument
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1356 is given, the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1357 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1358 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1359 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1360 'grid', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1361 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1362 self.tk.call('grid', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1363 def grid_rowconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1364 """Configure row INDEX of a grid.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1365
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1366 Valid resources are minsize (minimum size of the row),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1367 weight (how much does additional space propagate to this row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1368 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1369 return self._grid_configure('rowconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1370 rowconfigure = grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1371 def grid_size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1372 """Return a tuple of the number of column and rows in the grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1373 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1374 self.tk.call('grid', 'size', self._w)) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1375 size = grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1376 def grid_slaves(self, row=None, column=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1377 """Return a list of all slaves of this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1378 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1379 args = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1380 if row is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1381 args = args + ('-row', row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1382 if column is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1383 args = args + ('-column', column)
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1384 return [self._nametowidget(x) for x in
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1385 self.tk.splitlist(self.tk.call(
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1386 ('grid', 'slaves', self._w) + args))]
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1387
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1388 # Support for the "event" command, new in Tk 4.2.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1389 # By Case Roole.
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1390
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1391 def event_add(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1392 """Bind a virtual event VIRTUAL (of the form <<Name>>)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1393 to an event SEQUENCE such that the virtual event is triggered
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1394 whenever SEQUENCE occurs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1395 args = ('event', 'add', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1396 self.tk.call(args)
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1397
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1398 def event_delete(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1399 """Unbind a virtual event VIRTUAL from SEQUENCE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1400 args = ('event', 'delete', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1401 self.tk.call(args)
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1402
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1403 def event_generate(self, sequence, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1404 """Generate an event SEQUENCE. Additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1405 keyword arguments specify parameter of the event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1406 (e.g. x, y, rootx, rooty)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1407 args = ('event', 'generate', self._w, sequence)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1408 for k, v in kw.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1409 args = args + ('-%s' % k, str(v))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1410 self.tk.call(args)
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1411
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1412 def event_info(self, virtual=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1413 """Return a list of all virtual events or the information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1414 about the SEQUENCE bound to the virtual event VIRTUAL."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1415 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1416 self.tk.call('event', 'info', virtual))
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1417
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1418 # Image related commands
7959
fec8eb2a380d Add image_types() and image_names() as methods to Misc class.
Guido van Rossum <guido@python.org>
parents: 7880
diff changeset
1419
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1420 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1421 """Return a list of all existing image names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1422 return self.tk.call('image', 'names')
7959
fec8eb2a380d Add image_types() and image_names() as methods to Misc class.
Guido van Rossum <guido@python.org>
parents: 7880
diff changeset
1423
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1424 def image_types(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1425 """Return a list of all available image types (e.g. phote bitmap)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1426 return self.tk.call('image', 'types')
7959
fec8eb2a380d Add image_types() and image_names() as methods to Misc class.
Guido van Rossum <guido@python.org>
parents: 7880
diff changeset
1427
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1428
3071
fbb8eddc9309 move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents: 3067
diff changeset
1429 class CallWrapper:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1430 """Internal class. Stores function to call when some user
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1431 defined Tcl function is called e.g. after an event occurred."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1432 def __init__(self, func, subst, widget):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1433 """Store FUNC, SUBST and WIDGET as members."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1434 self.func = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1435 self.subst = subst
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1436 self.widget = widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1437 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1438 """Apply first function SUBST to arguments, than FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1439 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1440 if self.subst:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1441 args = self.subst(*args)
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1442 return self.func(*args)
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
1443 except SystemExit as msg:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1444 raise SystemExit(msg)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1445 except:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1446 self.widget._report_exception()
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1447
8211
203e2ab63936 Change the names of all methods in the Wm class: they are now
Guido van Rossum <guido@python.org>
parents: 8209
diff changeset
1448
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1449 class XView:
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1450 """Mix-in class for querying and changing the horizontal position
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1451 of a widget's window."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1452
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1453 def xview(self, *args):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1454 """Query and change the horizontal position of the view."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1455 res = self.tk.call(self._w, 'xview', *args)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1456 if not args:
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1457 return self._getdoubles(res)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1458
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1459 def xview_moveto(self, fraction):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1460 """Adjusts the view in the window so that FRACTION of the
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1461 total width of the canvas is off-screen to the left."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1462 self.tk.call(self._w, 'xview', 'moveto', fraction)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1463
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1464 def xview_scroll(self, number, what):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1465 """Shift the x-view according to NUMBER which is measured in "units"
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1466 or "pages" (WHAT)."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1467 self.tk.call(self._w, 'xview', 'scroll', number, what)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1468
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1469
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1470 class YView:
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1471 """Mix-in class for querying and changing the vertical position
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1472 of a widget's window."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1473
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1474 def yview(self, *args):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1475 """Query and change the vertical position of the view."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1476 res = self.tk.call(self._w, 'yview', *args)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1477 if not args:
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1478 return self._getdoubles(res)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1479
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1480 def yview_moveto(self, fraction):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1481 """Adjusts the view in the window so that FRACTION of the
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1482 total height of the canvas is off-screen to the top."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1483 self.tk.call(self._w, 'yview', 'moveto', fraction)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1484
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1485 def yview_scroll(self, number, what):
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1486 """Shift the y-view according to NUMBER which is measured in
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1487 "units" or "pages" (WHAT)."""
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1488 self.tk.call(self._w, 'yview', 'scroll', number, what)
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1489
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
1490
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1491 class Wm:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1492 """Provides functions for the communication with the window manager."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1493
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1494 def wm_aspect(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1495 minNumer=None, minDenom=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1496 maxNumer=None, maxDenom=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1497 """Instruct the window manager to set the aspect ratio (width/height)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1498 of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. Return a tuple
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1499 of the actual values if no argument is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1500 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1501 self.tk.call('wm', 'aspect', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1502 minNumer, minDenom,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1503 maxNumer, maxDenom))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1504 aspect = wm_aspect
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1505
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1506 def wm_attributes(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1507 """This subcommand returns or sets platform specific attributes
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1508
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1509 The first form returns a list of the platform specific flags and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1510 their values. The second form returns the value for the specific
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1511 option. The third form sets one or more of the values. The values
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1512 are as follows:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1514 On Windows, -disabled gets or sets whether the window is in a
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1515 disabled state. -toolwindow gets or sets the style of the window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1516 to toolwindow (as defined in the MSDN). -topmost gets or sets
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1517 whether this is a topmost window (displays above all other
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1518 windows).
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1519
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1520 On Macintosh, XXXXX
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1521
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1522 On Unix, there are currently no special attribute values.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1523 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1524 args = ('wm', 'attributes', self._w) + args
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1525 return self.tk.call(args)
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1526 attributes=wm_attributes
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1527
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1528 def wm_client(self, name=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1529 """Store NAME in WM_CLIENT_MACHINE property of this widget. Return
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1530 current value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1531 return self.tk.call('wm', 'client', self._w, name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1532 client = wm_client
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1533 def wm_colormapwindows(self, *wlist):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1534 """Store list of window names (WLIST) into WM_COLORMAPWINDOWS property
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1535 of this widget. This list contains windows whose colormaps differ from their
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1536 parents. Return current list of widgets if WLIST is empty."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1537 if len(wlist) > 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1538 wlist = (wlist,) # Tk needs a list of windows here
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1539 args = ('wm', 'colormapwindows', self._w) + wlist
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
1540 return [self._nametowidget(x) for x in self.tk.call(args)]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1541 colormapwindows = wm_colormapwindows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1542 def wm_command(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1543 """Store VALUE in WM_COMMAND property. It is the command
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1544 which shall be used to invoke the application. Return current
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1545 command if VALUE is None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1546 return self.tk.call('wm', 'command', self._w, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1547 command = wm_command
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1548 def wm_deiconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1549 """Deiconify this widget. If it was never mapped it will not be mapped.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1550 On Windows it will raise this widget and give it the focus."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1551 return self.tk.call('wm', 'deiconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1552 deiconify = wm_deiconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1553 def wm_focusmodel(self, model=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1554 """Set focus model to MODEL. "active" means that this widget will claim
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1555 the focus itself, "passive" means that the window manager shall give
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1556 the focus. Return current focus model if MODEL is None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1557 return self.tk.call('wm', 'focusmodel', self._w, model)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1558 focusmodel = wm_focusmodel
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1559 def wm_forget(self, window): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1560 """The window will be unmappend from the screen and will no longer
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1561 be managed by wm. toplevel windows will be treated like frame
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1562 windows once they are no longer managed by wm, however, the menu
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1563 option configuration will be remembered and the menus will return
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1564 once the widget is managed again."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1565 self.tk.call('wm', 'forget', window)
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1566 forget = wm_forget
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1567 def wm_frame(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1568 """Return identifier for decorative frame of this widget if present."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1569 return self.tk.call('wm', 'frame', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1570 frame = wm_frame
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1571 def wm_geometry(self, newGeometry=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1572 """Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1573 current value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1574 return self.tk.call('wm', 'geometry', self._w, newGeometry)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1575 geometry = wm_geometry
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1576 def wm_grid(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1577 baseWidth=None, baseHeight=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1578 widthInc=None, heightInc=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1579 """Instruct the window manager that this widget shall only be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1580 resized on grid boundaries. WIDTHINC and HEIGHTINC are the width and
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1581 height of a grid unit in pixels. BASEWIDTH and BASEHEIGHT are the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1582 number of grid units requested in Tk_GeometryRequest."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1583 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1584 'wm', 'grid', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1585 baseWidth, baseHeight, widthInc, heightInc))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1586 grid = wm_grid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1587 def wm_group(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1588 """Set the group leader widgets for related widgets to PATHNAME. Return
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1589 the group leader of this widget if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1590 return self.tk.call('wm', 'group', self._w, pathName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1591 group = wm_group
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1592 def wm_iconbitmap(self, bitmap=None, default=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1593 """Set bitmap for the iconified widget to BITMAP. Return
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1594 the bitmap if None is given.
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1595
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1596 Under Windows, the DEFAULT parameter can be used to set the icon
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1597 for the widget and any descendents that don't have an icon set
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1598 explicitly. DEFAULT can be the relative path to a .ico file
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1599 (example: root.iconbitmap(default='myicon.ico') ). See Tk
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1600 documentation for more information."""
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1601 if default:
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1602 return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1603 else:
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
1604 return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1605 iconbitmap = wm_iconbitmap
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1606 def wm_iconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1607 """Display widget as icon."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1608 return self.tk.call('wm', 'iconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1609 iconify = wm_iconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1610 def wm_iconmask(self, bitmap=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1611 """Set mask for the icon bitmap of this widget. Return the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1612 mask if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1613 return self.tk.call('wm', 'iconmask', self._w, bitmap)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1614 iconmask = wm_iconmask
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1615 def wm_iconname(self, newName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1616 """Set the name of the icon for this widget. Return the name if
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1617 None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1618 return self.tk.call('wm', 'iconname', self._w, newName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1619 iconname = wm_iconname
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1620 def wm_iconphoto(self, default=False, *args): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1621 """Sets the titlebar icon for this window based on the named photo
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1622 images passed through args. If default is True, this is applied to
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1623 all future created toplevels as well.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1624
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1625 The data in the images is taken as a snapshot at the time of
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1626 invocation. If the images are later changed, this is not reflected
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1627 to the titlebar icons. Multiple images are accepted to allow
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1628 different images sizes to be provided. The window manager may scale
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1629 provided icons to an appropriate size.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1630
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1631 On Windows, the images are packed into a Windows icon structure.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1632 This will override an icon specified to wm_iconbitmap, and vice
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1633 versa.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1634
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1635 On X, the images are arranged into the _NET_WM_ICON X property,
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1636 which most modern window managers support. An icon specified by
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1637 wm_iconbitmap may exist simuultaneously.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1638
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1639 On Macintosh, this currently does nothing."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1640 if default:
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1641 self.tk.call('wm', 'iconphoto', self._w, "-default", *args)
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1642 else:
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1643 self.tk.call('wm', 'iconphoto', self._w, *args)
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1644 iconphoto = wm_iconphoto
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1645 def wm_iconposition(self, x=None, y=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1646 """Set the position of the icon of this widget to X and Y. Return
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1647 a tuple of the current values of X and X if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1648 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1649 'wm', 'iconposition', self._w, x, y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1650 iconposition = wm_iconposition
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1651 def wm_iconwindow(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1652 """Set widget PATHNAME to be displayed instead of icon. Return the current
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1653 value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1654 return self.tk.call('wm', 'iconwindow', self._w, pathName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1655 iconwindow = wm_iconwindow
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1656 def wm_manage(self, widget): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1657 """The widget specified will become a stand alone top-level window.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1658 The window will be decorated with the window managers title bar,
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1659 etc."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1660 self.tk.call('wm', 'manage', widget)
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
1661 manage = wm_manage
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1662 def wm_maxsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1663 """Set max WIDTH and HEIGHT for this widget. If the window is gridded
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1664 the values are given in grid units. Return the current values if None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1665 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1666 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1667 'wm', 'maxsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1668 maxsize = wm_maxsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1669 def wm_minsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1670 """Set min WIDTH and HEIGHT for this widget. If the window is gridded
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1671 the values are given in grid units. Return the current values if None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1672 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1673 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1674 'wm', 'minsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1675 minsize = wm_minsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1676 def wm_overrideredirect(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1677 """Instruct the window manager to ignore this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1678 if BOOLEAN is given with 1. Return the current value if None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1679 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1680 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1681 'wm', 'overrideredirect', self._w, boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1682 overrideredirect = wm_overrideredirect
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1683 def wm_positionfrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1684 """Instruct the window manager that the position of this widget shall
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1685 be defined by the user if WHO is "user", and by its own policy if WHO is
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1686 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1687 return self.tk.call('wm', 'positionfrom', self._w, who)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1688 positionfrom = wm_positionfrom
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1689 def wm_protocol(self, name=None, func=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1690 """Bind function FUNC to command NAME for this widget.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1691 Return the function bound to NAME if None is given. NAME could be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1692 e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW"."""
73165
8e57b5d8f58f Closes #13258: Use callable() built-in in the standard library.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 68489
diff changeset
1693 if callable(func):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1694 command = self._register(func)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1695 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1696 command = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1697 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1698 'wm', 'protocol', self._w, name, command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1699 protocol = wm_protocol
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1700 def wm_resizable(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1701 """Instruct the window manager whether this width can be resized
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1702 in WIDTH or HEIGHT. Both values are boolean values."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1703 return self.tk.call('wm', 'resizable', self._w, width, height)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1704 resizable = wm_resizable
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1705 def wm_sizefrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1706 """Instruct the window manager that the size of this widget shall
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1707 be defined by the user if WHO is "user", and by its own policy if WHO is
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1708 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1709 return self.tk.call('wm', 'sizefrom', self._w, who)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1710 sizefrom = wm_sizefrom
13906
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1711 def wm_state(self, newstate=None):
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1712 """Query or set the state of this widget as one of normal, icon,
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1713 iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only)."""
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1714 return self.tk.call('wm', 'state', self._w, newstate)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1715 state = wm_state
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1716 def wm_title(self, string=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1717 """Set the title of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1718 return self.tk.call('wm', 'title', self._w, string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1719 title = wm_title
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1720 def wm_transient(self, master=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1721 """Instruct the window manager that this widget is transient
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1722 with regard to widget MASTER."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1723 return self.tk.call('wm', 'transient', self._w, master)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1724 transient = wm_transient
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1725 def wm_withdraw(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1726 """Withdraw this widget from the screen such that it is unmapped
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1727 and forgotten by the window manager. Re-draw it with wm_deiconify."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1728 return self.tk.call('wm', 'withdraw', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1729 withdraw = wm_withdraw
8211
203e2ab63936 Change the names of all methods in the Wm class: they are now
Guido van Rossum <guido@python.org>
parents: 8209
diff changeset
1730
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1731
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1732 class Tk(Misc, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1733 """Toplevel widget of Tk which represents mostly the main window
68488
0991b40e895d #11515: fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66407
diff changeset
1734 of an application. It has an associated Tcl interpreter."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1735 _w = '.'
32941
66dc211bf507 Patch #986929: Add support for wish -sync and -use options.
Martin v. Löwis <martin@v.loewis.de>
parents: 32736
diff changeset
1736 def __init__(self, screenName=None, baseName=None, className='Tk',
66dc211bf507 Patch #986929: Add support for wish -sync and -use options.
Martin v. Löwis <martin@v.loewis.de>
parents: 32736
diff changeset
1737 useTk=1, sync=0, use=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1738 """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1739 be created. BASENAME will be used for the identification of the profile file (see
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1740 readprofile).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1741 It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1742 is the name of the widget class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1743 self.master = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1744 self.children = {}
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1745 self._tkloaded = 0
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1746 # to avoid recursions in the getattr code in case of failure, we
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1747 # ensure that self.tk is always _something_.
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31547
diff changeset
1748 self.tk = None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1749 if baseName is None:
73345
fa82071bb7e1 Remove redundant imports.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 73166
diff changeset
1750 import os
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1751 baseName = os.path.basename(sys.argv[0])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1752 baseName, ext = os.path.splitext(baseName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1753 if ext not in ('.py', '.pyc', '.pyo'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1754 baseName = baseName + ext
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1755 interactive = 0
32941
66dc211bf507 Patch #986929: Add support for wish -sync and -use options.
Martin v. Löwis <martin@v.loewis.de>
parents: 32736
diff changeset
1756 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1757 if useTk:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1758 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1759 self.readprofile(baseName, className)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1760 def loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1761 if not self._tkloaded:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1762 self.tk.loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1763 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1764 def _loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1765 self._tkloaded = 1
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1766 global _default_root
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1767 # Version sanity checks
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1768 tk_version = self.tk.getvar('tk_version')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1769 if tk_version != _tkinter.TK_VERSION:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1770 raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)"
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1771 % (_tkinter.TK_VERSION, tk_version))
29248
2f42875d937f Convert tcl_version to str before comparing. Fixes #729317.
Martin v. Löwis <martin@v.loewis.de>
parents: 28645
diff changeset
1772 # Under unknown circumstances, tcl_version gets coerced to float
2f42875d937f Convert tcl_version to str before comparing. Fixes #729317.
Martin v. Löwis <martin@v.loewis.de>
parents: 28645
diff changeset
1773 tcl_version = str(self.tk.getvar('tcl_version'))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1774 if tcl_version != _tkinter.TCL_VERSION:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1775 raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1776 % (_tkinter.TCL_VERSION, tcl_version))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1777 if TkVersion < 4.0:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1778 raise RuntimeError("Tk 4.0 or higher is required; found Tk %s"
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
1779 % str(TkVersion))
34642
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1780 # Create and register the tkerror and exit commands
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1781 # We need to inline parts of _register here, _ register
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1782 # would register differently-named commands.
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1783 if self._tclCommands is None:
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1784 self._tclCommands = []
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1785 self.tk.createcommand('tkerror', _tkerror)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1786 self.tk.createcommand('exit', _exit)
34642
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1787 self._tclCommands.append('tkerror')
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1788 self._tclCommands.append('exit')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1789 if _support_default_root and not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1790 _default_root = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1791 self.protocol("WM_DELETE_WINDOW", self.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1792 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1793 """Destroy this and all descendants widgets. This will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1794 end the application of this Tcl interpreter."""
42309
bd6acfdb47d2 Merged revisions 56301-56442 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42193
diff changeset
1795 for c in list(self.children.values()): c.destroy()
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1796 self.tk.call('destroy', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1797 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1798 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1799 if _support_default_root and _default_root is self:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1800 _default_root = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1801 def readprofile(self, baseName, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1802 """Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
42552
ac192f89c109 Kill execfile(), use exec() instead
Neal Norwitz <nnorwitz@gmail.com>
parents: 42309
diff changeset
1803 the Tcl Interpreter and calls exec on the contents of BASENAME.py and
ac192f89c109 Kill execfile(), use exec() instead
Neal Norwitz <nnorwitz@gmail.com>
parents: 42309
diff changeset
1804 CLASSNAME.py if such a file exists in the home directory."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1805 import os
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
1806 if 'HOME' in os.environ: home = os.environ['HOME']
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1807 else: home = os.curdir
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1808 class_tcl = os.path.join(home, '.%s.tcl' % className)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1809 class_py = os.path.join(home, '.%s.py' % className)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1810 base_tcl = os.path.join(home, '.%s.tcl' % baseName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1811 base_py = os.path.join(home, '.%s.py' % baseName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1812 dir = {'self': self}
47130
ef4cca2d6171 Tkinter, step 2: adapt imports.
Georg Brandl <georg@python.org>
parents: 47129
diff changeset
1813 exec('from tkinter import *', dir)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1814 if os.path.isfile(class_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1815 self.tk.call('source', class_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1816 if os.path.isfile(class_py):
42552
ac192f89c109 Kill execfile(), use exec() instead
Neal Norwitz <nnorwitz@gmail.com>
parents: 42309
diff changeset
1817 exec(open(class_py).read(), dir)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1818 if os.path.isfile(base_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1819 self.tk.call('source', base_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1820 if os.path.isfile(base_py):
42552
ac192f89c109 Kill execfile(), use exec() instead
Neal Norwitz <nnorwitz@gmail.com>
parents: 42309
diff changeset
1821 exec(open(base_py).read(), dir)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1822 def report_callback_exception(self, exc, val, tb):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1823 """Internal function. It reports exception on sys.stderr."""
73345
fa82071bb7e1 Remove redundant imports.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 73166
diff changeset
1824 import traceback
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1825 sys.stderr.write("Exception in Tkinter callback\n")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1826 sys.last_type = exc
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1827 sys.last_value = val
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1828 sys.last_traceback = tb
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1829 traceback.print_exception(exc, val, tb)
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1830 def __getattr__(self, attr):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1831 "Delegate attribute access to the interpreter object"
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1832 return getattr(self.tk, attr)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1833
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1834 # Ideally, the classes Pack, Place and Grid disappear, the
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1835 # pack/place/grid methods are defined on the Widget class, and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1836 # everybody uses w.pack_whatever(...) instead of Pack.whatever(w,
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1837 # ...), with pack(), place() and grid() being short for
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1838 # pack_configure(), place_configure() and grid_columnconfigure(), and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1839 # forget() being short for pack_forget(). As a practical matter, I'm
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1840 # afraid that there is too much code out there that may be using the
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1841 # Pack, Place or Grid class, so I leave them intact -- but only as
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1842 # backwards compatibility features. Also note that those methods that
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1843 # take a master as argument (e.g. pack_propagate) have been moved to
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1844 # the Misc class (which now incorporates all methods common between
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1845 # toplevel and interior widgets). Again, for compatibility, these are
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1846 # copied into the Pack, Place or Grid class.
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1847
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1848
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1849 def Tcl(screenName=None, baseName=None, className='Tk', useTk=0):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1850 return Tk(screenName, baseName, className, useTk)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1851
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1852 class Pack:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1853 """Geometry manager Pack.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1854
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1855 Base class to use the methods pack_* in every widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1856 def pack_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1857 """Pack a widget in the parent widget. Use as options:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1858 after=widget - pack it after you have packed widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1859 anchor=NSEW (or subset) - position widget according to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1860 given direction
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1861 before=widget - pack it before you will pack widget
28639
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
1862 expand=bool - expand widget if parent size grows
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1863 fill=NONE or X or Y or BOTH - fill widget if widget grows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1864 in=master - use master to contain this widget
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1865 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1866 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1867 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1868 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1869 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1870 side=TOP or BOTTOM or LEFT or RIGHT - where to add this widget.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1871 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1872 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1873 ('pack', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1874 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1875 pack = configure = config = pack_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1876 def pack_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1877 """Unmap this widget and do not use it for the packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1878 self.tk.call('pack', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1879 forget = pack_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1880 def pack_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1881 """Return information about the packing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1882 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1883 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1884 self.tk.call('pack', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1885 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1886 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1887 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1888 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1889 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1890 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1891 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1892 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1893 info = pack_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1894 propagate = pack_propagate = Misc.pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1895 slaves = pack_slaves = Misc.pack_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1896
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1897 class Place:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1898 """Geometry manager Place.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1899
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1900 Base class to use the methods place_* in every widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1901 def place_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1902 """Place a widget in the parent widget. Use as options:
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1903 in=master - master relative to which the widget is placed
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1904 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1905 x=amount - locate anchor of this widget at position x of master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1906 y=amount - locate anchor of this widget at position y of master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1907 relx=amount - locate anchor of this widget between 0.0 and 1.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1908 relative to width of master (1.0 is right edge)
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1909 rely=amount - locate anchor of this widget between 0.0 and 1.0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1910 relative to height of master (1.0 is bottom edge)
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1911 anchor=NSEW (or subset) - position anchor according to given direction
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1912 width=amount - width of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1913 height=amount - height of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1914 relwidth=amount - width of this widget between 0.0 and 1.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1915 relative to width of master (1.0 is the same width
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1916 as the master)
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1917 relheight=amount - height of this widget between 0.0 and 1.0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1918 relative to height of master (1.0 is the same
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1919 height as the master)
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1920 bordermode="inside" or "outside" - whether to take border width of
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1921 master widget into account
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1922 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1923 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1924 ('place', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1925 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1926 place = configure = config = place_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1927 def place_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1928 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1929 self.tk.call('place', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1930 forget = place_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1931 def place_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1932 """Return information about the placing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1933 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1934 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1935 self.tk.call('place', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1936 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1937 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1938 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1939 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1940 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1941 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1942 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1943 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1944 info = place_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1945 slaves = place_slaves = Misc.place_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1946
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1947 class Grid:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1948 """Geometry manager Grid.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1949
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1950 Base class to use the methods grid_* in every widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1951 # Thanks to Masazumi Yoshikawa (yosikawa@isi.edu)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1952 def grid_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1953 """Position a widget in the parent widget in a grid. Use as options:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1954 column=number - use cell identified with given column (starting with 0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1955 columnspan=number - this widget will span several columns
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1956 in=master - use master to contain this widget
47366
b6cbec499756 #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47278
diff changeset
1957 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1958 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1959 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1960 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1961 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1962 row=number - use cell identified with given row (starting with 0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1963 rowspan=number - this widget will span several rows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1964 sticky=NSEW - if cell is larger on which sides will this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1965 widget stick to the cell boundary
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1966 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1967 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1968 ('grid', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1969 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1970 grid = configure = config = grid_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1971 bbox = grid_bbox = Misc.grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1972 columnconfigure = grid_columnconfigure = Misc.grid_columnconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1973 def grid_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1974 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1975 self.tk.call('grid', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1976 forget = grid_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1977 def grid_remove(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1978 """Unmap this widget but remember the grid options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1979 self.tk.call('grid', 'remove', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1980 def grid_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1981 """Return information about the options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1982 for positioning this widget in a grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1983 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1984 self.tk.call('grid', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1985 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1986 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1987 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1988 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1989 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1990 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1991 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1992 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1993 info = grid_info
20414
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1994 location = grid_location = Misc.grid_location
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1995 propagate = grid_propagate = Misc.grid_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1996 rowconfigure = grid_rowconfigure = Misc.grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1997 size = grid_size = Misc.grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1998 slaves = grid_slaves = Misc.grid_slaves
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1999
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2000 class BaseWidget(Misc):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2001 """Internal class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2002 def _setup(self, master, cnf):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2003 """Internal function. Sets up information about children."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2004 if _support_default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2005 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2006 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2007 if not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2008 _default_root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2009 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2010 self.master = master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2011 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2012 name = None
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2013 if 'name' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2014 name = cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2015 del cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2016 if not name:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
2017 name = repr(id(self))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2018 self._name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2019 if master._w=='.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2020 self._w = '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2021 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2022 self._w = master._w + '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2023 self.children = {}
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2024 if self._name in self.master.children:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2025 self.master.children[self._name].destroy()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2026 self.master.children[self._name] = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2027 def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2028 """Construct a widget with the parent widget MASTER, a name WIDGETNAME
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2029 and appropriate options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2030 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2031 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2032 self.widgetName = widgetName
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2033 BaseWidget._setup(self, master, cnf)
49639
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2034 if self._tclCommands is None:
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2035 self._tclCommands = []
49013
5c10af8d33f5 Issue #1658: dict size is changing during iteration in tkinter.BaseWidget and
Guilherme Polo <ggpolo@gmail.com>
parents: 48823
diff changeset
2036 classes = [(k, v) for k, v in cnf.items() if isinstance(k, type)]
5c10af8d33f5 Issue #1658: dict size is changing during iteration in tkinter.BaseWidget and
Guilherme Polo <ggpolo@gmail.com>
parents: 48823
diff changeset
2037 for k, v in classes:
5c10af8d33f5 Issue #1658: dict size is changing during iteration in tkinter.BaseWidget and
Guilherme Polo <ggpolo@gmail.com>
parents: 48823
diff changeset
2038 del cnf[k]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2039 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2040 (widgetName, self._w) + extra + self._options(cnf))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2041 for k, v in classes:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2042 k.configure(self, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2043 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2044 """Destroy this and all descendants widgets."""
42193
090588a17490 Merged revisions 56154-56264 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42050
diff changeset
2045 for c in list(self.children.values()): c.destroy()
39442
654c380cf8b9 Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
2046 self.tk.call('destroy', self._w)
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2047 if self._name in self.master.children:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2048 del self.master.children[self._name]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2049 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2050 def _do(self, name, args=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2051 # XXX Obsolete -- better use self.tk.call directly!
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2052 return self.tk.call((self._w, name) + args)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2053
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2054 class Widget(BaseWidget, Pack, Place, Grid):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2055 """Internal class.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2056
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2057 Base class for a widget which can be positioned with the geometry managers
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2058 Pack, Place or Grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2059 pass
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2060
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2061 class Toplevel(BaseWidget, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2062 """Toplevel widget, e.g. for dialogs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2063 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2064 """Construct a toplevel widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2065
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2066 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2067 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2068 highlightcolor, highlightthickness, menu, relief, screen, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2069 use, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2070 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2071 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2072 extra = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2073 for wmkey in ['screen', 'class_', 'class', 'visual',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2074 'colormap']:
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2075 if wmkey in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2076 val = cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2077 # TBD: a hack needed because some keys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2078 # are not valid as keyword arguments
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2079 if wmkey[-1] == '_': opt = '-'+wmkey[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2080 else: opt = '-'+wmkey
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2081 extra = extra + (opt, val)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2082 del cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2083 BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2084 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2085 self.iconname(root.iconname())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2086 self.title(root.title())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2087 self.protocol("WM_DELETE_WINDOW", self.destroy)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2088
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2089 class Button(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2090 """Button widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2091 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2092 """Construct a button widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2093
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2094 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2095
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2096 activebackground, activeforeground, anchor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2097 background, bitmap, borderwidth, cursor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2098 disabledforeground, font, foreground
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2099 highlightbackground, highlightcolor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2100 highlightthickness, image, justify,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2101 padx, pady, relief, repeatdelay,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2102 repeatinterval, takefocus, text,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2103 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2104
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2105 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2106
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2107 command, compound, default, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2108 overrelief, state, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2109 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2110 Widget.__init__(self, master, 'button', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2111
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2112 def tkButtonEnter(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2113 self.tk.call('tkButtonEnter', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2114
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2115 def tkButtonLeave(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2116 self.tk.call('tkButtonLeave', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2117
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2118 def tkButtonDown(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2119 self.tk.call('tkButtonDown', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2120
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2121 def tkButtonUp(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2122 self.tk.call('tkButtonUp', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2123
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2124 def tkButtonInvoke(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2125 self.tk.call('tkButtonInvoke', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2126
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2127 def flash(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2128 """Flash the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2129
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2130 This is accomplished by redisplaying
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2131 the button several times, alternating between active and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2132 normal colors. At the end of the flash the button is left
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2133 in the same normal/active state as when the command was
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2134 invoked. This command is ignored if the button's state is
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2135 disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2136 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2137 self.tk.call(self._w, 'flash')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2138
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2139 def invoke(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2140 """Invoke the command associated with the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2141
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2142 The return value is the return value from the command,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2143 or an empty string if there is no command associated with
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2144 the button. This command is ignored if the button's state
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2145 is disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2146 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2147 return self.tk.call(self._w, 'invoke')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2148
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2149 class Canvas(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2150 """Canvas widget to display graphical elements like lines or text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2151 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2152 """Construct a canvas widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2153
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2154 Valid resource names: background, bd, bg, borderwidth, closeenough,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2155 confine, cursor, height, highlightbackground, highlightcolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2156 highlightthickness, insertbackground, insertborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2157 insertofftime, insertontime, insertwidth, offset, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2158 scrollregion, selectbackground, selectborderwidth, selectforeground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2159 state, takefocus, width, xscrollcommand, xscrollincrement,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2160 yscrollcommand, yscrollincrement."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2161 Widget.__init__(self, master, 'canvas', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2162 def addtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2163 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2164 self.tk.call((self._w, 'addtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2165 def addtag_above(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2166 """Add tag NEWTAG to all items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2167 self.addtag(newtag, 'above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2168 def addtag_all(self, newtag):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2169 """Add tag NEWTAG to all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2170 self.addtag(newtag, 'all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2171 def addtag_below(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2172 """Add tag NEWTAG to all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2173 self.addtag(newtag, 'below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2174 def addtag_closest(self, newtag, x, y, halo=None, start=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2175 """Add tag NEWTAG to item which is closest to pixel at X, Y.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2176 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2177 All items closer than HALO are considered overlapping (all are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2178 closests). If START is specified the next below this tag is taken."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2179 self.addtag(newtag, 'closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2180 def addtag_enclosed(self, newtag, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2181 """Add tag NEWTAG to all items in the rectangle defined
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2182 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2183 self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2184 def addtag_overlapping(self, newtag, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2185 """Add tag NEWTAG to all items which overlap the rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2186 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2187 self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2188 def addtag_withtag(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2189 """Add tag NEWTAG to all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2190 self.addtag(newtag, 'withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2191 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2192 """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2193 which encloses all items with tags specified as arguments."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2194 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2195 self.tk.call((self._w, 'bbox') + args)) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2196 def tag_unbind(self, tagOrId, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2197 """Unbind for all items with TAGORID for event SEQUENCE the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2198 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2199 self.tk.call(self._w, 'bind', tagOrId, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2200 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2201 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2202 def tag_bind(self, tagOrId, sequence=None, func=None, add=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2203 """Bind to all items with TAGORID at event SEQUENCE a call to function FUNC.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2204
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2205 An additional boolean parameter ADD specifies whether FUNC will be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2206 called additionally to the other bound function or whether it will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2207 replace the previous function. See bind for the return value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2208 return self._bind((self._w, 'bind', tagOrId),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2209 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2210 def canvasx(self, screenx, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2211 """Return the canvas x coordinate of pixel position SCREENX rounded
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2212 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2213 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2214 self._w, 'canvasx', screenx, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2215 def canvasy(self, screeny, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2216 """Return the canvas y coordinate of pixel position SCREENY rounded
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2217 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2218 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2219 self._w, 'canvasy', screeny, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2220 def coords(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2221 """Return a list of coordinates for the item given in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2222 # XXX Should use _flatten on args
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
2223 return [getdouble(x) for x in
8390
76cd03979fca Get rid of nearly all clals to self._do -- turns out self.tk.call can
Guido van Rossum <guido@python.org>
parents: 8211
diff changeset
2224 self.tk.splitlist(
66407
cc9c51f9524f Merged revisions 86697 via svnmerge from
Alexander Belopolsky <alexander.belopolsky@gmail.com>
parents: 54475
diff changeset
2225 self.tk.call((self._w, 'coords') + args))]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2226 def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={})
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2227 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2228 args = _flatten(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2229 cnf = args[-1]
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
2230 if isinstance(cnf, (dict, tuple)):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2231 args = args[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2232 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2233 cnf = {}
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2234 return getint(self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2235 self._w, 'create', itemType,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2236 *(args + self._options(cnf, kw))))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2237 def create_arc(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2238 """Create arc shaped region with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2239 return self._create('arc', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2240 def create_bitmap(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2241 """Create bitmap with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2242 return self._create('bitmap', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2243 def create_image(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2244 """Create image item with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2245 return self._create('image', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2246 def create_line(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2247 """Create line with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2248 return self._create('line', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2249 def create_oval(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2250 """Create oval with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2251 return self._create('oval', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2252 def create_polygon(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2253 """Create polygon with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2254 return self._create('polygon', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2255 def create_rectangle(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2256 """Create rectangle with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2257 return self._create('rectangle', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2258 def create_text(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2259 """Create text with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2260 return self._create('text', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2261 def create_window(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2262 """Create window with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2263 return self._create('window', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2264 def dchars(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2265 """Delete characters of text items identified by tag or id in ARGS (possibly
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2266 several times) from FIRST to LAST character (including)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2267 self.tk.call((self._w, 'dchars') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2268 def delete(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2269 """Delete items identified by all tag or ids contained in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2270 self.tk.call((self._w, 'delete') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2271 def dtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2272 """Delete tag or id given as last arguments in ARGS from items
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2273 identified by first argument in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2274 self.tk.call((self._w, 'dtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2275 def find(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2276 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2277 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2278 self.tk.call((self._w, 'find') + args)) or ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2279 def find_above(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2280 """Return items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2281 return self.find('above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2282 def find_all(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2283 """Return all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2284 return self.find('all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2285 def find_below(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2286 """Return all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2287 return self.find('below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2288 def find_closest(self, x, y, halo=None, start=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2289 """Return item which is closest to pixel at X, Y.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2290 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2291 All items closer than HALO are considered overlapping (all are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2292 closests). If START is specified the next below this tag is taken."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2293 return self.find('closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2294 def find_enclosed(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2295 """Return all items in rectangle defined
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2296 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2297 return self.find('enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2298 def find_overlapping(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2299 """Return all items which overlap the rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2300 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2301 return self.find('overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2302 def find_withtag(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2303 """Return all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2304 return self.find('withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2305 def focus(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2306 """Set focus to the first item specified in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2307 return self.tk.call((self._w, 'focus') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2308 def gettags(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2309 """Return tags associated with the first item specified in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2310 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2311 self.tk.call((self._w, 'gettags') + args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2312 def icursor(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2313 """Set cursor at position POS in the item identified by TAGORID.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2314 In ARGS TAGORID must be first."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2315 self.tk.call((self._w, 'icursor') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2316 def index(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2317 """Return position of cursor as integer in item specified in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2318 return getint(self.tk.call((self._w, 'index') + args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2319 def insert(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2320 """Insert TEXT in item TAGORID at position POS. ARGS must
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2321 be TAGORID POS TEXT."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2322 self.tk.call((self._w, 'insert') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2323 def itemcget(self, tagOrId, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2324 """Return the resource value for an OPTION for item TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2325 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2326 (self._w, 'itemcget') + (tagOrId, '-'+option))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2327 def itemconfigure(self, tagOrId, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2328 """Configure resources of an item TAGORID.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2329
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2330 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2331 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2332 the allowed keyword arguments call the method without arguments.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2333 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2334 return self._configure(('itemconfigure', tagOrId), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2335 itemconfig = itemconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2336 # lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2337 # so the preferred name for them is tag_lower, tag_raise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2338 # (similar to tag_bind, and similar to the Text widget);
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2339 # unfortunately can't delete the old ones yet (maybe in 1.6)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2340 def tag_lower(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2341 """Lower an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2342 (optional below another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2343 self.tk.call((self._w, 'lower') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2344 lower = tag_lower
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2345 def move(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2346 """Move an item TAGORID given in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2347 self.tk.call((self._w, 'move') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2348 def postscript(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2349 """Print the contents of the canvas to a postscript
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2350 file. Valid options: colormap, colormode, file, fontmap,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2351 height, pageanchor, pageheight, pagewidth, pagex, pagey,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2352 rotate, witdh, x, y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2353 return self.tk.call((self._w, 'postscript') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2354 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2355 def tag_raise(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2356 """Raise an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2357 (optional above another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2358 self.tk.call((self._w, 'raise') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2359 lift = tkraise = tag_raise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2360 def scale(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2361 """Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2362 self.tk.call((self._w, 'scale') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2363 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2364 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2365 self.tk.call(self._w, 'scan', 'mark', x, y)
27211
a494f5a8639f Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Neal Norwitz <nnorwitz@gmail.com>
parents: 26428
diff changeset
2366 def scan_dragto(self, x, y, gain=10):
a494f5a8639f Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Neal Norwitz <nnorwitz@gmail.com>
parents: 26428
diff changeset
2367 """Adjust the view of the canvas to GAIN times the
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2368 difference between X and Y and the coordinates given in
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2369 scan_mark."""
27211
a494f5a8639f Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Neal Norwitz <nnorwitz@gmail.com>
parents: 26428
diff changeset
2370 self.tk.call(self._w, 'scan', 'dragto', x, y, gain)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2371 def select_adjust(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2372 """Adjust the end of the selection near the cursor of an item TAGORID to index."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2373 self.tk.call(self._w, 'select', 'adjust', tagOrId, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2374 def select_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2375 """Clear the selection if it is in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2376 self.tk.call(self._w, 'select', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2377 def select_from(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2378 """Set the fixed end of a selection in item TAGORID to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2379 self.tk.call(self._w, 'select', 'from', tagOrId, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2380 def select_item(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2381 """Return the item which has the selection."""
24357
17e94e62353c SF patch #581396, Canvas "select_item" always returns None
Neal Norwitz <nnorwitz@gmail.com>
parents: 23241
diff changeset
2382 return self.tk.call(self._w, 'select', 'item') or None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2383 def select_to(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2384 """Set the variable end of a selection in item TAGORID to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2385 self.tk.call(self._w, 'select', 'to', tagOrId, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2386 def type(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2387 """Return the type of the item TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2388 return self.tk.call(self._w, 'type', tagOrId) or None
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2389
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2390 class Checkbutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2391 """Checkbutton widget which is either in on- or off-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2392 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2393 """Construct a checkbutton widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2394
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2395 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2396 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2397 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2398 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2399 indicatoron, justify, offvalue, onvalue, padx, pady, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2400 selectcolor, selectimage, state, takefocus, text, textvariable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2401 underline, variable, width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2402 Widget.__init__(self, master, 'checkbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2403 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2404 """Put the button in off-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2405 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2406 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2407 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2408 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2409 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2410 """Toggle the button and invoke a command if given as resource."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2411 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2412 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2413 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2414 self.tk.call(self._w, 'select')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2415 def toggle(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2416 """Toggle the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2417 self.tk.call(self._w, 'toggle')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2418
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2419 class Entry(Widget, XView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2420 """Entry widget which allows to display simple text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2421 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2422 """Construct an entry widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2423
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2424 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2425 exportselection, fg, font, foreground, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2426 highlightcolor, highlightthickness, insertbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2427 insertborderwidth, insertofftime, insertontime, insertwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2428 invalidcommand, invcmd, justify, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2429 selectborderwidth, selectforeground, show, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2430 textvariable, validate, validatecommand, vcmd, width,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2431 xscrollcommand."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2432 Widget.__init__(self, master, 'entry', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2433 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2434 """Delete text from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2435 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2436 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2437 """Return the text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2438 return self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2439 def icursor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2440 """Insert cursor at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2441 self.tk.call(self._w, 'icursor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2442 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2443 """Return position of cursor."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2444 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2445 self._w, 'index', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2446 def insert(self, index, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2447 """Insert STRING at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2448 self.tk.call(self._w, 'insert', index, string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2449 def scan_mark(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2450 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2451 self.tk.call(self._w, 'scan', 'mark', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2452 def scan_dragto(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2453 """Adjust the view of the canvas to 10 times the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2454 difference between X and Y and the coordinates given in
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2455 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2456 self.tk.call(self._w, 'scan', 'dragto', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2457 def selection_adjust(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2458 """Adjust the end of the selection near the cursor to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2459 self.tk.call(self._w, 'selection', 'adjust', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2460 select_adjust = selection_adjust
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2461 def selection_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2462 """Clear the selection if it is in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2463 self.tk.call(self._w, 'selection', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2464 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2465 def selection_from(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2466 """Set the fixed end of a selection to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2467 self.tk.call(self._w, 'selection', 'from', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2468 select_from = selection_from
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2469 def selection_present(self):
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2470 """Return True if there are characters selected in the entry, False
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2471 otherwise."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2472 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2473 self.tk.call(self._w, 'selection', 'present'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2474 select_present = selection_present
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2475 def selection_range(self, start, end):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2476 """Set the selection from START to END (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2477 self.tk.call(self._w, 'selection', 'range', start, end)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2478 select_range = selection_range
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2479 def selection_to(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2480 """Set the variable end of a selection to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2481 self.tk.call(self._w, 'selection', 'to', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2482 select_to = selection_to
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2483
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2484 class Frame(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2485 """Frame widget which may contain other widgets and can have a 3D border."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2486 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2487 """Construct a frame widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2488
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2489 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2490 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2491 highlightcolor, highlightthickness, relief, takefocus, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2492 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2493 extra = ()
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2494 if 'class_' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2495 extra = ('-class', cnf['class_'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2496 del cnf['class_']
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
2497 elif 'class' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2498 extra = ('-class', cnf['class'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2499 del cnf['class']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2500 Widget.__init__(self, master, 'frame', cnf, {}, extra)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2501
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2502 class Label(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2503 """Label widget which can display text and bitmaps."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2504 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2505 """Construct a label widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2506
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2507 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2508
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2509 activebackground, activeforeground, anchor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2510 background, bitmap, borderwidth, cursor,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2511 disabledforeground, font, foreground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2512 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2513 highlightthickness, image, justify,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2514 padx, pady, relief, takefocus, text,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2515 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2516
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2517 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2518
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2519 height, state, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2520
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2521 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2522 Widget.__init__(self, master, 'label', cnf, kw)
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 2585
diff changeset
2523
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2524 class Listbox(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2525 """Listbox widget which can display a list of strings."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2526 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2527 """Construct a listbox widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2528
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2529 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2530 exportselection, fg, font, foreground, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2531 highlightcolor, highlightthickness, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2532 selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2533 width, xscrollcommand, yscrollcommand, listvariable."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2534 Widget.__init__(self, master, 'listbox', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2535 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2536 """Activate item identified by INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2537 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2538 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2539 """Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2540 which encloses the item identified by index in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2541 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2542 self.tk.call((self._w, 'bbox') + args)) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2543 def curselection(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2544 """Return list of indices of currently selected item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2545 # XXX Ought to apply self._getints()...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2546 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2547 self._w, 'curselection'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2548 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2549 """Delete items from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2550 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2551 def get(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2552 """Get list of items from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2553 if last:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2554 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2555 self._w, 'get', first, last))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2556 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2557 return self.tk.call(self._w, 'get', first)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2558 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2559 """Return index of item identified with INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2560 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2561 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2562 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2563 def insert(self, index, *elements):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2564 """Insert ELEMENTS at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2565 self.tk.call((self._w, 'insert', index) + elements)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2566 def nearest(self, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2567 """Get index of item which is nearest to y coordinate Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2568 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2569 self._w, 'nearest', y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2570 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2571 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2572 self.tk.call(self._w, 'scan', 'mark', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2573 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2574 """Adjust the view of the listbox to 10 times the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2575 difference between X and Y and the coordinates given in
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2576 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2577 self.tk.call(self._w, 'scan', 'dragto', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2578 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2579 """Scroll such that INDEX is visible."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2580 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2581 def selection_anchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2582 """Set the fixed end oft the selection to INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2583 self.tk.call(self._w, 'selection', 'anchor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2584 select_anchor = selection_anchor
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2585 def selection_clear(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2586 """Clear the selection from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2587 self.tk.call(self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2588 'selection', 'clear', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2589 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2590 def selection_includes(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2591 """Return 1 if INDEX is part of the selection."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2592 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2593 self._w, 'selection', 'includes', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2594 select_includes = selection_includes
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2595 def selection_set(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2596 """Set the selection from FIRST to LAST (not included) without
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2597 changing the currently selected elements."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2598 self.tk.call(self._w, 'selection', 'set', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2599 select_set = selection_set
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2600 def size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2601 """Return the number of elements in the listbox."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2602 return getint(self.tk.call(self._w, 'size'))
19743
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2603 def itemcget(self, index, option):
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2604 """Return the resource value for an ITEM and an OPTION."""
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2605 return self.tk.call(
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2606 (self._w, 'itemcget') + (index, '-'+option))
19638
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2607 def itemconfigure(self, index, cnf=None, **kw):
19743
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2608 """Configure resources of an ITEM.
19638
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2609
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2610 The values for resources are specified as keyword arguments.
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2611 To get an overview about the allowed keyword arguments
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2612 call the method without arguments.
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2613 Valid resource names: background, bg, foreground, fg,
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2614 selectbackground, selectforeground."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2615 return self._configure(('itemconfigure', index), cnf, kw)
19638
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2616 itemconfig = itemconfigure
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2617
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2618 class Menu(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2619 """Menu widget which allows to display menu bars, pull-down menus and pop-up menus."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2620 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2621 """Construct menu widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2622
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2623 Valid resource names: activebackground, activeborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2624 activeforeground, background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2625 disabledforeground, fg, font, foreground, postcommand, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2626 selectcolor, takefocus, tearoff, tearoffcommand, title, type."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2627 Widget.__init__(self, master, 'menu', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2628 def tk_bindForTraversal(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2629 pass # obsolete since Tk 4.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2630 def tk_mbPost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2631 self.tk.call('tk_mbPost', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2632 def tk_mbUnpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2633 self.tk.call('tk_mbUnpost')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2634 def tk_traverseToMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2635 self.tk.call('tk_traverseToMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2636 def tk_traverseWithinMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2637 self.tk.call('tk_traverseWithinMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2638 def tk_getMenuButtons(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2639 return self.tk.call('tk_getMenuButtons', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2640 def tk_nextMenu(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2641 self.tk.call('tk_nextMenu', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2642 def tk_nextMenuEntry(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2643 self.tk.call('tk_nextMenuEntry', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2644 def tk_invokeMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2645 self.tk.call('tk_invokeMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2646 def tk_firstMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2647 self.tk.call('tk_firstMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2648 def tk_mbButtonDown(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2649 self.tk.call('tk_mbButtonDown', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2650 def tk_popup(self, x, y, entry=""):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2651 """Post the menu at position X,Y with entry ENTRY."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2652 self.tk.call('tk_popup', self._w, x, y, entry)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2653 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2654 """Activate entry at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2655 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2656 def add(self, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2657 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2658 self.tk.call((self._w, 'add', itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2659 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2660 def add_cascade(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2661 """Add hierarchical menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2662 self.add('cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2663 def add_checkbutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2664 """Add checkbutton menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2665 self.add('checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2666 def add_command(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2667 """Add command menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2668 self.add('command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2669 def add_radiobutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2670 """Addd radio menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2671 self.add('radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2672 def add_separator(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2673 """Add separator."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2674 self.add('separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2675 def insert(self, index, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2676 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2677 self.tk.call((self._w, 'insert', index, itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2678 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2679 def insert_cascade(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2680 """Add hierarchical menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2681 self.insert(index, 'cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2682 def insert_checkbutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2683 """Add checkbutton menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2684 self.insert(index, 'checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2685 def insert_command(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2686 """Add command menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2687 self.insert(index, 'command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2688 def insert_radiobutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2689 """Addd radio menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2690 self.insert(index, 'radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2691 def insert_separator(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2692 """Add separator at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2693 self.insert(index, 'separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2694 def delete(self, index1, index2=None):
49639
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2695 """Delete menu items between INDEX1 and INDEX2 (included)."""
48676
054dc111b1d9 Merged revisions 65622 via svnmerge from
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48619
diff changeset
2696 if index2 is None:
054dc111b1d9 Merged revisions 65622 via svnmerge from
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48619
diff changeset
2697 index2 = index1
49639
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2698
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2699 num_index1, num_index2 = self.index(index1), self.index(index2)
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2700 if (num_index1 is None) or (num_index2 is None):
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2701 num_index1, num_index2 = 0, -1
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2702
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2703 for i in range(num_index1, num_index2 + 1):
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2704 if 'command' in self.entryconfig(i):
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2705 c = str(self.entrycget(i, 'command'))
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2706 if c:
f67b2c8fa93a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 49013
diff changeset
2707 self.deletecommand(c)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2708 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2709 def entrycget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2710 """Return the resource value of an menu item for OPTION at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2711 return self.tk.call(self._w, 'entrycget', index, '-' + option)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2712 def entryconfigure(self, index, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2713 """Configure a menu item at INDEX."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2714 return self._configure(('entryconfigure', index), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2715 entryconfig = entryconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2716 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2717 """Return the index of a menu item identified by INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2718 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2719 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2720 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2721 def invoke(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2722 """Invoke a menu item identified by INDEX and execute
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2723 the associated command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2724 return self.tk.call(self._w, 'invoke', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2725 def post(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2726 """Display a menu at position X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2727 self.tk.call(self._w, 'post', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2728 def type(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2729 """Return the type of the menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2730 return self.tk.call(self._w, 'type', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2731 def unpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2732 """Unmap a menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2733 self.tk.call(self._w, 'unpost')
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2734 def xposition(self, index): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2735 """Return the x-position of the leftmost pixel of the menu item
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2736 at INDEX."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2737 return getint(self.tk.call(self._w, 'xposition', index))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2738 def yposition(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2739 """Return the y-position of the topmost pixel of the menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2740 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2741 self._w, 'yposition', index))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2742
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2743 class Menubutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2744 """Menubutton widget, obsolete since Tk8.0."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2745 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2746 Widget.__init__(self, master, 'menubutton', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2747
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2748 class Message(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2749 """Message widget to display multiline text. Obsolete since Label does it too."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2750 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2751 Widget.__init__(self, master, 'message', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2752
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2753 class Radiobutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2754 """Radiobutton widget which shows only one of several buttons in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2755 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2756 """Construct a radiobutton widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2757
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2758 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2759 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2760 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2761 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2762 indicatoron, justify, padx, pady, relief, selectcolor, selectimage,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2763 state, takefocus, text, textvariable, underline, value, variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2764 width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2765 Widget.__init__(self, master, 'radiobutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2766 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2767 """Put the button in off-state."""
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2768
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2769 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2770 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2771 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2772 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2773 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2774 """Toggle the button and invoke a command if given as resource."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2775 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2776 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2777 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2778 self.tk.call(self._w, 'select')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2779
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2780 class Scale(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2781 """Scale widget which can display a numerical scale."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2782 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2783 """Construct a scale widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2784
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2785 Valid resource names: activebackground, background, bigincrement, bd,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2786 bg, borderwidth, command, cursor, digits, fg, font, foreground, from,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2787 highlightbackground, highlightcolor, highlightthickness, label,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2788 length, orient, relief, repeatdelay, repeatinterval, resolution,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2789 showvalue, sliderlength, sliderrelief, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2790 tickinterval, to, troughcolor, variable, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2791 Widget.__init__(self, master, 'scale', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2792 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2793 """Get the current value as integer or float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2794 value = self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2795 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2796 return getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2797 except ValueError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2798 return getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2799 def set(self, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2800 """Set the value to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2801 self.tk.call(self._w, 'set', value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2802 def coords(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2803 """Return a tuple (X,Y) of the point along the centerline of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2804 trough that corresponds to VALUE or the current value if None is
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2805 given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2806
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2807 return self._getints(self.tk.call(self._w, 'coords', value))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2808 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2809 """Return where the point X,Y lies. Valid return values are "slider",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2810 "though1" and "though2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2811 return self.tk.call(self._w, 'identify', x, y)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2812
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2813 class Scrollbar(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2814 """Scrollbar widget which displays a slider at a certain position."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2815 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2816 """Construct a scrollbar widget with the parent MASTER.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2817
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2818 Valid resource names: activebackground, activerelief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2819 background, bd, bg, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2820 elementborderwidth, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2821 highlightcolor, highlightthickness, jump, orient,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2822 relief, repeatdelay, repeatinterval, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2823 troughcolor, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2824 Widget.__init__(self, master, 'scrollbar', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2825 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2826 """Display the element at INDEX with activebackground and activerelief.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2827 INDEX can be "arrow1","slider" or "arrow2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2828 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2829 def delta(self, deltax, deltay):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2830 """Return the fractional change of the scrollbar setting if it
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2831 would be moved by DELTAX or DELTAY pixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2832 return getdouble(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2833 self.tk.call(self._w, 'delta', deltax, deltay))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2834 def fraction(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2835 """Return the fractional value which corresponds to a slider
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2836 position of X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2837 return getdouble(self.tk.call(self._w, 'fraction', x, y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2838 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2839 """Return the element under position X,Y as one of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2840 "arrow1","slider","arrow2" or ""."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2841 return self.tk.call(self._w, 'identify', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2842 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2843 """Return the current fractional values (upper and lower end)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2844 of the slider position."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2845 return self._getdoubles(self.tk.call(self._w, 'get'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2846 def set(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2847 """Set the fractional values of the slider position (upper and
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2848 lower ends as value between 0 and 1)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2849 self.tk.call((self._w, 'set') + args)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2850
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2851
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2852
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
2853 class Text(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2854 """Text widget which can display text in various forms."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2855 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2856 """Construct a text widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2857
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2858 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2859
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2860 background, borderwidth, cursor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2861 exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2862 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2863 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2864 insertborderwidth, insertofftime,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2865 insertontime, insertwidth, padx, pady,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2866 relief, selectbackground,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2867 selectborderwidth, selectforeground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2868 setgrid, takefocus,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2869 xscrollcommand, yscrollcommand,
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2870
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2871 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2872
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2873 autoseparators, height, maxundo,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2874 spacing1, spacing2, spacing3,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2875 state, tabs, undo, width, wrap,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2876
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2877 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2878 Widget.__init__(self, master, 'text', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2879 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2880 """Return a tuple of (x,y,width,height) which gives the bounding
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2881 box of the visible part of the character at the index in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2882 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2883 self.tk.call((self._w, 'bbox') + args)) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2884 def tk_textSelectTo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2885 self.tk.call('tk_textSelectTo', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2886 def tk_textBackspace(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2887 self.tk.call('tk_textBackspace', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2888 def tk_textIndexCloser(self, a, b, c):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2889 self.tk.call('tk_textIndexCloser', self._w, a, b, c)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2890 def tk_textResetAnchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2891 self.tk.call('tk_textResetAnchor', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2892 def compare(self, index1, op, index2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2893 """Return whether between index INDEX1 and index INDEX2 the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2894 relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2895 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2896 self._w, 'compare', index1, op, index2))
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2897 def count(self, index1, index2, *args): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2898 """Counts the number of relevant things between the two indices.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2899 If index1 is after index2, the result will be a negative number
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2900 (and this holds for each of the possible options).
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2901
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2902 The actual items which are counted depends on the options given by
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2903 args. The result is a list of integers, one for the result of each
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2904 counting option given. Valid counting options are "chars",
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2905 "displaychars", "displayindices", "displaylines", "indices",
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2906 "lines", "xpixels" and "ypixels". There is an additional possible
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2907 option "update", which if given then all subsequent options ensure
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2908 that any possible out of date information is recalculated."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2909 args = ['-%s' % arg for arg in args if not arg.startswith('-')]
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2910 args += [index1, index2]
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2911 res = self.tk.call(self._w, 'count', *args) or None
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2912 if res is not None and len(args) <= 3:
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2913 return (res, )
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2914 else:
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
2915 return res
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2916 def debug(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2917 """Turn on the internal consistency checks of the B-Tree inside the text
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2918 widget according to BOOLEAN."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2919 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2920 self._w, 'debug', boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2921 def delete(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2922 """Delete the characters between INDEX1 and INDEX2 (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2923 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2924 def dlineinfo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2925 """Return tuple (x,y,width,height,baseline) giving the bounding box
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2926 and baseline position of the visible part of the line containing
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2927 the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2928 return self._getints(self.tk.call(self._w, 'dlineinfo', index))
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2929 def dump(self, index1, index2=None, command=None, **kw):
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2930 """Return the contents of the widget between index1 and index2.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2931
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2932 The type of contents returned in filtered based on the keyword
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2933 parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2934 given and true, then the corresponding items are returned. The result
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2935 is a list of triples of the form (key, value, index). If none of the
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2936 keywords are true then 'all' is used by default.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2937
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2938 If the 'command' argument is given, it is called once for each element
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2939 of the list of triples, with the values of each triple serving as the
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2940 arguments to the function. In this case the list is not returned."""
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2941 args = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2942 func_name = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2943 result = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2944 if not command:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2945 # Never call the dump command without the -command flag, since the
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2946 # output could involve Tcl quoting and would be a pain to parse
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2947 # right. Instead just set the command to build a list of triples
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2948 # as if we had done the parsing.
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2949 result = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2950 def append_triple(key, value, index, result=result):
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2951 result.append((key, value, index))
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2952 command = append_triple
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2953 try:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2954 if not isinstance(command, str):
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2955 func_name = command = self._register(command)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2956 args += ["-command", command]
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2957 for key in kw:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2958 if kw[key]: args.append("-" + key)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2959 args.append(index1)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2960 if index2:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2961 args.append(index2)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2962 self.tk.call(self._w, "dump", *args)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2963 return result
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2964 finally:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2965 if func_name:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2966 self.deletecommand(func_name)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2967
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2968 ## new in tk8.4
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2969 def edit(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2970 """Internal method
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2971
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2972 This method controls the undo mechanism and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2973 the modified flag. The exact behavior of the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2974 command depends on the option argument that
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2975 follows the edit argument. The following forms
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2976 of the command are currently supported:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2977
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2978 edit_modified, edit_redo, edit_reset, edit_separator
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2979 and edit_undo
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2980
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2981 """
47278
f762a9ab69dd Merged revisions 63412,63445-63447,63449-63450,63452,63454,63459,63463,63465,63470,63483-63484,63496-63497,63499-63501,63530-63531,63540,63614 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47130
diff changeset
2982 return self.tk.call(self._w, 'edit', *args)
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2983
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2984 def edit_modified(self, arg=None):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2985 """Get or Set the modified flag
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2986
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2987 If arg is not specified, returns the modified
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2988 flag of the widget. The insert, delete, edit undo and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2989 edit redo commands or the user can set or clear the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2990 modified flag. If boolean is specified, sets the
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2991 modified flag of the widget to arg.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2992 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2993 return self.edit("modified", arg)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2994
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2995 def edit_redo(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2996 """Redo the last undone edit
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2997
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2998 When the undo option is true, reapplies the last
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2999 undone edits provided no other edits were done since
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3000 then. Generates an error when the redo stack is empty.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3001 Does nothing when the undo option is false.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3002 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3003 return self.edit("redo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3004
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3005 def edit_reset(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3006 """Clears the undo and redo stacks
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3007 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3008 return self.edit("reset")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3009
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3010 def edit_separator(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3011 """Inserts a separator (boundary) on the undo stack.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3012
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3013 Does nothing when the undo option is false
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3014 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3015 return self.edit("separator")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3016
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3017 def edit_undo(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3018 """Undoes the last edit action
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3019
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3020 If the undo option is true. An edit action is defined
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3021 as all the insert and delete commands that are recorded
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3022 on the undo stack in between two separators. Generates
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3023 an error when the undo stack is empty. Does nothing
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3024 when the undo option is false
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3025 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3026 return self.edit("undo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3027
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3028 def get(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3029 """Return the text from INDEX1 to INDEX2 (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3030 return self.tk.call(self._w, 'get', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3031 # (Image commands are new in 8.0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3032 def image_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3033 """Return the value of OPTION of an embedded image at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3034 if option[:1] != "-":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3035 option = "-" + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3036 if option[-1:] == "_":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3037 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3038 return self.tk.call(self._w, "image", "cget", index, option)
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3039 def image_configure(self, index, cnf=None, **kw):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3040 """Configure an embedded image at INDEX."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3041 return self._configure(('image', 'configure', index), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3042 def image_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3043 """Create an embedded image at INDEX."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3044 return self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3045 self._w, "image", "create", index,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3046 *self._options(cnf, kw))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3047 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3048 """Return all names of embedded images in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3049 return self.tk.call(self._w, "image", "names")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3050 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3051 """Return the index in the form line.char for INDEX."""
44428
6e93d2d6eb28 Merged revisions 59642-59665 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44026
diff changeset
3052 return str(self.tk.call(self._w, 'index', index))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3053 def insert(self, index, chars, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3054 """Insert CHARS before the characters at INDEX. An additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3055 tag can be given in ARGS. Additional CHARS and tags can follow in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3056 self.tk.call((self._w, 'insert', index, chars) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3057 def mark_gravity(self, markName, direction=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3058 """Change the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3059 Return the current value if None is given for DIRECTION."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3060 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3061 (self._w, 'mark', 'gravity', markName, direction))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3062 def mark_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3063 """Return all mark names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3064 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3065 self._w, 'mark', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3066 def mark_set(self, markName, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3067 """Set mark MARKNAME before the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3068 self.tk.call(self._w, 'mark', 'set', markName, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3069 def mark_unset(self, *markNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3070 """Delete all marks in MARKNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3071 self.tk.call((self._w, 'mark', 'unset') + markNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3072 def mark_next(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3073 """Return the name of the next mark after INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3074 return self.tk.call(self._w, 'mark', 'next', index) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3075 def mark_previous(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3076 """Return the name of the previous mark before INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3077 return self.tk.call(self._w, 'mark', 'previous', index) or None
75598
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3078 def peer_create(self, newPathName, cnf={}, **kw): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3079 """Creates a peer text widget with the given newPathName, and any
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3080 optional standard configuration options. By default the peer will
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3081 have the same start and and end line as the parent widget, but
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3082 these can be overriden with the standard configuration options."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3083 self.tk.call(self._w, 'peer', 'create', newPathName,
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3084 *self._options(cnf, kw))
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3085 def peer_names(self): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3086 """Returns a list of peers of this widget (this does not include
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3087 the widget itself)."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3088 return self.tk.splitlist(self.tk.call(self._w, 'peer', 'names'))
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3089 def replace(self, index1, index2, chars, *args): # new in Tk 8.5
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3090 """Replaces the range of characters between index1 and index2 with
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3091 the given characters and tags specified by args.
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3092
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3093 See the method insert for some more information about args, and the
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3094 method delete for information about the indices."""
71041c0dedd5 Issue #2843: Add new Tk API to Tkinter.
Martin v. Löwis <martin@v.loewis.de>
parents: 75569
diff changeset
3095 self.tk.call(self._w, 'replace', index1, index2, chars, *args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3096 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3097 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3098 self.tk.call(self._w, 'scan', 'mark', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3099 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3100 """Adjust the view of the text to 10 times the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3101 difference between X and Y and the coordinates given in
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3102 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3103 self.tk.call(self._w, 'scan', 'dragto', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3104 def search(self, pattern, index, stopindex=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3105 forwards=None, backwards=None, exact=None,
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39782
diff changeset
3106 regexp=None, nocase=None, count=None, elide=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3107 """Search PATTERN beginning from INDEX until STOPINDEX.
51484
663ce74d5175 Merged revisions 69463 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 50532
diff changeset
3108 Return the index of the first character of a match or an
663ce74d5175 Merged revisions 69463 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 50532
diff changeset
3109 empty string."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3110 args = [self._w, 'search']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3111 if forwards: args.append('-forwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3112 if backwards: args.append('-backwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3113 if exact: args.append('-exact')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3114 if regexp: args.append('-regexp')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3115 if nocase: args.append('-nocase')
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39782
diff changeset
3116 if elide: args.append('-elide')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3117 if count: args.append('-count'); args.append(count)
51484
663ce74d5175 Merged revisions 69463 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 50532
diff changeset
3118 if pattern and pattern[0] == '-': args.append('--')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3119 args.append(pattern)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3120 args.append(index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3121 if stopindex: args.append(stopindex)
52057
03c80e0742c3 Merged revisions 70218-70219 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 51776
diff changeset
3122 return str(self.tk.call(tuple(args)))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3123 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3124 """Scroll such that the character at INDEX is visible."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3125 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3126 def tag_add(self, tagName, index1, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3127 """Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3128 Additional pairs of indices may follow in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3129 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3130 (self._w, 'tag', 'add', tagName, index1) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3131 def tag_unbind(self, tagName, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3132 """Unbind for all characters with TAGNAME for event SEQUENCE the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3133 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3134 self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3135 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3136 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3137 def tag_bind(self, tagName, sequence, func, add=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3138 """Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
3139
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3140 An additional boolean parameter ADD specifies whether FUNC will be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3141 called additionally to the other bound function or whether it will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3142 replace the previous function. See bind for the return value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3143 return self._bind((self._w, 'tag', 'bind', tagName),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3144 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3145 def tag_cget(self, tagName, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3146 """Return the value of OPTION for tag TAGNAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3147 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3148 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3149 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3150 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3151 return self.tk.call(self._w, 'tag', 'cget', tagName, option)
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3152 def tag_configure(self, tagName, cnf=None, **kw):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3153 """Configure a tag TAGNAME."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3154 return self._configure(('tag', 'configure', tagName), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3155 tag_config = tag_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3156 def tag_delete(self, *tagNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3157 """Delete all tags in TAGNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3158 self.tk.call((self._w, 'tag', 'delete') + tagNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3159 def tag_lower(self, tagName, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3160 """Change the priority of tag TAGNAME such that it is lower
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3161 than the priority of BELOWTHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3162 self.tk.call(self._w, 'tag', 'lower', tagName, belowThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3163 def tag_names(self, index=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3164 """Return a list of all tag names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3165 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3166 self.tk.call(self._w, 'tag', 'names', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3167 def tag_nextrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3168 """Return a list of start and end index for the first sequence of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3169 characters between INDEX1 and INDEX2 which all have tag TAGNAME.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3170 The text is searched forward from INDEX1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3171 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3172 self._w, 'tag', 'nextrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3173 def tag_prevrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3174 """Return a list of start and end index for the first sequence of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3175 characters between INDEX1 and INDEX2 which all have tag TAGNAME.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3176 The text is searched backwards from INDEX1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3177 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3178 self._w, 'tag', 'prevrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3179 def tag_raise(self, tagName, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3180 """Change the priority of tag TAGNAME such that it is higher
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3181 than the priority of ABOVETHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3182 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3183 self._w, 'tag', 'raise', tagName, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3184 def tag_ranges(self, tagName):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3185 """Return a list of ranges of text which have tag TAGNAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3186 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3187 self._w, 'tag', 'ranges', tagName))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3188 def tag_remove(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3189 """Remove tag TAGNAME from all characters between INDEX1 and INDEX2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3190 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3191 self._w, 'tag', 'remove', tagName, index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3192 def window_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3193 """Return the value of OPTION of an embedded window at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3194 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3195 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3196 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3197 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3198 return self.tk.call(self._w, 'window', 'cget', index, option)
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3199 def window_configure(self, index, cnf=None, **kw):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3200 """Configure an embedded window at INDEX."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3201 return self._configure(('window', 'configure', index), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3202 window_config = window_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3203 def window_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3204 """Create a window at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3205 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3206 (self._w, 'window', 'create', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3207 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3208 def window_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3209 """Return all names of embedded windows in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3210 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3211 self.tk.call(self._w, 'window', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3212 def yview_pickplace(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3213 """Obsolete function, use see."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3214 self.tk.call((self._w, 'yview', '-pickplace') + what)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3215
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3216
4428
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3217 class _setit:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3218 """Internal class. It wraps the command in the widget OptionMenu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3219 def __init__(self, var, value, callback=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3220 self.__value = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3221 self.__var = var
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3222 self.__callback = callback
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3223 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3224 self.__var.set(self.__value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3225 if self.__callback:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3226 self.__callback(self.__value, *args)
4428
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3227
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3228 class OptionMenu(Menubutton):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3229 """OptionMenu which allows the user to select a value from a menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3230 def __init__(self, master, variable, value, *values, **kwargs):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3231 """Construct an optionmenu widget with the parent MASTER, with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3232 the resource textvariable set to VARIABLE, the initially selected
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3233 value VALUE, the other menu values VALUES and an additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3234 keyword argument command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3235 kw = {"borderwidth": 2, "textvariable": variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3236 "indicatoron": 1, "relief": RAISED, "anchor": "c",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3237 "highlightthickness": 2}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3238 Widget.__init__(self, master, "menubutton", kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3239 self.widgetName = 'tk_optionMenu'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3240 menu = self.__menu = Menu(self, name="menu", tearoff=0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3241 self.menuname = menu._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3242 # 'command' is the only supported keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3243 callback = kwargs.get('command')
39592
0f135affabf2 Couple more has_keys() going...
Guido van Rossum <guido@python.org>
parents: 39442
diff changeset
3244 if 'command' in kwargs:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3245 del kwargs['command']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3246 if kwargs:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
3247 raise TclError('unknown option -'+kwargs.keys()[0])
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3248 menu.add_command(label=value,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3249 command=_setit(variable, value, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3250 for v in values:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3251 menu.add_command(label=v,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3252 command=_setit(variable, v, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3253 self["menu"] = menu
4428
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3254
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3255 def __getitem__(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3256 if name == 'menu':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3257 return self.__menu
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3258 return Widget.__getitem__(self, name)
4428
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3259
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3260 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3261 """Destroy this widget and the associated menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3262 Menubutton.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3263 self.__menu = None
3067
6ec820db2ffa added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents: 2968
diff changeset
3264
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3265 class Image:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3266 """Base class for images."""
14470
39ff6b3c43af Fix for bug 110629: Generate unique image names by introducing a counter
Martin v. Löwis <martin@v.loewis.de>
parents: 14453
diff changeset
3267 _last_id = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3268 def __init__(self, imgtype, name=None, cnf={}, master=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3269 self.name = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3270 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3271 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3272 if not master:
43020
907a45df1295 Raise statement normalization in Lib/.
Collin Winter <collinw@gmail.com>
parents: 42552
diff changeset
3273 raise RuntimeError('Too early to create image')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3274 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3275 if not name:
14470
39ff6b3c43af Fix for bug 110629: Generate unique image names by introducing a counter
Martin v. Löwis <martin@v.loewis.de>
parents: 14453
diff changeset
3276 Image._last_id += 1
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
3277 name = "pyimage%r" % (Image._last_id,) # tk itself would use image<x>
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3278 # The following is needed for systems where id(x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3279 # can return a negative number, such as Linux/m68k:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3280 if name[0] == '-': name = '_' + name[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3281 if kw and cnf: cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3282 elif kw: cnf = kw
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3283 options = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3284 for k, v in cnf.items():
73165
8e57b5d8f58f Closes #13258: Use callable() built-in in the standard library.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 68489
diff changeset
3285 if callable(v):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3286 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3287 options = options + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3288 self.tk.call(('image', 'create', imgtype, name,) + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3289 self.name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3290 def __str__(self): return self.name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3291 def __del__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3292 if self.name:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3293 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3294 self.tk.call('image', 'delete', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3295 except TclError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3296 # May happen if the root was destroyed
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3297 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3298 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3299 self.tk.call(self.name, 'configure', '-'+key, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3300 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3301 return self.tk.call(self.name, 'configure', '-'+key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3302 def configure(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3303 """Configure the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3304 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3305 for k, v in _cnfmerge(kw).items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3306 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3307 if k[-1] == '_': k = k[:-1]
73165
8e57b5d8f58f Closes #13258: Use callable() built-in in the standard library.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 68489
diff changeset
3308 if callable(v):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3309 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3310 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3311 self.tk.call((self.name, 'config') + res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3312 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3313 def height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3314 """Return the height of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3315 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3316 self.tk.call('image', 'height', self.name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3317 def type(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3318 """Return the type of the imgage, e.g. "photo" or "bitmap"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3319 return self.tk.call('image', 'type', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3320 def width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3321 """Return the width of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3322 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3323 self.tk.call('image', 'width', self.name))
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3324
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3325 class PhotoImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3326 """Widget which can display colored images in GIF, PPM/PGM format."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3327 def __init__(self, name=None, cnf={}, master=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3328 """Create an image with NAME.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
3329
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3330 Valid resource names: data, format, file, gamma, height, palette,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3331 width."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3332 Image.__init__(self, 'photo', name, cnf, master, **kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3333 def blank(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3334 """Display a transparent image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3335 self.tk.call(self.name, 'blank')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3336 def cget(self, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3337 """Return the value of OPTION."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3338 return self.tk.call(self.name, 'cget', '-' + option)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3339 # XXX config
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3340 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3341 return self.tk.call(self.name, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3342 # XXX copy -from, -to, ...?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3343 def copy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3344 """Return a new PhotoImage with the same image as this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3345 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3346 self.tk.call(destImage, 'copy', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3347 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3348 def zoom(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3349 """Return a new PhotoImage with the same image as this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3350 but zoom it with X and Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3351 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3352 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3353 self.tk.call(destImage, 'copy', self.name, '-zoom',x,y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3354 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3355 def subsample(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3356 """Return a new PhotoImage based on the same image as this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3357 but use only every Xth or Yth pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3358 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3359 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3360 self.tk.call(destImage, 'copy', self.name, '-subsample',x,y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3361 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3362 def get(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3363 """Return the color (red, green, blue) of the pixel at X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3364 return self.tk.call(self.name, 'get', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3365 def put(self, data, to=None):
51776
d06a3ebf306f Merged revisions 69846 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 51484
diff changeset
3366 """Put row formatted colors to image starting from
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3367 position TO, e.g. image.put("{red green} {blue yellow}", to=(4,6))"""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3368 args = (self.name, 'put', data)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3369 if to:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3370 if to[0] == '-to':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3371 to = to[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3372 args = args + ('-to',) + tuple(to)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3373 self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3374 # XXX read
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3375 def write(self, filename, format=None, from_coords=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3376 """Write image to file FILENAME in FORMAT starting from
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3377 position FROM_COORDS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3378 args = (self.name, 'write', filename)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3379 if format:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3380 args = args + ('-format', format)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3381 if from_coords:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3382 args = args + ('-from',) + tuple(from_coords)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3383 self.tk.call(args)
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3384
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3385 class BitmapImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3386 """Widget which can display a bitmap."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3387 def __init__(self, name=None, cnf={}, master=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3388 """Create a bitmap with NAME.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
3389
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3390 Valid resource names: background, data, file, foreground, maskdata, maskfile."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3391 Image.__init__(self, 'bitmap', name, cnf, master, **kw)
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3392
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3393 def image_names(): return _default_root.tk.call('image', 'names')
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3394 def image_types(): return _default_root.tk.call('image', 'types')
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3395
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3396
55642
e4a83e91521a Merged revisions 74446-74449 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 54475
diff changeset
3397 class Spinbox(Widget, XView):
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3398 """spinbox widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3399 def __init__(self, master=None, cnf={}, **kw):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3400 """Construct a spinbox widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3401
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3402 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3403
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3404 activebackground, background, borderwidth,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3405 cursor, exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3406 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3407 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3408 insertborderwidth, insertofftime,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3409 insertontime, insertwidth, justify, relief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3410 repeatdelay, repeatinterval,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3411 selectbackground, selectborderwidth
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3412 selectforeground, takefocus, textvariable
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3413 xscrollcommand.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3414
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3415 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3416
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3417 buttonbackground, buttoncursor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3418 buttondownrelief, buttonuprelief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3419 command, disabledbackground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3420 disabledforeground, format, from,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3421 invalidcommand, increment,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3422 readonlybackground, state, to,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3423 validate, validatecommand values,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3424 width, wrap,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3425 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3426 Widget.__init__(self, master, 'spinbox', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3427
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3428 def bbox(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3429 """Return a tuple of X1,Y1,X2,Y2 coordinates for a
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3430 rectangle which encloses the character given by index.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3431
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3432 The first two elements of the list give the x and y
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3433 coordinates of the upper-left corner of the screen
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3434 area covered by the character (in pixels relative
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3435 to the widget) and the last two elements give the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3436 width and height of the character, in pixels. The
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3437 bounding box may refer to a region outside the
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3438 visible area of the window.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3439 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3440 return self.tk.call(self._w, 'bbox', index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3441
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3442 def delete(self, first, last=None):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3443 """Delete one or more elements of the spinbox.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3444
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3445 First is the index of the first character to delete,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3446 and last is the index of the character just after
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3447 the last one to delete. If last isn't specified it
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3448 defaults to first+1, i.e. a single character is
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3449 deleted. This command returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3450 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3451 return self.tk.call(self._w, 'delete', first, last)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3452
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3453 def get(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3454 """Returns the spinbox's string"""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3455 return self.tk.call(self._w, 'get')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3456
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3457 def icursor(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3458 """Alter the position of the insertion cursor.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3459
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3460 The insertion cursor will be displayed just before
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3461 the character given by index. Returns an empty string
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3462 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3463 return self.tk.call(self._w, 'icursor', index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3464
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3465 def identify(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3466 """Returns the name of the widget at position x, y
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3467
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3468 Return value is one of: none, buttondown, buttonup, entry
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3469 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3470 return self.tk.call(self._w, 'identify', x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3471
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3472 def index(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3473 """Returns the numerical index corresponding to index
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3474 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3475 return self.tk.call(self._w, 'index', index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3476
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3477 def insert(self, index, s):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3478 """Insert string s at index
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3479
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3480 Returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3481 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3482 return self.tk.call(self._w, 'insert', index, s)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3483
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3484 def invoke(self, element):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3485 """Causes the specified element to be invoked
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3486
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3487 The element could be buttondown or buttonup
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3488 triggering the action associated with it.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3489 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3490 return self.tk.call(self._w, 'invoke', element)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3491
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3492 def scan(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3493 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3494 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3495 self.tk.call((self._w, 'scan') + args)) or ()
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3496
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3497 def scan_mark(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3498 """Records x and the current view in the spinbox window;
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3499
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3500 used in conjunction with later scan dragto commands.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3501 Typically this command is associated with a mouse button
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3502 press in the widget. It returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3503 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3504 return self.scan("mark", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3505
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3506 def scan_dragto(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3507 """Compute the difference between the given x argument
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3508 and the x argument to the last scan mark command
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3509
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3510 It then adjusts the view left or right by 10 times the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3511 difference in x-coordinates. This command is typically
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3512 associated with mouse motion events in the widget, to
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3513 produce the effect of dragging the spinbox at high speed
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3514 through the window. The return value is an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3515 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3516 return self.scan("dragto", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3517
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3518 def selection(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3519 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3520 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3521 self.tk.call((self._w, 'selection') + args)) or ()
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3522
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3523 def selection_adjust(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3524 """Locate the end of the selection nearest to the character
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3525 given by index,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3526
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3527 Then adjust that end of the selection to be at index
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3528 (i.e including but not going beyond index). The other
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3529 end of the selection is made the anchor point for future
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3530 select to commands. If the selection isn't currently in
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3531 the spinbox, then a new selection is created to include
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3532 the characters between index and the most recent selection
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3533 anchor point, inclusive. Returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3534 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3535 return self.selection("adjust", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3536
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3537 def selection_clear(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3538 """Clear the selection
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3539
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3540 If the selection isn't in this widget then the
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3541 command has no effect. Returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3542 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3543 return self.selection("clear")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3544
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3545 def selection_element(self, element=None):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3546 """Sets or gets the currently selected element.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3547
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3548 If a spinbutton element is specified, it will be
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3549 displayed depressed
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3550 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3551 return self.selection("element", element)
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3552
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3553 ###########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3554
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3555 class LabelFrame(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3556 """labelframe widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3557 def __init__(self, master=None, cnf={}, **kw):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3558 """Construct a labelframe widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3559
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3560 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3561
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3562 borderwidth, cursor, font, foreground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3563 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3564 highlightthickness, padx, pady, relief,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3565 takefocus, text
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3566
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3567 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3568
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3569 background, class, colormap, container,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3570 height, labelanchor, labelwidget,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3571 visual, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3572 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3573 Widget.__init__(self, master, 'labelframe', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3574
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3575 ########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3576
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3577 class PanedWindow(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3578 """panedwindow widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3579 def __init__(self, master=None, cnf={}, **kw):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3580 """Construct a panedwindow widget with the parent MASTER.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3581
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3582 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3583
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3584 background, borderwidth, cursor, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3585 orient, relief, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3586
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3587 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3588
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3589 handlepad, handlesize, opaqueresize,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3590 sashcursor, sashpad, sashrelief,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3591 sashwidth, showhandle,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3592 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3593 Widget.__init__(self, master, 'panedwindow', cnf, kw)
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3594
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3595 def add(self, child, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3596 """Add a child widget to the panedwindow in a new pane.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3597
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3598 The child argument is the name of the child widget
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3599 followed by pairs of arguments that specify how to
54475
7b772ed536c7 Merged revisions 73083 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 52057
diff changeset
3600 manage the windows. The possible options and values
7b772ed536c7 Merged revisions 73083 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 52057
diff changeset
3601 are the ones accepted by the paneconfigure method.
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3602 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3603 self.tk.call((self._w, 'add', child) + self._options(kw))
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3604
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3605 def remove(self, child):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3606 """Remove the pane containing child from the panedwindow
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3607
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3608 All geometry management options for child will be forgotten.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3609 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3610 self.tk.call(self._w, 'forget', child)
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3611 forget=remove
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3612
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3613 def identify(self, x, y):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3614 """Identify the panedwindow component at point x, y
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3615
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3616 If the point is over a sash or a sash handle, the result
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3617 is a two element list containing the index of the sash or
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3618 handle, and a word indicating whether it is over a sash
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3619 or a handle, such as {0 sash} or {2 handle}. If the point
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3620 is over any other part of the panedwindow, the result is
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3621 an empty list.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3622 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3623 return self.tk.call(self._w, 'identify', x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3624
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3625 def proxy(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3626 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3627 return self._getints(
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3628 self.tk.call((self._w, 'proxy') + args)) or ()
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3629
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3630 def proxy_coord(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3631 """Return the x and y pair of the most recent proxy location
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3632 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3633 return self.proxy("coord")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3634
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3635 def proxy_forget(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3636 """Remove the proxy from the display.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3637 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3638 return self.proxy("forget")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3639
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3640 def proxy_place(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3641 """Place the proxy at the given x and y coordinates.
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3642 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3643 return self.proxy("place", x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3644
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3645 def sash(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3646 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3647 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3648 self.tk.call((self._w, 'sash') + args)) or ()
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3649
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3650 def sash_coord(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3651 """Return the current x and y pair for the sash given by index.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3652
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3653 Index must be an integer between 0 and 1 less than the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3654 number of panes in the panedwindow. The coordinates given are
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3655 those of the top left corner of the region containing the sash.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3656 pathName sash dragto index x y This command computes the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3657 difference between the given coordinates and the coordinates
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3658 given to the last sash coord command for the given sash. It then
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3659 moves that sash the computed difference. The return value is the
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3660 empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3661 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3662 return self.sash("coord", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3663
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3664 def sash_mark(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3665 """Records x and y for the sash given by index;
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3666
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3667 Used in conjunction with later dragto commands to move the sash.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3668 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3669 return self.sash("mark", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3670
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3671 def sash_place(self, index, x, y):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3672 """Place the sash given by index at the given coordinates
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3673 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3674 return self.sash("place", index, x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3675
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3676 def panecget(self, child, option):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3677 """Query a management option for window.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3678
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3679 Option may be any value allowed by the paneconfigure subcommand
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3680 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3681 return self.tk.call(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3682 (self._w, 'panecget') + (child, '-'+option))
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3683
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3684 def paneconfigure(self, tagOrId, cnf=None, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3685 """Query or modify the management options for window.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3686
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3687 If no option is specified, returns a list describing all
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3688 of the available options for pathName. If option is
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3689 specified with no value, then the command returns a list
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3690 describing the one named option (this list will be identical
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3691 to the corresponding sublist of the value returned if no
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3692 option is specified). If one or more option-value pairs are
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3693 specified, then the command modifies the given widget
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3694 option(s) to have the given value(s); in this case the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3695 command returns an empty string. The following options
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3696 are supported:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3697
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3698 after window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3699 Insert the window after the window specified. window
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3700 should be the name of a window already managed by pathName.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3701 before window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3702 Insert the window before the window specified. window
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3703 should be the name of a window already managed by pathName.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3704 height size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3705 Specify a height for the window. The height will be the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3706 outer dimension of the window including its border, if
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3707 any. If size is an empty string, or if -height is not
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3708 specified, then the height requested internally by the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3709 window will be used initially; the height may later be
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3710 adjusted by the movement of sashes in the panedwindow.
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3711 Size may be any value accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3712 minsize n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3713 Specifies that the size of the window cannot be made
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3714 less than n. This constraint only affects the size of
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3715 the widget in the paned dimension -- the x dimension
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3716 for horizontal panedwindows, the y dimension for
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3717 vertical panedwindows. May be any value accepted by
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3718 Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3719 padx n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3720 Specifies a non-negative value indicating how much
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3721 extra space to leave on each side of the window in
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3722 the X-direction. The value may have any of the forms
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3723 accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3724 pady n
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3725 Specifies a non-negative value indicating how much
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3726 extra space to leave on each side of the window in
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3727 the Y-direction. The value may have any of the forms
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3728 accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3729 sticky style
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3730 If a window's pane is larger than the requested
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3731 dimensions of the window, this option may be used
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3732 to position (or stretch) the window within its pane.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3733 Style is a string that contains zero or more of the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3734 characters n, s, e or w. The string can optionally
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3735 contains spaces or commas, but they are ignored. Each
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3736 letter refers to a side (north, south, east, or west)
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3737 that the window will "stick" to. If both n and s
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3738 (or e and w) are specified, the window will be
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3739 stretched to fill the entire height (or width) of
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3740 its cavity.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3741 width size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3742 Specify a width for the window. The width will be
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3743 the outer dimension of the window including its
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3744 border, if any. If size is an empty string, or
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3745 if -width is not specified, then the width requested
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3746 internally by the window will be used initially; the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3747 width may later be adjusted by the movement of sashes
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3748 in the panedwindow. Size may be any value accepted by
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3749 Tk_GetPixels.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3750
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3751 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3752 if cnf is None and not kw:
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3753 cnf = {}
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3754 for x in self.tk.split(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3755 self.tk.call(self._w,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3756 'paneconfigure', tagOrId)):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3757 cnf[x[0][1:]] = (x[0][1:],) + x[1:]
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3758 return cnf
41986
6464cc638faa Merged revisions 55795-55816 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
3759 if isinstance(cnf, str) and not kw:
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3760 x = self.tk.split(self.tk.call(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3761 self._w, 'paneconfigure', tagOrId, '-'+cnf))
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3762 return (x[0][1:],) + x[1:]
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3763 self.tk.call((self._w, 'paneconfigure', tagOrId) +
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3764 self._options(cnf, kw))
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3765 paneconfig = paneconfigure
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3766
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3767 def panes(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3768 """Returns an ordered list of the child panes."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3769 return self.tk.call(self._w, 'panes')
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3770
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3771 ######################################################################
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3772 # Extensions:
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3773
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3774 class Studbutton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3775 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3776 Widget.__init__(self, master, 'studbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3777 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3778 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3779 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3780 self.bind('<ButtonRelease-1>', self.tkButtonUp)
1688
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3781
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3782 class Tributton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3783 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3784 Widget.__init__(self, master, 'tributton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3785 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3786 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3787 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3788 self.bind('<ButtonRelease-1>', self.tkButtonUp)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3789 self['fg'] = self['bg']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3790 self['activebackground'] = self['bg']
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
3791
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3792 ######################################################################
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3793 # Test:
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3794
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3795 def _test():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3796 root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3797 text = "This is Tcl/Tk version %s" % TclVersion
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3798 if TclVersion >= 8.1:
42050
ca693f4fd05d Simplify various spots where: str() is called on something
Walter Dörwald <walter@livinglogic.de>
parents: 41986
diff changeset
3799 text += "\nThis should be a cedilla: \xe7"
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3800 label = Label(root, text=text)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3801 label.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3802 test = Button(root, text="Click me!",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3803 command=lambda root=root: root.test.configure(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3804 text="[%s]" % root.test['text']))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3805 test.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3806 root.test = test
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3807 quit = Button(root, text="QUIT", command=root.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3808 quit.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3809 # The following three commands are needed so the window pops
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3810 # up on top on Windows...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3811 root.iconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3812 root.update()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3813 root.deiconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3814 root.mainloop()
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3815
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3816 if __name__ == '__main__':
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3817 _test()