annotate Lib/lib-tk/Tkinter.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 433e116c335d
children 5db0556ed122
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):
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
21 import Tkinter
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
22 from Tkconstants import *
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
23 tk = Tkinter.Tk()
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
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)
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
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)
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
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
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
33 __version__ = "$Revision$"
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
34
9763
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
35 import sys
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
36 if sys.platform == "win32":
47099
3b827f3647cb Step 1 of Tkinter renaming: move lib-tk modules into a new "tkinter" package.
Georg Brandl <georg@python.org>
parents: 46913
diff changeset
37 # Attempt to configure Tcl/Tk without requiring PATH
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
38 import FixTk
9763
16c9a714880f This hopefully fixes the problem of having to set PATH
Guido van Rossum <guido@python.org>
parents: 9666
diff changeset
39 import _tkinter # If this fails your Python may not be configured for Tk
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
40 tkinter = _tkinter # b/w compat for export
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
2577
498dad8045d3 add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents: 2045
diff changeset
42 from types import *
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
43 from Tkconstants import *
2830
bd79cd768ff8 Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents: 2585
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
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
54 # These are not always defined, e.g. not on Win32 with Tk 8.0 :-(
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
55 try: _tkinter.createfilehandler
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
56 except AttributeError: _tkinter.createfilehandler = None
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
57 try: _tkinter.deletefilehandler
d02ac61cd50f Add dummies for create/delete filehandles, just so that vanilla Grail
Guido van Rossum <guido@python.org>
parents: 5989
diff changeset
58 except AttributeError: _tkinter.deletefilehandler = None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
59
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
60
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
61 def _flatten(tuple):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
62 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
63 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
64 for item in tuple:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
65 if type(item) in (TupleType, ListType):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
66 res = res + _flatten(item)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
67 elif item is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
68 res = res + (item,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
69 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
70
12953
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
71 try: _flatten = _tkinter._flatten
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
72 except AttributeError: pass
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
73
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
74 def _cnfmerge(cnfs):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
75 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
76 if type(cnfs) is DictionaryType:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
77 return cnfs
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
78 elif type(cnfs) in (NoneType, StringType):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
79 return cnfs
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
80 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
81 cnf = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
82 for c in _flatten(cnfs):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
83 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
84 cnf.update(c)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
85 except (AttributeError, TypeError), msg:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
86 print "_cnfmerge: fallback due to:", msg
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
87 for k, v in c.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
88 cnf[k] = v
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
89 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
90
12953
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
91 try: _cnfmerge = _tkinter._cnfmerge
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
92 except AttributeError: pass
a3e12881cc3c Patch from /F:
Andrew M. Kuchling <amk@amk.ca>
parents: 12130
diff changeset
93
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
94 class Event:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
95 """Container for the properties of an event.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
96
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
97 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
98
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
99 KeyPress, KeyRelease - for keyboard events
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
100 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
101 Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
102 Colormap, Gravity, Reparent, Property, Destroy, Activate,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
103 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
104
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
105 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
106 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
107 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
108 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
109 the attribute is valid):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
110
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
111 serial - serial number of event
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
112 num - mouse button pressed (ButtonPress, ButtonRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
113 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
114 height - height of the exposed window (Configure, Expose)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
115 width - width of the exposed window (Configure, Expose)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
116 keycode - keycode of the pressed key (KeyPress, KeyRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
117 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
118 Enter, KeyPress, KeyRelease,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
119 Leave, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
120 state - state as a string (Visibility)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
121 time - when the event occurred
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
122 x - x-position of the mouse
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
123 y - y-position of the mouse
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
124 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
125 (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
126 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
127 (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
128 char - pressed character (KeyPress, KeyRelease)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
129 send_event - see X/Windows documentation
35850
f6d8b0de134a Fix typos.
Walter Dörwald <walter@livinglogic.de>
parents: 35282
diff changeset
130 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
131 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
132 type - type of the event as a number
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
133 widget - widget in which the event occurred
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
134 delta - delta of wheel movement (MouseWheel)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
135 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
136 pass
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
137
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
138 _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
139 _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
140
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
141 def NoDefaultRoot():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
142 """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
143
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
144 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
145 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
146 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
147 global _support_default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
148 _support_default_root = 0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
149 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
150 _default_root = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
151 del _default_root
7731
9c37ed8868b9 Give in to the tab police.
Guido van Rossum <guido@python.org>
parents: 7463
diff changeset
152
1671
953e74eac006 Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents: 1669
diff changeset
153 def _tkerror(err):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
154 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
155 pass
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
1714
db0eaef42cb9 Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents: 1709
diff changeset
157 def _exit(code='0'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
158 """Internal function. Calling it will throw the exception SystemExit."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
159 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
160
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
161 _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
162 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
163 """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
164
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
165 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
166 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
167 _default = ""
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
168 def __init__(self, master=None, value=None, name=None):
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
169 """Construct a variable
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
170
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
171 MASTER can be given as master widget.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
172 VALUE is an optional value (defaults to "")
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
173 NAME is an optional Tcl name (defaults to PY_VARnum).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
174
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
175 If NAME matches an existing variable and VALUE is omitted
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
176 then the existing value is retained.
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
177 """
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
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
183 if name:
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
184 self._name = name
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
185 else:
39116
95fa8fc8a065 Patch #1524429: Use repr instead of backticks again.
Martin v. Löwis <martin@v.loewis.de>
parents: 38875
diff changeset
186 self._name = 'PY_VAR' + repr(_varnum)
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
187 _varnum += 1
46197
01a7e66525c2 #2503 make singletons compared with "is" not == or !=
Benjamin Peterson <benjamin@python.org>
parents: 44416
diff changeset
188 if value is not None:
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
189 self.set(value)
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
190 elif not self._tk.call("info", "exists", self._name):
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
191 self.set(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."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
194 self._tk.globalunsetvar(self._name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
195 def __str__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
196 """Return the name of the variable in Tcl."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
197 return self._name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
198 def set(self, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
199 """Set the variable to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
200 return self._tk.globalsetvar(self._name, value)
28642
cfece1822e94 Add 'get' method to Variable and switch it from internal class to
Guido van Rossum <guido@python.org>
parents: 28639
diff changeset
201 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
202 """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
203 return self._tk.globalgetvar(self._name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
204 def trace_variable(self, mode, callback):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
205 """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
206
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
207 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
208 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
209 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
210
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
211 Return the name of the callback.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
212 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
213 cbname = self._master._register(callback)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
214 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
215 return cbname
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
216 trace = trace_variable
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
217 def trace_vdelete(self, mode, cbname):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
218 """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
219
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
220 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
221 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
222 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
223 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
224 self._master.deletecommand(cbname)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
225 def trace_vinfo(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
226 """Return all trace callback information."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
227 return map(self._tk.split, self._tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
228 self._tk.call("trace", "vinfo", self._name)))
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
229 def __eq__(self, other):
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
230 """Comparison for equality (==).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
231
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
232 Note: if the Variable's master matters to behavior
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
233 also compare self._master == other._master
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
234 """
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
235 return self.__class__.__name__ == other.__class__.__name__ \
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
236 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
237
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
238 class StringVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
239 """Value holder for strings variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
240 _default = ""
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
241 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
242 """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
243
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
244 MASTER can be given as master widget.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
245 VALUE is an optional value (defaults to "")
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
246 NAME is an optional Tcl name (defaults to PY_VARnum).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
247
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
248 If NAME matches an existing variable and VALUE is omitted
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
249 then the existing value is retained.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
250 """
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
251 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
252
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
253 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
254 """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
255 value = self._tk.globalgetvar(self._name)
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
256 if isinstance(value, basestring):
be0d4ec6bf5a For StringVar results to strings. Document that boolean things are of
Martin v. Löwis <martin@v.loewis.de>
parents: 28513
diff changeset
257 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
258 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
259
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
260 class IntVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
261 """Value holder for integer variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
262 _default = 0
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
263 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
264 """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
265
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
266 MASTER can be given as master widget.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
267 VALUE is an optional value (defaults to 0)
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
268 NAME is an optional Tcl name (defaults to PY_VARnum).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
269
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
270 If NAME matches an existing variable and VALUE is omitted
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
271 then the existing value is retained.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
272 """
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
273 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
274
27341
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
275 def set(self, value):
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
276 """Set the variable to value, converting booleans to integers."""
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
277 if isinstance(value, bool):
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
278 value = int(value)
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
279 return Variable.set(self, value)
ba63d717c75f Convert booleans to integers in IntVar.set. Fixes #671741.
Martin v. Löwis <martin@v.loewis.de>
parents: 27211
diff changeset
280
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
281 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
282 """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
283 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
284
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
285 class DoubleVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
286 """Value holder for float variables."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
287 _default = 0.0
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
288 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
289 """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
290
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
291 MASTER can be given as master widget.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
292 VALUE is an optional value (defaults to 0.0)
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
293 NAME is an optional Tcl name (defaults to PY_VARnum).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
294
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
295 If NAME matches an existing variable and VALUE is omitted
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
296 then the existing value is retained.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
297 """
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
298 Variable.__init__(self, master, value, name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
299
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
300 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
301 """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
302 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
303
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
304 class BooleanVar(Variable):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
305 """Value holder for boolean variables."""
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
306 _default = False
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
307 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
308 """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
309
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
310 MASTER can be given as master widget.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
311 VALUE is an optional value (defaults to False)
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
312 NAME is an optional Tcl name (defaults to PY_VARnum).
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
313
38854
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
314 If NAME matches an existing variable and VALUE is omitted
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
315 then the existing value is retained.
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
316 """
8a50d8e9018c Patch #763580: Add name and value arguments to
Martin v. Löwis <martin@v.loewis.de>
parents: 37778
diff changeset
317 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
318
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
319 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
320 """Return the value of the variable as a bool."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
321 return self._tk.getboolean(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
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."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
333 return _default_root.tk.getboolean(s)
1703
ba957aa42241 Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1700
diff changeset
334
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
335 # Methods defined on both toplevel and interior widgets
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
336 class Misc:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
337 """Internal class.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
338
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
339 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
340
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
341 # XXX font command?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
342 _tclCommands = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
343 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
344 """Internal function.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
345
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
346 Delete all Tcl commands created for
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
347 this widget in the Tcl interpreter."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
348 if self._tclCommands is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
349 for name in self._tclCommands:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
350 #print '- Tkinter: deleted command', name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
351 self.tk.deletecommand(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
352 self._tclCommands = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
353 def deletecommand(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
354 """Internal function.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
355
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
356 Delete the Tcl command provided in NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
357 #print '- Tkinter: deleted command', name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
358 self.tk.deletecommand(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
359 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
360 self._tclCommands.remove(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
361 except ValueError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
362 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
363 def tk_strictMotif(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
364 """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
365 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
366
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
367 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
368 change if mouse passes over slider).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
369 Returns the set value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
370 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
371 'set', 'tk_strictMotif', boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
372 def tk_bisque(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
373 """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
374 self.tk.call('tk_bisque')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
375 def tk_setPalette(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
376 """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
377
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
378 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
379 widget elements are derived from this.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
380 Alternatively several keyword parameters and its associated
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
381 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
382 activeBackground, foreground, selectColor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
383 activeForeground, highlightBackground, selectBackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
384 background, highlightColor, selectForeground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
385 disabledForeground, insertBackground, troughColor."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
386 self.tk.call(('tk_setPalette',)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
387 + _flatten(args) + _flatten(kw.items()))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
388 def tk_menuBar(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
389 """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
390 pass # obsolete since Tk 4.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
391 def wait_variable(self, name='PY_VAR'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
392 """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
393
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
394 A parameter of type IntVar, StringVar, DoubleVar or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
395 BooleanVar must be given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
396 self.tk.call('tkwait', 'variable', name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
397 waitvar = wait_variable # XXX b/w compat
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
398 def wait_window(self, window=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
399 """Wait until a WIDGET is destroyed.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
400
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
401 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
402 if window is None:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
403 window = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
404 self.tk.call('tkwait', 'window', window._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
405 def wait_visibility(self, window=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
406 """Wait until the visibility of a WIDGET changes
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
407 (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
408
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
409 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
410 if window is None:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
411 window = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
412 self.tk.call('tkwait', 'visibility', window._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
413 def setvar(self, name='PY_VAR', value='1'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
414 """Set Tcl variable NAME to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
415 self.tk.setvar(name, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
416 def getvar(self, name='PY_VAR'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
417 """Return value of Tcl variable NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
418 return self.tk.getvar(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
419 getint = int
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
420 getdouble = float
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
421 def getboolean(self, s):
28645
b9745cd791bf Remove extra space in docstring
Neal Norwitz <nnorwitz@gmail.com>
parents: 28642
diff changeset
422 """Return a boolean value for Tcl boolean values true and false given as parameter."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
423 return self.tk.getboolean(s)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
424 def focus_set(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
425 """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
426
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
427 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
428 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
429 the focus through the window manager."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
430 self.tk.call('focus', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
431 focus = focus_set # XXX b/w compat?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
432 def focus_force(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
433 """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
434 application does not have the focus. Use with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
435 caution!"""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
436 self.tk.call('focus', '-force', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
437 def focus_get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
438 """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
439 application.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
440
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
441 Use focus_displayof to allow working with several
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
442 displays. Return None if application does not have
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
443 the focus."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
444 name = self.tk.call('focus')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
445 if name == 'none' or not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
446 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
447 def focus_displayof(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
448 """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
449 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
450
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
451 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
452 name = self.tk.call('focus', '-displayof', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
453 if name == 'none' or not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
454 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
455 def focus_lastfor(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
456 """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
457 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
458 name = self.tk.call('focus', '-lastfor', 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 tk_focusFollowsMouse(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
462 """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
463 be disabled easily."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
464 self.tk.call('tk_focusFollowsMouse')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
465 def tk_focusNext(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
466 """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
467 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
468
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
469 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
470 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
471 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
472 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
473 to 0."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
474 name = self.tk.call('tk_focusNext', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
475 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
476 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
477 def tk_focusPrev(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
478 """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
479 name = self.tk.call('tk_focusPrev', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
480 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
481 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
482 def after(self, ms, func=None, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
483 """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
484
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
485 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
486 function which shall be called. Additional parameters
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
487 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
488 identifier to cancel scheduling with after_cancel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
489 if not func:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
490 # 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
491 self.tk.call('after', ms)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
492 else:
37402
2cf3b5c451d7 Remove "disgusting hack" in favour of closure (patch #1462235)
Georg Brandl <georg@python.org>
parents: 35850
diff changeset
493 def callit():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
494 try:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
495 func(*args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
496 finally:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
497 try:
37402
2cf3b5c451d7 Remove "disgusting hack" in favour of closure (patch #1462235)
Georg Brandl <georg@python.org>
parents: 35850
diff changeset
498 self.deletecommand(name)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
499 except TclError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
500 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
501 name = self._register(callit)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
502 return self.tk.call('after', ms, name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
503 def after_idle(self, func, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
504 """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
505 process.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
506
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
507 Return an identifier to cancel the scheduling with
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
508 after_cancel."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
509 return self.after('idle', func, *args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
510 def after_cancel(self, id):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
511 """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
512
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
513 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
514 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
515 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
516 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
517 # 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
518 # 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
519 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
520 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
521 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
522 pass
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
523 self.tk.call('after', 'cancel', id)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
524 def bell(self, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
525 """Ring a display's bell."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
526 self.tk.call(('bell',) + self._displayof(displayof))
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
527
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
528 # Clipboard handling:
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
529 def clipboard_get(self, **kw):
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
530 """Retrieve data from the clipboard on window's display.
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
531
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
532 The window keyword defaults to the root window of the Tkinter
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
533 application.
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
534
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
535 The type keyword specifies the form in which the data is
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
536 to be returned and should be an atom name such as STRING
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
537 or FILE_NAME. Type defaults to STRING.
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
538
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
539 This command is equivalent to:
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
540
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
541 selection_get(CLIPBOARD)
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
542 """
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
543 return self.tk.call(('clipboard', 'get') + self._options(kw))
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
544
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
545 def clipboard_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
546 """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
547
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
548 A widget specified for the optional displayof keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
549 argument specifies the target display."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
550 if not kw.has_key('displayof'): kw['displayof'] = self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
551 self.tk.call(('clipboard', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
552 def clipboard_append(self, string, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
553 """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
554
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
555 A widget specified at the optional displayof keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
556 argument specifies the target display. The clipboard
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
557 can be retrieved with selection_get."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
558 if not kw.has_key('displayof'): kw['displayof'] = self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
559 self.tk.call(('clipboard', 'append') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
560 + ('--', string))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
561 # XXX grab current w/o window argument
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
562 def grab_current(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
563 """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
564 or None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
565 name = self.tk.call('grab', 'current', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
566 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
567 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
568 def grab_release(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
569 """Release grab for this widget if currently set."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
570 self.tk.call('grab', 'release', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
571 def grab_set(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
572 """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
573
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
574 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
575 widgets in the application."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
576 self.tk.call('grab', 'set', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
577 def grab_set_global(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
578 """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
579
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
580 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
581 descendant widgets on the display. Use with caution -
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
582 other applications do not get events anymore."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
583 self.tk.call('grab', 'set', '-global', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
584 def grab_status(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
585 """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
586 no, a local or a global grab."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
587 status = self.tk.call('grab', 'status', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
588 if status == 'none': status = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
589 return status
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
590 def option_add(self, pattern, value, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
591 """Set a VALUE (second parameter) for an option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
592 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
593
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
594 An optional third parameter gives the numeric priority
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
595 (defaults to 80)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
596 self.tk.call('option', 'add', pattern, value, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
597 def option_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
598 """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
599
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
600 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
601 self.tk.call('option', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
602 def option_get(self, name, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
603 """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
604 with CLASSNAME.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
605
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
606 Values with higher priority override lower values."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
607 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
608 def option_readfile(self, fileName, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
609 """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
610
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
611 An optional second parameter gives the numeric
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
612 priority."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
613 self.tk.call('option', 'readfile', fileName, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
614 def selection_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
615 """Clear the current X selection."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
616 if not kw.has_key('displayof'): kw['displayof'] = self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
617 self.tk.call(('selection', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
618 def selection_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
619 """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
620
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
621 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
622 the selection and defaults to PRIMARY. A keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
623 parameter displayof specifies a widget on the display
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
624 to use."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
625 if not kw.has_key('displayof'): kw['displayof'] = self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
626 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
627 def selection_handle(self, command, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
628 """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
629 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
630 application.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
631
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
632 This function must return the contents of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
633 selection. The function will be called with the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
634 arguments OFFSET and LENGTH which allows the chunking
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
635 of very long selections. The following keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
636 parameters can be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
637 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
638 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
639 name = self._register(command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
640 self.tk.call(('selection', 'handle') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
641 + (self._w, name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
642 def selection_own(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
643 """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
644
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
645 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
646 the selection (default PRIMARY)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
647 self.tk.call(('selection', 'own') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
648 self._options(kw) + (self._w,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
649 def selection_own_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
650 """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
651
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
652 The following keyword parameter can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
653 be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
654 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
655 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
656 if not kw.has_key('displayof'): kw['displayof'] = self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
657 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
658 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
659 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
660 def send(self, interp, cmd, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
661 """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
662 return self.tk.call(('send', interp, cmd) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
663 def lower(self, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
664 """Lower this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
665 self.tk.call('lower', self._w, belowThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
666 def tkraise(self, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
667 """Raise this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
668 self.tk.call('raise', self._w, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
669 lift = tkraise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
670 def colormodel(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
671 """Useless. Not implemented in Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
672 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
673 def winfo_atom(self, name, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
674 """Return integer which represents atom NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
675 args = ('winfo', 'atom') + self._displayof(displayof) + (name,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
676 return getint(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
677 def winfo_atomname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
678 """Return name of atom with identifier ID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
679 args = ('winfo', 'atomname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
680 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
681 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
682 def winfo_cells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
683 """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
684 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
685 self.tk.call('winfo', 'cells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
686 def winfo_children(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
687 """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
688 result = []
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
689 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
690 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
691 try:
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
692 # 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
693 # 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
694 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
695 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
696 pass
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
697 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
698
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
699 def winfo_class(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
700 """Return window class name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
701 return self.tk.call('winfo', 'class', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
702 def winfo_colormapfull(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
703 """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
704 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
705 self.tk.call('winfo', 'colormapfull', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
706 def winfo_containing(self, rootX, rootY, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
707 """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
708 args = ('winfo', 'containing') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
709 + self._displayof(displayof) + (rootX, rootY)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
710 name = self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
711 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
712 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
713 def winfo_depth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
714 """Return the number of bits per pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
715 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
716 def winfo_exists(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
717 """Return true if this widget exists."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
718 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
719 self.tk.call('winfo', 'exists', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
720 def winfo_fpixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
721 """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
722 (e.g. "3c") as float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
723 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
724 'winfo', 'fpixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
725 def winfo_geometry(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
726 """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
727 return self.tk.call('winfo', 'geometry', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
728 def winfo_height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
729 """Return height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
730 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
731 self.tk.call('winfo', 'height', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
732 def winfo_id(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
733 """Return identifier ID for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
734 return self.tk.getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
735 self.tk.call('winfo', 'id', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
736 def winfo_interps(self, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
737 """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
738 args = ('winfo', 'interps') + self._displayof(displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
739 return self.tk.splitlist(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
740 def winfo_ismapped(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
741 """Return true if this widget is mapped."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
742 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
743 self.tk.call('winfo', 'ismapped', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
744 def winfo_manager(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
745 """Return the window mananger name for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
746 return self.tk.call('winfo', 'manager', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
747 def winfo_name(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
748 """Return the name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
749 return self.tk.call('winfo', 'name', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
750 def winfo_parent(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
751 """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
752 return self.tk.call('winfo', 'parent', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
753 def winfo_pathname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
754 """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
755 args = ('winfo', 'pathname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
756 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
757 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
758 def winfo_pixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
759 """Rounded integer value of winfo_fpixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
760 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
761 self.tk.call('winfo', 'pixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
762 def winfo_pointerx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
763 """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
764 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
765 self.tk.call('winfo', 'pointerx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
766 def winfo_pointerxy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
767 """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
768 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
769 self.tk.call('winfo', 'pointerxy', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
770 def winfo_pointery(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
771 """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
772 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
773 self.tk.call('winfo', 'pointery', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
774 def winfo_reqheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
775 """Return requested height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
776 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
777 self.tk.call('winfo', 'reqheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
778 def winfo_reqwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
779 """Return requested width of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
780 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
781 self.tk.call('winfo', 'reqwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
782 def winfo_rgb(self, color):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
783 """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
784 COLOR in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
785 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
786 self.tk.call('winfo', 'rgb', self._w, color))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
787 def winfo_rootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
788 """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
789 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
790 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
791 self.tk.call('winfo', 'rootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
792 def winfo_rooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
793 """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
794 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
795 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
796 self.tk.call('winfo', 'rooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
797 def winfo_screen(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
798 """Return the screen name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
799 return self.tk.call('winfo', 'screen', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
800 def winfo_screencells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
801 """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
802 of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
803 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
804 self.tk.call('winfo', 'screencells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
805 def winfo_screendepth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
806 """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
807 screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
808 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
809 self.tk.call('winfo', 'screendepth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
810 def winfo_screenheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
811 """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
812 in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
813 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
814 self.tk.call('winfo', 'screenheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
815 def winfo_screenmmheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
816 """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
817 this widget in mm."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
818 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
819 self.tk.call('winfo', 'screenmmheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
820 def winfo_screenmmwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
821 """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
822 this widget in mm."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
823 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
824 self.tk.call('winfo', 'screenmmwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
825 def winfo_screenvisual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
826 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
827 staticcolor, staticgray, or truecolor for the default
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
828 colormodel of this screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
829 return self.tk.call('winfo', 'screenvisual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
830 def winfo_screenwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
831 """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
832 this widget in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
833 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
834 self.tk.call('winfo', 'screenwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
835 def winfo_server(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
836 """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
837 the form "XmajorRminor vendor vendorVersion"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
838 return self.tk.call('winfo', 'server', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
839 def winfo_toplevel(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
840 """Return the toplevel widget of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
841 return self._nametowidget(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
842 'winfo', 'toplevel', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
843 def winfo_viewable(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
844 """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
845 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
846 self.tk.call('winfo', 'viewable', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
847 def winfo_visual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
848 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
849 staticcolor, staticgray, or truecolor for the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
850 colormodel of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
851 return self.tk.call('winfo', 'visual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
852 def winfo_visualid(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
853 """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
854 return self.tk.call('winfo', 'visualid', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
855 def winfo_visualsavailable(self, includeids=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
856 """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
857 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
858
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
859 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
860 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
861 data = self.tk.split(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
862 self.tk.call('winfo', 'visualsavailable', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
863 includeids and 'includeids' or None))
13907
446c3616c323 -- don't mess up in winfo_visualsavailable if the system only
Fredrik Lundh <fredrik@pythonware.com>
parents: 13906
diff changeset
864 if type(data) is StringType:
446c3616c323 -- don't mess up in winfo_visualsavailable if the system only
Fredrik Lundh <fredrik@pythonware.com>
parents: 13906
diff changeset
865 data = [self.tk.split(data)]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
866 return map(self.__winfo_parseitem, data)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
867 def __winfo_parseitem(self, t):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
868 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
869 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
870 def __winfo_getint(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
871 """Internal function."""
16517
eee67a84e5fa String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15540
diff changeset
872 return int(x, 0)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
873 def winfo_vrootheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
874 """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
875 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
876 height of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
877 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
878 self.tk.call('winfo', 'vrootheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
879 def winfo_vrootwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
880 """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
881 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
882 width of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
883 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
884 self.tk.call('winfo', 'vrootwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
885 def winfo_vrootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
886 """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
887 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
888 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
889 self.tk.call('winfo', 'vrootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
890 def winfo_vrooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
891 """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
892 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
893 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
894 self.tk.call('winfo', 'vrooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
895 def winfo_width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
896 """Return the width of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
897 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
898 self.tk.call('winfo', 'width', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
899 def winfo_x(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
900 """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
901 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
902 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
903 self.tk.call('winfo', 'x', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
904 def winfo_y(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
905 """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
906 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
907 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
908 self.tk.call('winfo', 'y', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
909 def update(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
910 """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
911 self.tk.call('update')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
912 def update_idletasks(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
913 """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
914 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
915 the user."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
916 self.tk.call('update', 'idletasks')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
917 def bindtags(self, tagList=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
918 """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
919
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
920 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
921 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
922 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
923 processed (see bind)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
924 if tagList is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
925 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
926 self.tk.call('bindtags', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
927 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
928 self.tk.call('bindtags', self._w, tagList)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
929 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
930 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
931 if type(func) is StringType:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
932 self.tk.call(what + (sequence, func))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
933 elif func:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
934 funcid = self._register(func, self._substitute,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
935 needcleanup)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
936 cmd = ('%sif {"[%s %s]" == "break"} break\n'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
937 %
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
938 (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
939 funcid, self._subst_format_str))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
940 self.tk.call(what + (sequence, cmd))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
941 return funcid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
942 elif sequence:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
943 return self.tk.call(what + (sequence,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
944 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
945 return self.tk.splitlist(self.tk.call(what))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
946 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
947 """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
948
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
949 SEQUENCE is a string of concatenated event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
950 patterns. An event pattern is of the form
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
951 <MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
952 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
953 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
954 B3, Alt, Button4, B4, Double, Button5, B5 Triple,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
955 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
956 ButtonPress, Button, Expose, Motion, ButtonRelease
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
957 FocusIn, MouseWheel, Circulate, FocusOut, Property,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
958 Colormap, Gravity Reparent, Configure, KeyPress, Key,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
959 Unmap, Deactivate, KeyRelease Visibility, Destroy,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
960 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
961 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
962 KeyRelease. Examples are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
963 <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
964 <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
965 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
966 <<AString>> where AString can be arbitrary. This
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
967 event can be generated by event_generate.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
968 If events are concatenated they must appear shortly
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
969 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
970
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
971 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
972 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
973 "break" no further bound function is invoked.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
974
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
975 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
976 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
977 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
978
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
979 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
980 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
981
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
982 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
983 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
984
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
985 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
986 def unbind(self, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
987 """Unbind for this widget for event SEQUENCE the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
988 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
989 self.tk.call('bind', self._w, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
990 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
991 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
992 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
993 """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
994 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
995 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
996 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
997 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
998 def unbind_all(self, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
999 """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
1000 self.tk.call('bind', 'all' , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1001 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
1002
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1003 """Bind to widgets with bindtag CLASSNAME at event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1004 SEQUENCE a call of function FUNC. An additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1005 boolean parameter ADD specifies whether FUNC will be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1006 called additionally to the other bound function or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1007 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
1008 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
1009
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1010 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
1011 def unbind_class(self, className, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1012 """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
1013 all functions."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1014 self.tk.call('bind', className , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1015 def mainloop(self, n=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1016 """Call the mainloop of Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1017 self.tk.mainloop(n)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1018 def quit(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1019 """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
1020 self.tk.quit()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1021 def _getints(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1022 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1023 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1024 return tuple(map(getint, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1025 def _getdoubles(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1026 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1027 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1028 return tuple(map(getdouble, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1029 def _getboolean(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1030 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1031 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1032 return self.tk.getboolean(string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1033 def _displayof(self, displayof):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1034 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1035 if displayof:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1036 return ('-displayof', displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1037 if displayof is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1038 return ('-displayof', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1039 return ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1040 def _options(self, cnf, kw = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1041 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1042 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1043 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1044 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1045 cnf = _cnfmerge(cnf)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1046 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1047 for k, v in cnf.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1048 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1049 if k[-1] == '_': k = k[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1050 if callable(v):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1051 v = self._register(v)
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1052 elif isinstance(v, (tuple, list)):
47454
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1053 nv = []
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1054 for item in v:
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1055 if not isinstance(item, (basestring, int)):
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1056 break
47454
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1057 elif isinstance(item, int):
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1058 nv.append('%d' % item)
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1059 else:
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1060 # format it to proper Tcl code if it contains space
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1061 nv.append(('{%s}' if ' ' in item else '%s') % item)
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1062 else:
47454
5353b550c969 Fix Tkinter sequence passing. #2906.
Georg Brandl <georg@python.org>
parents: 47365
diff changeset
1063 v = ' '.join(nv)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1064 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1065 return res
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1066 def nametowidget(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1067 """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
1068 its Tcl name NAME."""
48136
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1069 name = str(name).split('.')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1070 w = self
48136
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1071
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1072 if not name[0]:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1073 w = w._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1074 name = name[1:]
48136
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1075
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1076 for n in name:
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1077 if not n:
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1078 break
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1079 w = w.children[n]
ba84c1e3dd60 Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 48111
diff changeset
1080
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1081 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1082 _nametowidget = nametowidget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1083 def _register(self, func, subst=None, needcleanup=1):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1084 """Return a newly created Tcl function. If this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1085 function is called, the Python function FUNC will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1086 be executed. An optional function SUBST can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1087 be given which will be executed before FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1088 f = CallWrapper(func, subst, self).__call__
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
1089 name = repr(id(f))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1090 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1091 func = func.im_func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1092 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1093 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1094 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1095 name = name + func.__name__
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1096 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1097 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1098 self.tk.createcommand(name, f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1099 if needcleanup:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1100 if self._tclCommands is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1101 self._tclCommands = []
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1102 self._tclCommands.append(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1103 return name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1104 register = _register
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1105 def _root(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1106 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1107 w = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1108 while w.master: w = w.master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1109 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1110 _subst_format = ('%#', '%b', '%f', '%h', '%k',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1111 '%s', '%t', '%w', '%x', '%y',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1112 '%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
1113 _subst_format_str = " ".join(_subst_format)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1114 def _substitute(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1115 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1116 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
1117 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
1118
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1119 getint = int
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1120 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
1121 """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
1122 try:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1123 return int(s)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1124 except ValueError:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1125 return s
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1126
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1127 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
1128 # 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
1129 e = Event()
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1130 # 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
1131 # 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
1132 # 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
1133 # 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
1134 # 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
1135 # 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
1136 # 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
1137 # 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
1138 # 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
1139 # 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
1140 # 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
1141 # 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
1142 # KeyRelease,and Motion events
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1143 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
1144 e.num = getint_event(b)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1145 try: e.focus = getboolean(f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1146 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
1147 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
1148 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
1149 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
1150 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
1151 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
1152 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
1153 e.y = getint_event(y)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1154 e.char = A
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1155 try: e.send_event = getboolean(E)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1156 except TclError: pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1157 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
1158 e.keysym_num = getint_event(N)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1159 e.type = T
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1160 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1161 e.widget = self._nametowidget(W)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1162 except KeyError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1163 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
1164 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
1165 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
1166 try:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1167 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
1168 except ValueError:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1169 e.delta = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1170 return (e,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1171 def _report_exception(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1172 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1173 import sys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1174 exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1175 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1176 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
1177 def _configure(self, cmd, cnf, kw):
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1178 """Internal function."""
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1179 if kw:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1180 cnf = _cnfmerge((cnf, kw))
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1181 elif cnf:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1182 cnf = _cnfmerge(cnf)
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1183 if cnf is None:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1184 cnf = {}
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1185 for x in self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1186 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
1187 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
1188 return cnf
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1189 if type(cnf) is StringType:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1190 x = self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1191 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
1192 return (x[0][1:],) + x[1:]
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1193 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
1194 # These used to be defined in Widget:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1195 def configure(self, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1196 """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
1197
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1198 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1199 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1200 the allowed keyword arguments call the method keys.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1201 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1202 return self._configure('configure', cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1203 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1204 def cget(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1205 """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
1206 return self.tk.call(self._w, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1207 __getitem__ = cget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1208 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1209 self.configure({key: value})
47197
de11bf84491d #615772: raise a more explicit error from Tkinter.Misc.__contains__.
Georg Brandl <georg@python.org>
parents: 47187
diff changeset
1210 def __contains__(self, key):
de11bf84491d #615772: raise a more explicit error from Tkinter.Misc.__contains__.
Georg Brandl <georg@python.org>
parents: 47187
diff changeset
1211 raise TypeError("Tkinter objects don't support 'in' tests.")
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1212 def keys(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1213 """Return a list of all resource names of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1214 return map(lambda x: x[0][1:],
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1215 self.tk.split(self.tk.call(self._w, 'configure')))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1216 def __str__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1217 """Return the window path name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1218 return self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1219 # Pack methods that apply to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1220 _noarg_ = ['_noarg_']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1221 def pack_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1222 """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
1223
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1224 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1225 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
1226 is given the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1227 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1228 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1229 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1230 'pack', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1231 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1232 self.tk.call('pack', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1233 propagate = pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1234 def pack_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1235 """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
1236 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1237 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1238 self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1239 self.tk.call('pack', 'slaves', self._w)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1240 slaves = pack_slaves
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1241 # Place method that applies to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1242 def place_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1243 """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
1244 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1245 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1246 self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1247 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1248 'place', 'slaves', self._w)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1249 # Grid methods that apply to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1250 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
1251 """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
1252 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
1253
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1254 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
1255 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
1256 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
1257 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
1258
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1259 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
1260 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
1261 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1262 args = ('grid', 'bbox', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1263 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
1264 args = args + (column, row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1265 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
1266 args = args + (col2, row2)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1267 return self._getints(self.tk.call(*args)) or None
9636
e58957f06a15 grid_bbox(): support new Tk API: grid bbox ?column row? ?column2 row2?
Barry Warsaw <barry@python.org>
parents: 9357
diff changeset
1268
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1269 bbox = grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1270 def _grid_configure(self, command, index, cnf, kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1271 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1272 if type(cnf) is StringType and not kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1273 if cnf[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1274 cnf = cnf[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1275 if cnf[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1276 cnf = '-'+cnf
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1277 options = (cnf,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1278 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1279 options = self._options(cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1280 if not options:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1281 res = self.tk.call('grid',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1282 command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1283 words = self.tk.splitlist(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1284 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1285 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1286 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1287 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1288 if not value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1289 value = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1290 elif '.' in value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1291 value = getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1292 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1293 value = getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1294 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1295 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1296 res = self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1297 ('grid', command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1298 + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1299 if len(options) == 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1300 if not res: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1301 # 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
1302 if '.' in res: return getdouble(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1303 return getint(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1304 def grid_columnconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1305 """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
1306
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1307 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
1308 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
1309 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1310 return self._grid_configure('columnconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1311 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
1312 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
1313 """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
1314 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
1315 widget is located."""
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1316 return self._getints(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1317 self.tk.call(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1318 '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
1319 def grid_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1320 """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
1321
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1322 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1323 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
1324 is given, the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1325 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1326 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1327 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1328 'grid', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1329 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1330 self.tk.call('grid', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1331 def grid_rowconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1332 """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
1333
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1334 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
1335 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
1336 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1337 return self._grid_configure('rowconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1338 rowconfigure = grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1339 def grid_size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1340 """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
1341 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1342 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
1343 size = grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1344 def grid_slaves(self, row=None, column=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1345 """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
1346 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1347 args = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1348 if row is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1349 args = args + ('-row', row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1350 if column is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1351 args = args + ('-column', column)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1352 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1353 self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1354 ('grid', 'slaves', self._w) + args)))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1355
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1356 # 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
1357 # 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
1358
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1359 def event_add(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1360 """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
1361 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
1362 whenever SEQUENCE occurs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1363 args = ('event', 'add', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1364 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
1365
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1366 def event_delete(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1367 """Unbind a virtual event VIRTUAL from SEQUENCE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1368 args = ('event', 'delete', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1369 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
1370
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1371 def event_generate(self, sequence, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1372 """Generate an event SEQUENCE. Additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1373 keyword arguments specify parameter of the event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1374 (e.g. x, y, rootx, rooty)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1375 args = ('event', 'generate', self._w, sequence)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1376 for k, v in kw.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1377 args = args + ('-%s' % k, str(v))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1378 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
1379
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1380 def event_info(self, virtual=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1381 """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
1382 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
1383 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1384 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
1385
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1386 # 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
1387
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1388 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1389 """Return a list of all existing image names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1390 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
1391
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1392 def image_types(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1393 """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
1394 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
1395
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1396
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
1397 class CallWrapper:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1398 """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
1399 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
1400 def __init__(self, func, subst, widget):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1401 """Store FUNC, SUBST and WIDGET as members."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1402 self.func = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1403 self.subst = subst
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1404 self.widget = widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1405 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1406 """Apply first function SUBST to arguments, than FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1407 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1408 if self.subst:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1409 args = self.subst(*args)
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1410 return self.func(*args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1411 except SystemExit, msg:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1412 raise SystemExit, msg
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1413 except:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1414 self.widget._report_exception()
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1415
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
1416
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1417 class Wm:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1418 """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
1419
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1420 def wm_aspect(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1421 minNumer=None, minDenom=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1422 maxNumer=None, maxDenom=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1423 """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
1424 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
1425 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
1426 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1427 self.tk.call('wm', 'aspect', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1428 minNumer, minDenom,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1429 maxNumer, maxDenom))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1430 aspect = wm_aspect
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1431
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1432 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
1433 """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
1434
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1435 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
1436 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
1437 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
1438 are as follows:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1439
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1440 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
1441 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
1442 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
1443 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
1444 windows).
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1445
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1446 On Macintosh, XXXXX
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1447
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1448 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
1449 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1450 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
1451 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
1452 attributes=wm_attributes
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1453
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1454 def wm_client(self, name=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1455 """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
1456 current value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1457 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
1458 client = wm_client
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1459 def wm_colormapwindows(self, *wlist):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1460 """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
1461 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
1462 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
1463 if len(wlist) > 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1464 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
1465 args = ('wm', 'colormapwindows', self._w) + wlist
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1466 return map(self._nametowidget, self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1467 colormapwindows = wm_colormapwindows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1468 def wm_command(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1469 """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
1470 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
1471 command if VALUE is None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1472 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
1473 command = wm_command
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1474 def wm_deiconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1475 """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
1476 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
1477 return self.tk.call('wm', 'deiconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1478 deiconify = wm_deiconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1479 def wm_focusmodel(self, model=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1480 """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
1481 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
1482 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
1483 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
1484 focusmodel = wm_focusmodel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1485 def wm_frame(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1486 """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
1487 return self.tk.call('wm', 'frame', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1488 frame = wm_frame
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1489 def wm_geometry(self, newGeometry=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1490 """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
1491 current value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1492 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
1493 geometry = wm_geometry
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1494 def wm_grid(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1495 baseWidth=None, baseHeight=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1496 widthInc=None, heightInc=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1497 """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
1498 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
1499 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
1500 number of grid units requested in Tk_GeometryRequest."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1501 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1502 'wm', 'grid', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1503 baseWidth, baseHeight, widthInc, heightInc))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1504 grid = wm_grid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1505 def wm_group(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1506 """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
1507 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
1508 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
1509 group = wm_group
38855
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1510 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
1511 """Set bitmap for the iconified widget to BITMAP. Return
38855
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1512 the bitmap if None is given.
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1513
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
1514 Under Windows, the DEFAULT parameter can be used to set the icon
38855
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1515 for the widget and any descendents that don't have an icon set
38863
484d3d5ba7f9 Fix typo in docstring
Neal Norwitz <nnorwitz@gmail.com>
parents: 38856
diff changeset
1516 explicitly. DEFAULT can be the relative path to a .ico file
38855
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1517 (example: root.iconbitmap(default='myicon.ico') ). See Tk
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1518 documentation for more information."""
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1519 if default:
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1520 return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1521 else:
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1522 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
1523 iconbitmap = wm_iconbitmap
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1524 def wm_iconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1525 """Display widget as icon."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1526 return self.tk.call('wm', 'iconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1527 iconify = wm_iconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1528 def wm_iconmask(self, bitmap=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1529 """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
1530 mask if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1531 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
1532 iconmask = wm_iconmask
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1533 def wm_iconname(self, newName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1534 """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
1535 None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1536 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
1537 iconname = wm_iconname
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1538 def wm_iconposition(self, x=None, y=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1539 """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
1540 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
1541 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1542 'wm', 'iconposition', self._w, x, y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1543 iconposition = wm_iconposition
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1544 def wm_iconwindow(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1545 """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
1546 value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1547 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
1548 iconwindow = wm_iconwindow
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1549 def wm_maxsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1550 """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
1551 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
1552 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1553 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1554 'wm', 'maxsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1555 maxsize = wm_maxsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1556 def wm_minsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1557 """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
1558 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
1559 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1560 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1561 'wm', 'minsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1562 minsize = wm_minsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1563 def wm_overrideredirect(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1564 """Instruct the window manager to ignore this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1565 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
1566 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1567 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1568 'wm', 'overrideredirect', self._w, boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1569 overrideredirect = wm_overrideredirect
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1570 def wm_positionfrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1571 """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
1572 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
1573 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1574 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
1575 positionfrom = wm_positionfrom
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1576 def wm_protocol(self, name=None, func=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1577 """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
1578 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
1579 e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW"."""
48176
f7846a71e38a Remove a use of callable() from Tkinter to silence warnings under -3.
Brett Cannon <bcannon@gmail.com>
parents: 48136
diff changeset
1580 if hasattr(func, '__call__'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1581 command = self._register(func)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1582 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1583 command = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1584 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1585 'wm', 'protocol', self._w, name, command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1586 protocol = wm_protocol
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1587 def wm_resizable(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1588 """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
1589 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
1590 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
1591 resizable = wm_resizable
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1592 def wm_sizefrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1593 """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
1594 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
1595 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1596 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
1597 sizefrom = wm_sizefrom
13906
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1598 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
1599 """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
1600 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
1601 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
1602 state = wm_state
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1603 def wm_title(self, string=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1604 """Set the title of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1605 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
1606 title = wm_title
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1607 def wm_transient(self, master=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1608 """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
1609 with regard to widget MASTER."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1610 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
1611 transient = wm_transient
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1612 def wm_withdraw(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1613 """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
1614 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
1615 return self.tk.call('wm', 'withdraw', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1616 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
1617
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1618
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1619 class Tk(Misc, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1620 """Toplevel widget of Tk which represents mostly the main window
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1621 of an appliation. It has an associated Tcl interpreter."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1622 _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
1623 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
1624 useTk=1, sync=0, use=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1625 """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
1626 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
1627 readprofile).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1628 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
1629 is the name of the widget class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1630 self.master = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1631 self.children = {}
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1632 self._tkloaded = 0
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1633 # 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
1634 # ensure that self.tk is always _something_.
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31547
diff changeset
1635 self.tk = None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1636 if baseName is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1637 import sys, os
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1638 baseName = os.path.basename(sys.argv[0])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1639 baseName, ext = os.path.splitext(baseName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1640 if ext not in ('.py', '.pyc', '.pyo'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1641 baseName = baseName + ext
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1642 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
1643 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
1644 if useTk:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1645 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1646 self.readprofile(baseName, className)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1647 def loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1648 if not self._tkloaded:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1649 self.tk.loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1650 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1651 def _loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1652 self._tkloaded = 1
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1653 global _default_root
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1654 # Version sanity checks
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1655 tk_version = self.tk.getvar('tk_version')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1656 if tk_version != _tkinter.TK_VERSION:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1657 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1658 "tk.h version (%s) doesn't match libtk.a version (%s)" \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1659 % (_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
1660 # 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
1661 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
1662 if tcl_version != _tkinter.TCL_VERSION:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1663 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1664 "tcl.h version (%s) doesn't match libtcl.a version (%s)" \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1665 % (_tkinter.TCL_VERSION, tcl_version)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1666 if TkVersion < 4.0:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1667 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1668 "Tk 4.0 or higher is required; found Tk %s" \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1669 % str(TkVersion)
34642
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1670 # 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
1671 # 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
1672 # 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
1673 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
1674 self._tclCommands = []
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1675 self.tk.createcommand('tkerror', _tkerror)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1676 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
1677 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
1678 self._tclCommands.append('exit')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1679 if _support_default_root and not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1680 _default_root = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1681 self.protocol("WM_DELETE_WINDOW", self.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1682 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1683 """Destroy this and all descendants widgets. This will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1684 end the application of this Tcl interpreter."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1685 for c in self.children.values(): c.destroy()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1686 self.tk.call('destroy', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1687 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1688 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1689 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
1690 _default_root = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1691 def readprofile(self, baseName, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1692 """Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1693 the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1694 such a file exists in the home directory."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1695 import os
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1696 if os.environ.has_key('HOME'): home = os.environ['HOME']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1697 else: home = os.curdir
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1698 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
1699 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
1700 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
1701 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
1702 dir = {'self': self}
47183
b53604fad54b Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents: 47182
diff changeset
1703 exec 'from Tkinter import *' in dir
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1704 if os.path.isfile(class_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1705 self.tk.call('source', class_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1706 if os.path.isfile(class_py):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1707 execfile(class_py, dir)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1708 if os.path.isfile(base_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1709 self.tk.call('source', base_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1710 if os.path.isfile(base_py):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1711 execfile(base_py, dir)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1712 def report_callback_exception(self, exc, val, tb):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1713 """Internal function. It reports exception on sys.stderr."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1714 import traceback, sys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1715 sys.stderr.write("Exception in Tkinter callback\n")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1716 sys.last_type = exc
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1717 sys.last_value = val
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1718 sys.last_traceback = tb
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1719 traceback.print_exception(exc, val, tb)
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1720 def __getattr__(self, attr):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1721 "Delegate attribute access to the interpreter object"
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1722 return getattr(self.tk, attr)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1723
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1724 # Ideally, the classes Pack, Place and Grid disappear, the
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1725 # pack/place/grid methods are defined on the Widget class, and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1726 # everybody uses w.pack_whatever(...) instead of Pack.whatever(w,
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1727 # ...), with pack(), place() and grid() being short for
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1728 # pack_configure(), place_configure() and grid_columnconfigure(), and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1729 # 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
1730 # 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
1731 # 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
1732 # backwards compatibility features. Also note that those methods that
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1733 # 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
1734 # the Misc class (which now incorporates all methods common between
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1735 # toplevel and interior widgets). Again, for compatibility, these are
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1736 # copied into the Pack, Place or Grid class.
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1737
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1738
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1739 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
1740 return Tk(screenName, baseName, className, useTk)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1741
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1742 class Pack:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1743 """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
1744
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1745 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
1746 def pack_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1747 """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
1748 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
1749 anchor=NSEW (or subset) - position widget according to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1750 given direction
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1751 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
1752 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
1753 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
1754 in=master - use master to contain this widget
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1755 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1756 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1757 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1758 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1759 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1760 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
1761 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1762 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1763 ('pack', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1764 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1765 pack = configure = config = pack_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1766 def pack_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1767 """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
1768 self.tk.call('pack', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1769 forget = pack_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1770 def pack_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1771 """Return information about the packing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1772 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1773 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1774 self.tk.call('pack', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1775 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1776 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1777 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1778 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1779 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1780 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1781 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1782 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1783 info = pack_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1784 propagate = pack_propagate = Misc.pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1785 slaves = pack_slaves = Misc.pack_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1786
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1787 class Place:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1788 """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
1789
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1790 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
1791 def place_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1792 """Place a widget in the parent widget. Use as options:
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1793 in=master - master relative to which the widget is placed
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1794 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1795 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
1796 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
1797 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
1798 relative to width of master (1.0 is right edge)
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1799 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
1800 relative to height of master (1.0 is bottom edge)
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1801 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
1802 width=amount - width of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1803 height=amount - height of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1804 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
1805 relative to width of master (1.0 is the same width
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1806 as the master)
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1807 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
1808 relative to height of master (1.0 is the same
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1809 height as the master)
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1810 bordermode="inside" or "outside" - whether to take border width of
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1811 master widget into account
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1812 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1813 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1814 ('place', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1815 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1816 place = configure = config = place_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1817 def place_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1818 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1819 self.tk.call('place', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1820 forget = place_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1821 def place_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1822 """Return information about the placing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1823 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1824 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1825 self.tk.call('place', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1826 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1827 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1828 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1829 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1830 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1831 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1832 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1833 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1834 info = place_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1835 slaves = place_slaves = Misc.place_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1836
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1837 class Grid:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1838 """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
1839
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1840 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
1841 # Thanks to Masazumi Yoshikawa (yosikawa@isi.edu)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1842 def grid_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1843 """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
1844 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
1845 columnspan=number - this widget will span several columns
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1846 in=master - use master to contain this widget
47365
29c9536c04ad #2906: accept lists for options, and some cosmetic fixes in Tkinter.
Georg Brandl <georg@python.org>
parents: 47197
diff changeset
1847 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1848 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1849 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1850 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1851 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1852 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
1853 rowspan=number - this widget will span several rows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1854 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
1855 widget stick to the cell boundary
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1856 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1857 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1858 ('grid', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1859 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1860 grid = configure = config = grid_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1861 bbox = grid_bbox = Misc.grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1862 columnconfigure = grid_columnconfigure = Misc.grid_columnconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1863 def grid_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1864 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1865 self.tk.call('grid', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1866 forget = grid_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1867 def grid_remove(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1868 """Unmap this widget but remember the grid options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1869 self.tk.call('grid', 'remove', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1870 def grid_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1871 """Return information about the options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1872 for positioning this widget in a grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1873 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1874 self.tk.call('grid', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1875 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1876 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1877 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1878 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1879 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1880 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1881 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1882 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1883 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
1884 location = grid_location = Misc.grid_location
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1885 propagate = grid_propagate = Misc.grid_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1886 rowconfigure = grid_rowconfigure = Misc.grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1887 size = grid_size = Misc.grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1888 slaves = grid_slaves = Misc.grid_slaves
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1889
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1890 class BaseWidget(Misc):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1891 """Internal class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1892 def _setup(self, master, cnf):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1893 """Internal function. Sets up information about children."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1894 if _support_default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1895 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1896 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1897 if not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1898 _default_root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1899 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1900 self.master = master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1901 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1902 name = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1903 if cnf.has_key('name'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1904 name = cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1905 del cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1906 if not name:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
1907 name = repr(id(self))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1908 self._name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1909 if master._w=='.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1910 self._w = '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1911 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1912 self._w = master._w + '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1913 self.children = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1914 if self.master.children.has_key(self._name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1915 self.master.children[self._name].destroy()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1916 self.master.children[self._name] = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1917 def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1918 """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
1919 and appropriate options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1920 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1921 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1922 self.widgetName = widgetName
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1923 BaseWidget._setup(self, master, cnf)
49631
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
1924 if self._tclCommands is None:
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
1925 self._tclCommands = []
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1926 classes = []
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1927 for k in cnf.keys():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1928 if type(k) is ClassType:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1929 classes.append((k, cnf[k]))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1930 del cnf[k]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1931 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1932 (widgetName, self._w) + extra + self._options(cnf))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1933 for k, v in classes:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1934 k.configure(self, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1935 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1936 """Destroy this and all descendants widgets."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1937 for c in self.children.values(): c.destroy()
38856
aff6629d1d1c Patch #1494750: Destroy master after deleting children.
Martin v. Löwis <martin@v.loewis.de>
parents: 38855
diff changeset
1938 self.tk.call('destroy', self._w)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1939 if self.master.children.has_key(self._name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1940 del self.master.children[self._name]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1941 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1942 def _do(self, name, args=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1943 # XXX Obsolete -- better use self.tk.call directly!
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1944 return self.tk.call((self._w, name) + args)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1945
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1946 class Widget(BaseWidget, Pack, Place, Grid):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1947 """Internal class.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
1948
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1949 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
1950 Pack, Place or Grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1951 pass
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1952
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1953 class Toplevel(BaseWidget, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1954 """Toplevel widget, e.g. for dialogs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1955 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1956 """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
1957
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1958 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1959 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1960 highlightcolor, highlightthickness, menu, relief, screen, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1961 use, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1962 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1963 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1964 extra = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1965 for wmkey in ['screen', 'class_', 'class', 'visual',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1966 'colormap']:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1967 if cnf.has_key(wmkey):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1968 val = cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1969 # TBD: a hack needed because some keys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1970 # are not valid as keyword arguments
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1971 if wmkey[-1] == '_': opt = '-'+wmkey[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1972 else: opt = '-'+wmkey
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1973 extra = extra + (opt, val)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1974 del cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1975 BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1976 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1977 self.iconname(root.iconname())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1978 self.title(root.title())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1979 self.protocol("WM_DELETE_WINDOW", self.destroy)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1980
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1981 class Button(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1982 """Button widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1983 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1984 """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
1985
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1986 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1987
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1988 activebackground, activeforeground, anchor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1989 background, bitmap, borderwidth, cursor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1990 disabledforeground, font, foreground
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1991 highlightbackground, highlightcolor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1992 highlightthickness, image, justify,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1993 padx, pady, relief, repeatdelay,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1994 repeatinterval, takefocus, text,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1995 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1996
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1997 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1998
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1999 command, compound, default, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2000 overrelief, state, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2001 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2002 Widget.__init__(self, master, 'button', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2003
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2004 def tkButtonEnter(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2005 self.tk.call('tkButtonEnter', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2006
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2007 def tkButtonLeave(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2008 self.tk.call('tkButtonLeave', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2009
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2010 def tkButtonDown(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2011 self.tk.call('tkButtonDown', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2012
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2013 def tkButtonUp(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2014 self.tk.call('tkButtonUp', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2015
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2016 def tkButtonInvoke(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2017 self.tk.call('tkButtonInvoke', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2018
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2019 def flash(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2020 """Flash the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2021
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2022 This is accomplished by redisplaying
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2023 the button several times, alternating between active and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2024 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
2025 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
2026 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
2027 disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2028 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2029 self.tk.call(self._w, 'flash')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2030
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2031 def invoke(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2032 """Invoke the command associated with the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2033
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2034 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
2035 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
2036 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
2037 is disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2038 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2039 return self.tk.call(self._w, 'invoke')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2040
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2041 # Indices:
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
2042 # XXX I don't like these -- take them away
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2043 def AtEnd():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2044 return 'end'
1669
273451892327 Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents: 1666
diff changeset
2045 def AtInsert(*args):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2046 s = 'insert'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2047 for a in args:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2048 if a: s = s + (' ' + a)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2049 return s
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2050 def AtSelFirst():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2051 return 'sel.first'
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2052 def AtSelLast():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2053 return 'sel.last'
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2054 def At(x, y=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2055 if y is None:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
2056 return '@%r' % (x,)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2057 else:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
2058 return '@%r,%r' % (x, y)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2059
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2060 class Canvas(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2061 """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
2062 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2063 """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
2064
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2065 Valid resource names: background, bd, bg, borderwidth, closeenough,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2066 confine, cursor, height, highlightbackground, highlightcolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2067 highlightthickness, insertbackground, insertborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2068 insertofftime, insertontime, insertwidth, offset, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2069 scrollregion, selectbackground, selectborderwidth, selectforeground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2070 state, takefocus, width, xscrollcommand, xscrollincrement,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2071 yscrollcommand, yscrollincrement."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2072 Widget.__init__(self, master, 'canvas', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2073 def addtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2074 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2075 self.tk.call((self._w, 'addtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2076 def addtag_above(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2077 """Add tag NEWTAG to all items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2078 self.addtag(newtag, 'above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2079 def addtag_all(self, newtag):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2080 """Add tag NEWTAG to all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2081 self.addtag(newtag, 'all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2082 def addtag_below(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2083 """Add tag NEWTAG to all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2084 self.addtag(newtag, 'below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2085 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
2086 """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
2087 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2088 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
2089 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
2090 self.addtag(newtag, 'closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2091 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
2092 """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
2093 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2094 self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2095 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
2096 """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
2097 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2098 self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2099 def addtag_withtag(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2100 """Add tag NEWTAG to all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2101 self.addtag(newtag, 'withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2102 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2103 """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
2104 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
2105 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2106 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
2107 def tag_unbind(self, tagOrId, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2108 """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
2109 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2110 self.tk.call(self._w, 'bind', tagOrId, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2111 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2112 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2113 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
2114 """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
2115
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2116 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
2117 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
2118 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
2119 return self._bind((self._w, 'bind', tagOrId),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2120 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2121 def canvasx(self, screenx, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2122 """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
2123 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2124 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2125 self._w, 'canvasx', screenx, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2126 def canvasy(self, screeny, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2127 """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
2128 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2129 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2130 self._w, 'canvasy', screeny, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2131 def coords(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2132 """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
2133 # XXX Should use _flatten on args
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2134 return map(getdouble,
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
2135 self.tk.splitlist(
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2136 self.tk.call((self._w, 'coords') + args)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2137 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
2138 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2139 args = _flatten(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2140 cnf = args[-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2141 if type(cnf) in (DictionaryType, TupleType):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2142 args = args[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2143 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2144 cnf = {}
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2145 return getint(self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2146 self._w, 'create', itemType,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2147 *(args + self._options(cnf, kw))))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2148 def create_arc(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2149 """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
2150 return self._create('arc', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2151 def create_bitmap(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2152 """Create bitmap with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2153 return self._create('bitmap', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2154 def create_image(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2155 """Create image item with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2156 return self._create('image', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2157 def create_line(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2158 """Create line with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2159 return self._create('line', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2160 def create_oval(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2161 """Create oval with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2162 return self._create('oval', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2163 def create_polygon(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2164 """Create polygon with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2165 return self._create('polygon', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2166 def create_rectangle(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2167 """Create rectangle with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2168 return self._create('rectangle', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2169 def create_text(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2170 """Create text with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2171 return self._create('text', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2172 def create_window(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2173 """Create window with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2174 return self._create('window', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2175 def dchars(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2176 """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
2177 several times) from FIRST to LAST character (including)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2178 self.tk.call((self._w, 'dchars') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2179 def delete(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2180 """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
2181 self.tk.call((self._w, 'delete') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2182 def dtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2183 """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
2184 identified by first argument in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2185 self.tk.call((self._w, 'dtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2186 def find(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2187 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2188 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2189 self.tk.call((self._w, 'find') + args)) or ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2190 def find_above(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2191 """Return items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2192 return self.find('above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2193 def find_all(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2194 """Return all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2195 return self.find('all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2196 def find_below(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2197 """Return all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2198 return self.find('below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2199 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
2200 """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
2201 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2202 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
2203 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
2204 return self.find('closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2205 def find_enclosed(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2206 """Return all items in rectangle defined
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2207 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2208 return self.find('enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2209 def find_overlapping(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2210 """Return all items which overlap the rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2211 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2212 return self.find('overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2213 def find_withtag(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2214 """Return all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2215 return self.find('withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2216 def focus(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2217 """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
2218 return self.tk.call((self._w, 'focus') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2219 def gettags(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2220 """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
2221 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2222 self.tk.call((self._w, 'gettags') + args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2223 def icursor(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2224 """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
2225 In ARGS TAGORID must be first."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2226 self.tk.call((self._w, 'icursor') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2227 def index(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2228 """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
2229 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
2230 def insert(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2231 """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
2232 be TAGORID POS TEXT."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2233 self.tk.call((self._w, 'insert') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2234 def itemcget(self, tagOrId, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2235 """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
2236 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2237 (self._w, 'itemcget') + (tagOrId, '-'+option))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2238 def itemconfigure(self, tagOrId, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2239 """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
2240
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2241 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2242 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2243 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
2244 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2245 return self._configure(('itemconfigure', tagOrId), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2246 itemconfig = itemconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2247 # 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
2248 # 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
2249 # (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
2250 # 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
2251 def tag_lower(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2252 """Lower an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2253 (optional below another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2254 self.tk.call((self._w, 'lower') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2255 lower = tag_lower
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2256 def move(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2257 """Move an item TAGORID given in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2258 self.tk.call((self._w, 'move') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2259 def postscript(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2260 """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
2261 file. Valid options: colormap, colormode, file, fontmap,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2262 height, pageanchor, pageheight, pagewidth, pagex, pagey,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2263 rotate, witdh, x, y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2264 return self.tk.call((self._w, 'postscript') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2265 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2266 def tag_raise(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2267 """Raise an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2268 (optional above another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2269 self.tk.call((self._w, 'raise') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2270 lift = tkraise = tag_raise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2271 def scale(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2272 """Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2273 self.tk.call((self._w, 'scale') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2274 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2275 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2276 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
2277 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
2278 """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
2279 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
2280 scan_mark."""
27211
a494f5a8639f Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Neal Norwitz <nnorwitz@gmail.com>
parents: 26428
diff changeset
2281 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
2282 def select_adjust(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2283 """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
2284 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
2285 def select_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2286 """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
2287 self.tk.call(self._w, 'select', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2288 def select_from(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2289 """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
2290 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
2291 def select_item(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2292 """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
2293 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
2294 def select_to(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2295 """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
2296 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
2297 def type(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2298 """Return the type of the item TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2299 return self.tk.call(self._w, 'type', tagOrId) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2300 def xview(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2301 """Query and change horizontal position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2302 if not args:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2303 return self._getdoubles(self.tk.call(self._w, 'xview'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2304 self.tk.call((self._w, 'xview') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2305 def xview_moveto(self, fraction):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2306 """Adjusts the view in the window so that FRACTION of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2307 total width of the canvas is off-screen to the left."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2308 self.tk.call(self._w, 'xview', 'moveto', fraction)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2309 def xview_scroll(self, number, what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2310 """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2311 self.tk.call(self._w, 'xview', 'scroll', number, what)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2312 def yview(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2313 """Query and change vertical position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2314 if not args:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2315 return self._getdoubles(self.tk.call(self._w, 'yview'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2316 self.tk.call((self._w, 'yview') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2317 def yview_moveto(self, fraction):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2318 """Adjusts the view in the window so that FRACTION of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2319 total height of the canvas is off-screen to the top."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2320 self.tk.call(self._w, 'yview', 'moveto', fraction)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2321 def yview_scroll(self, number, what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2322 """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2323 self.tk.call(self._w, 'yview', 'scroll', number, what)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2324
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2325 class Checkbutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2326 """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
2327 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2328 """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
2329
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2330 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2331 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2332 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2333 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2334 indicatoron, justify, offvalue, onvalue, padx, pady, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2335 selectcolor, selectimage, state, takefocus, text, textvariable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2336 underline, variable, width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2337 Widget.__init__(self, master, 'checkbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2338 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2339 """Put the button in off-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2340 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2341 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2342 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2343 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2344 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2345 """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
2346 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2347 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2348 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2349 self.tk.call(self._w, 'select')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2350 def toggle(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2351 """Toggle the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2352 self.tk.call(self._w, 'toggle')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2353
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2354 class Entry(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2355 """Entry widget which allows to display simple text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2356 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2357 """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
2358
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2359 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2360 exportselection, fg, font, foreground, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2361 highlightcolor, highlightthickness, insertbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2362 insertborderwidth, insertofftime, insertontime, insertwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2363 invalidcommand, invcmd, justify, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2364 selectborderwidth, selectforeground, show, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2365 textvariable, validate, validatecommand, vcmd, width,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2366 xscrollcommand."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2367 Widget.__init__(self, master, 'entry', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2368 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2369 """Delete text from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2370 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2371 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2372 """Return the text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2373 return self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2374 def icursor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2375 """Insert cursor at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2376 self.tk.call(self._w, 'icursor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2377 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2378 """Return position of cursor."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2379 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2380 self._w, 'index', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2381 def insert(self, index, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2382 """Insert STRING at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2383 self.tk.call(self._w, 'insert', index, string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2384 def scan_mark(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2385 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2386 self.tk.call(self._w, 'scan', 'mark', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2387 def scan_dragto(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2388 """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
2389 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
2390 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2391 self.tk.call(self._w, 'scan', 'dragto', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2392 def selection_adjust(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2393 """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
2394 self.tk.call(self._w, 'selection', 'adjust', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2395 select_adjust = selection_adjust
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2396 def selection_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2397 """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
2398 self.tk.call(self._w, 'selection', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2399 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2400 def selection_from(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2401 """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
2402 self.tk.call(self._w, 'selection', 'from', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2403 select_from = selection_from
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2404 def selection_present(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2405 """Return whether the widget has the selection."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2406 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2407 self.tk.call(self._w, 'selection', 'present'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2408 select_present = selection_present
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2409 def selection_range(self, start, end):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2410 """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
2411 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
2412 select_range = selection_range
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2413 def selection_to(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2414 """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
2415 self.tk.call(self._w, 'selection', 'to', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2416 select_to = selection_to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2417 def xview(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2418 """Query and change horizontal position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2419 self.tk.call(self._w, 'xview', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2420 def xview_moveto(self, fraction):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2421 """Adjust the view in the window so that FRACTION of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2422 total width of the entry is off-screen to the left."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2423 self.tk.call(self._w, 'xview', 'moveto', fraction)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2424 def xview_scroll(self, number, what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2425 """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2426 self.tk.call(self._w, 'xview', 'scroll', number, what)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2427
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2428 class Frame(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2429 """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
2430 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2431 """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
2432
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2433 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2434 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2435 highlightcolor, highlightthickness, relief, takefocus, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2436 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2437 extra = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2438 if cnf.has_key('class_'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2439 extra = ('-class', cnf['class_'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2440 del cnf['class_']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2441 elif cnf.has_key('class'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2442 extra = ('-class', cnf['class'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2443 del cnf['class']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2444 Widget.__init__(self, master, 'frame', cnf, {}, extra)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2445
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2446 class Label(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2447 """Label widget which can display text and bitmaps."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2448 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2449 """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
2450
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2451 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2452
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2453 activebackground, activeforeground, anchor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2454 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
2455 disabledforeground, font, foreground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2456 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2457 highlightthickness, image, justify,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2458 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
2459 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2460
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2461 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2462
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2463 height, state, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2464
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2465 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2466 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
2467
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2468 class Listbox(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2469 """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
2470 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2471 """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
2472
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2473 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2474 exportselection, fg, font, foreground, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2475 highlightcolor, highlightthickness, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2476 selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2477 width, xscrollcommand, yscrollcommand, listvariable."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2478 Widget.__init__(self, master, 'listbox', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2479 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2480 """Activate item identified by INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2481 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2482 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2483 """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
2484 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
2485 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2486 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
2487 def curselection(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2488 """Return list of indices of currently selected item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2489 # XXX Ought to apply self._getints()...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2490 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2491 self._w, 'curselection'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2492 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2493 """Delete items from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2494 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2495 def get(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2496 """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
2497 if last:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2498 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2499 self._w, 'get', first, last))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2500 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2501 return self.tk.call(self._w, 'get', first)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2502 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2503 """Return index of item identified with INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2504 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2505 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2506 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2507 def insert(self, index, *elements):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2508 """Insert ELEMENTS at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2509 self.tk.call((self._w, 'insert', index) + elements)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2510 def nearest(self, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2511 """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
2512 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2513 self._w, 'nearest', y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2514 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2515 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2516 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
2517 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2518 """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
2519 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
2520 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2521 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
2522 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2523 """Scroll such that INDEX is visible."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2524 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2525 def selection_anchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2526 """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
2527 self.tk.call(self._w, 'selection', 'anchor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2528 select_anchor = selection_anchor
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2529 def selection_clear(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2530 """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
2531 self.tk.call(self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2532 'selection', 'clear', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2533 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2534 def selection_includes(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2535 """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
2536 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2537 self._w, 'selection', 'includes', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2538 select_includes = selection_includes
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2539 def selection_set(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2540 """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
2541 changing the currently selected elements."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2542 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
2543 select_set = selection_set
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2544 def size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2545 """Return the number of elements in the listbox."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2546 return getint(self.tk.call(self._w, 'size'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2547 def xview(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2548 """Query and change horizontal position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2549 if not what:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2550 return self._getdoubles(self.tk.call(self._w, 'xview'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2551 self.tk.call((self._w, 'xview') + what)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2552 def xview_moveto(self, fraction):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2553 """Adjust the view in the window so that FRACTION of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2554 total width of the entry is off-screen to the left."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2555 self.tk.call(self._w, 'xview', 'moveto', fraction)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2556 def xview_scroll(self, number, what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2557 """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2558 self.tk.call(self._w, 'xview', 'scroll', number, what)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2559 def yview(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2560 """Query and change vertical position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2561 if not what:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2562 return self._getdoubles(self.tk.call(self._w, 'yview'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2563 self.tk.call((self._w, 'yview') + what)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2564 def yview_moveto(self, fraction):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2565 """Adjust the view in the window so that FRACTION of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2566 total width of the entry is off-screen to the top."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2567 self.tk.call(self._w, 'yview', 'moveto', fraction)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2568 def yview_scroll(self, number, what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2569 """Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2570 self.tk.call(self._w, 'yview', 'scroll', number, what)
19743
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2571 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
2572 """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
2573 return self.tk.call(
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2574 (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
2575 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
2576 """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
2577
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2578 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
2579 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
2580 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
2581 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
2582 selectbackground, selectforeground."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2583 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
2584 itemconfig = itemconfigure
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2585
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2586 class Menu(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2587 """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
2588 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2589 """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
2590
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2591 Valid resource names: activebackground, activeborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2592 activeforeground, background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2593 disabledforeground, fg, font, foreground, postcommand, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2594 selectcolor, takefocus, tearoff, tearoffcommand, title, type."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2595 Widget.__init__(self, master, 'menu', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2596 def tk_bindForTraversal(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2597 pass # obsolete since Tk 4.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2598 def tk_mbPost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2599 self.tk.call('tk_mbPost', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2600 def tk_mbUnpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2601 self.tk.call('tk_mbUnpost')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2602 def tk_traverseToMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2603 self.tk.call('tk_traverseToMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2604 def tk_traverseWithinMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2605 self.tk.call('tk_traverseWithinMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2606 def tk_getMenuButtons(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2607 return self.tk.call('tk_getMenuButtons', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2608 def tk_nextMenu(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2609 self.tk.call('tk_nextMenu', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2610 def tk_nextMenuEntry(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2611 self.tk.call('tk_nextMenuEntry', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2612 def tk_invokeMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2613 self.tk.call('tk_invokeMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2614 def tk_firstMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2615 self.tk.call('tk_firstMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2616 def tk_mbButtonDown(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2617 self.tk.call('tk_mbButtonDown', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2618 def tk_popup(self, x, y, entry=""):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2619 """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
2620 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
2621 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2622 """Activate entry at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2623 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2624 def add(self, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2625 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2626 self.tk.call((self._w, 'add', itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2627 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2628 def add_cascade(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2629 """Add hierarchical menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2630 self.add('cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2631 def add_checkbutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2632 """Add checkbutton menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2633 self.add('checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2634 def add_command(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2635 """Add command menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2636 self.add('command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2637 def add_radiobutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2638 """Addd radio menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2639 self.add('radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2640 def add_separator(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2641 """Add separator."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2642 self.add('separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2643 def insert(self, index, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2644 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2645 self.tk.call((self._w, 'insert', index, itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2646 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2647 def insert_cascade(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2648 """Add hierarchical menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2649 self.insert(index, 'cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2650 def insert_checkbutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2651 """Add checkbutton menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2652 self.insert(index, 'checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2653 def insert_command(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2654 """Add command menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2655 self.insert(index, 'command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2656 def insert_radiobutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2657 """Addd radio menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2658 self.insert(index, 'radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2659 def insert_separator(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2660 """Add separator at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2661 self.insert(index, 'separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2662 def delete(self, index1, index2=None):
49631
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2663 """Delete menu items between INDEX1 and INDEX2 (included)."""
48207
5a15a7044e7d Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48176
diff changeset
2664 if index2 is None:
5a15a7044e7d Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48176
diff changeset
2665 index2 = index1
49631
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2666
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2667 num_index1, num_index2 = self.index(index1), self.index(index2)
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2668 if (num_index1 is None) or (num_index2 is None):
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2669 num_index1, num_index2 = 0, -1
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2670
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2671 for i in range(num_index1, num_index2 + 1):
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2672 if 'command' in self.entryconfig(i):
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2673 c = str(self.entrycget(i, 'command'))
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2674 if c:
00e71cd89128 Merged revisions 67082 via svnmerge from
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48821
diff changeset
2675 self.deletecommand(c)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2676 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2677 def entrycget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2678 """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
2679 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
2680 def entryconfigure(self, index, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2681 """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
2682 return self._configure(('entryconfigure', index), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2683 entryconfig = entryconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2684 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2685 """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
2686 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2687 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2688 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2689 def invoke(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2690 """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
2691 the associated command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2692 return self.tk.call(self._w, 'invoke', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2693 def post(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2694 """Display a menu at position X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2695 self.tk.call(self._w, 'post', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2696 def type(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2697 """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
2698 return self.tk.call(self._w, 'type', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2699 def unpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2700 """Unmap a menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2701 self.tk.call(self._w, 'unpost')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2702 def yposition(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2703 """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
2704 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2705 self._w, 'yposition', index))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2706
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2707 class Menubutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2708 """Menubutton widget, obsolete since Tk8.0."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2709 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2710 Widget.__init__(self, master, 'menubutton', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2711
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2712 class Message(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2713 """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
2714 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2715 Widget.__init__(self, master, 'message', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2716
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2717 class Radiobutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2718 """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
2719 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2720 """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
2721
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2722 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2723 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2724 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2725 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2726 indicatoron, justify, padx, pady, relief, selectcolor, selectimage,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2727 state, takefocus, text, textvariable, underline, value, variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2728 width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2729 Widget.__init__(self, master, 'radiobutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2730 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2731 """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
2732
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2733 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2734 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2735 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2736 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2737 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2738 """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
2739 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2740 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2741 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2742 self.tk.call(self._w, 'select')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2743
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2744 class Scale(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2745 """Scale widget which can display a numerical scale."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2746 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2747 """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
2748
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2749 Valid resource names: activebackground, background, bigincrement, bd,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2750 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
2751 highlightbackground, highlightcolor, highlightthickness, label,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2752 length, orient, relief, repeatdelay, repeatinterval, resolution,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2753 showvalue, sliderlength, sliderrelief, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2754 tickinterval, to, troughcolor, variable, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2755 Widget.__init__(self, master, 'scale', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2756 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2757 """Get the current value as integer or float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2758 value = self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2759 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2760 return getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2761 except ValueError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2762 return getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2763 def set(self, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2764 """Set the value to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2765 self.tk.call(self._w, 'set', value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2766 def coords(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2767 """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
2768 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
2769 given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2770
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2771 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
2772 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2773 """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
2774 "though1" and "though2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2775 return self.tk.call(self._w, 'identify', x, y)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2776
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2777 class Scrollbar(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2778 """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
2779 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2780 """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
2781
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2782 Valid resource names: activebackground, activerelief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2783 background, bd, bg, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2784 elementborderwidth, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2785 highlightcolor, highlightthickness, jump, orient,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2786 relief, repeatdelay, repeatinterval, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2787 troughcolor, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2788 Widget.__init__(self, master, 'scrollbar', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2789 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2790 """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
2791 INDEX can be "arrow1","slider" or "arrow2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2792 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2793 def delta(self, deltax, deltay):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2794 """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
2795 would be moved by DELTAX or DELTAY pixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2796 return getdouble(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2797 self.tk.call(self._w, 'delta', deltax, deltay))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2798 def fraction(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2799 """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
2800 position of X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2801 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
2802 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2803 """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
2804 "arrow1","slider","arrow2" or ""."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2805 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
2806 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2807 """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
2808 of the slider position."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2809 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
2810 def set(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2811 """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
2812 lower ends as value between 0 and 1)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2813 self.tk.call((self._w, 'set') + args)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2814
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2815
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2816
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2817 class Text(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2818 """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
2819 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2820 """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
2821
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2822 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2823
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2824 background, borderwidth, cursor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2825 exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2826 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2827 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2828 insertborderwidth, insertofftime,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2829 insertontime, insertwidth, padx, pady,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2830 relief, selectbackground,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2831 selectborderwidth, selectforeground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2832 setgrid, takefocus,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2833 xscrollcommand, yscrollcommand,
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2834
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2835 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2836
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2837 autoseparators, height, maxundo,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2838 spacing1, spacing2, spacing3,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2839 state, tabs, undo, width, wrap,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2840
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2841 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2842 Widget.__init__(self, master, 'text', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2843 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2844 """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
2845 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
2846 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2847 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
2848 def tk_textSelectTo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2849 self.tk.call('tk_textSelectTo', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2850 def tk_textBackspace(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2851 self.tk.call('tk_textBackspace', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2852 def tk_textIndexCloser(self, a, b, c):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2853 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
2854 def tk_textResetAnchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2855 self.tk.call('tk_textResetAnchor', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2856 def compare(self, index1, op, index2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2857 """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
2858 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
2859 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2860 self._w, 'compare', index1, op, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2861 def debug(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2862 """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
2863 widget according to BOOLEAN."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2864 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2865 self._w, 'debug', boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2866 def delete(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2867 """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
2868 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2869 def dlineinfo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2870 """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
2871 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
2872 the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2873 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
2874 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
2875 """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
2876
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2877 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
2878 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
2879 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
2880 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
2881 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
2882
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2883 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
2884 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
2885 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
2886 args = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2887 func_name = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2888 result = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2889 if not command:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2890 # 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
2891 # 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
2892 # 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
2893 # 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
2894 result = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2895 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
2896 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
2897 command = append_triple
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2898 try:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2899 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
2900 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
2901 args += ["-command", command]
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2902 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
2903 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
2904 args.append(index1)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2905 if index2:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2906 args.append(index2)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2907 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
2908 return result
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2909 finally:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2910 if func_name:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2911 self.deletecommand(func_name)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2912
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2913 ## new in tk8.4
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2914 def edit(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2915 """Internal method
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2916
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2917 This method controls the undo mechanism and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2918 the modified flag. The exact behavior of the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2919 command depends on the option argument that
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2920 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
2921 of the command are currently supported:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2922
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2923 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
2924 and edit_undo
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2925
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2926 """
47124
ac93edc396a6 #961805: fix Edit.text_modified().
Georg Brandl <georg@python.org>
parents: 47099
diff changeset
2927 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
2928
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2929 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
2930 """Get or Set the modified flag
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2931
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2932 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
2933 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
2934 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
2935 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
2936 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
2937 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2938 return self.edit("modified", arg)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2939
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2940 def edit_redo(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2941 """Redo the last undone edit
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2942
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2943 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
2944 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
2945 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
2946 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
2947 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2948 return self.edit("redo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2949
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2950 def edit_reset(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2951 """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
2952 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2953 return self.edit("reset")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2954
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2955 def edit_separator(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2956 """Inserts a separator (boundary) on the undo stack.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2957
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2958 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
2959 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2960 return self.edit("separator")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2961
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2962 def edit_undo(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2963 """Undoes the last edit action
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2964
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2965 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
2966 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
2967 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
2968 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
2969 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
2970 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2971 return self.edit("undo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2972
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2973 def get(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2974 """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
2975 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
2976 # (Image commands are new in 8.0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2977 def image_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2978 """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
2979 if option[:1] != "-":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2980 option = "-" + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2981 if option[-1:] == "_":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2982 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2983 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
2984 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
2985 """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
2986 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
2987 def image_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2988 """Create an embedded image at INDEX."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2989 return self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2990 self._w, "image", "create", index,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2991 *self._options(cnf, kw))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2992 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2993 """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
2994 return self.tk.call(self._w, "image", "names")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2995 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2996 """Return the index in the form line.char for INDEX."""
44416
d9a4a5f0121e Always convert Text.index result to string.
Martin v. Löwis <martin@v.loewis.de>
parents: 40315
diff changeset
2997 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
2998 def insert(self, index, chars, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2999 """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
3000 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
3001 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
3002 def mark_gravity(self, markName, direction=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3003 """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
3004 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
3005 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3006 (self._w, 'mark', 'gravity', markName, direction))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3007 def mark_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3008 """Return all mark names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3009 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3010 self._w, 'mark', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3011 def mark_set(self, markName, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3012 """Set mark MARKNAME before the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3013 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
3014 def mark_unset(self, *markNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3015 """Delete all marks in MARKNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3016 self.tk.call((self._w, 'mark', 'unset') + markNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3017 def mark_next(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3018 """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
3019 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
3020 def mark_previous(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3021 """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
3022 return self.tk.call(self._w, 'mark', 'previous', index) or None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3023 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3024 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3025 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
3026 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3027 """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
3028 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
3029 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3030 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
3031 def search(self, pattern, index, stopindex=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3032 forwards=None, backwards=None, exact=None,
40315
07b29bcfc013 Patch #1592250: Add elidge argument to Tkinter.Text.search.
Martin v. Löwis <martin@v.loewis.de>
parents: 39116
diff changeset
3033 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
3034 """Search PATTERN beginning from INDEX until STOPINDEX.
51482
e45525195317 Merged revisions 69461 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 49631
diff changeset
3035 Return the index of the first character of a match or an
e45525195317 Merged revisions 69461 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 49631
diff changeset
3036 empty string."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3037 args = [self._w, 'search']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3038 if forwards: args.append('-forwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3039 if backwards: args.append('-backwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3040 if exact: args.append('-exact')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3041 if regexp: args.append('-regexp')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3042 if nocase: args.append('-nocase')
40315
07b29bcfc013 Patch #1592250: Add elidge argument to Tkinter.Text.search.
Martin v. Löwis <martin@v.loewis.de>
parents: 39116
diff changeset
3043 if elide: args.append('-elide')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3044 if count: args.append('-count'); args.append(count)
51482
e45525195317 Merged revisions 69461 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 49631
diff changeset
3045 if pattern and pattern[0] == '-': args.append('--')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3046 args.append(pattern)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3047 args.append(index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3048 if stopindex: args.append(stopindex)
52054
433e116c335d Fixed issue #5193: Guarantee that Tkinter.Text.search returns a string.
Guilherme Polo <ggpolo@gmail.com>
parents: 51775
diff changeset
3049 return str(self.tk.call(tuple(args)))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3050 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3051 """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
3052 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3053 def tag_add(self, tagName, index1, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3054 """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
3055 Additional pairs of indices may follow in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3056 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3057 (self._w, 'tag', 'add', tagName, index1) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3058 def tag_unbind(self, tagName, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3059 """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
3060 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3061 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
3062 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3063 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3064 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
3065 """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
3066
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3067 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
3068 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
3069 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
3070 return self._bind((self._w, 'tag', 'bind', tagName),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3071 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3072 def tag_cget(self, tagName, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3073 """Return the value of OPTION for tag TAGNAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3074 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3075 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3076 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3077 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3078 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
3079 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
3080 """Configure a tag TAGNAME."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3081 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
3082 tag_config = tag_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3083 def tag_delete(self, *tagNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3084 """Delete all tags in TAGNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3085 self.tk.call((self._w, 'tag', 'delete') + tagNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3086 def tag_lower(self, tagName, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3087 """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
3088 than the priority of BELOWTHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3089 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
3090 def tag_names(self, index=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3091 """Return a list of all tag names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3092 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3093 self.tk.call(self._w, 'tag', 'names', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3094 def tag_nextrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3095 """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
3096 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
3097 The text is searched forward from INDEX1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3098 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3099 self._w, 'tag', 'nextrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3100 def tag_prevrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3101 """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
3102 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
3103 The text is searched backwards from INDEX1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3104 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3105 self._w, 'tag', 'prevrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3106 def tag_raise(self, tagName, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3107 """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
3108 than the priority of ABOVETHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3109 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3110 self._w, 'tag', 'raise', tagName, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3111 def tag_ranges(self, tagName):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3112 """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
3113 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3114 self._w, 'tag', 'ranges', tagName))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3115 def tag_remove(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3116 """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
3117 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3118 self._w, 'tag', 'remove', tagName, index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3119 def window_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3120 """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
3121 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3122 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3123 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3124 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3125 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
3126 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
3127 """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
3128 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
3129 window_config = window_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3130 def window_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3131 """Create a window at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3132 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3133 (self._w, 'window', 'create', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3134 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3135 def window_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3136 """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
3137 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3138 self.tk.call(self._w, 'window', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3139 def xview(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3140 """Query and change horizontal position of the view."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3141 if not what:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3142 return self._getdoubles(self.tk.call(self._w, 'xview'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3143 self.tk.call((self._w, 'xview') + what)
13904
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3144 def xview_moveto(self, fraction):
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3145 """Adjusts the view in the window so that FRACTION of the
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3146 total width of the canvas is off-screen to the left."""
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3147 self.tk.call(self._w, 'xview', 'moveto', fraction)
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3148 def xview_scroll(self, number, what):
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3149 """Shift the x-view according to NUMBER which is measured
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3150 in "units" or "pages" (WHAT)."""
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3151 self.tk.call(self._w, 'xview', 'scroll', number, what)
13905
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3152 def yview(self, *what):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3153 """Query and change vertical position of the view."""
13905
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3154 if not what:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3155 return self._getdoubles(self.tk.call(self._w, 'yview'))
13905
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3156 self.tk.call((self._w, 'yview') + what)
13904
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3157 def yview_moveto(self, fraction):
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3158 """Adjusts the view in the window so that FRACTION of the
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3159 total height of the canvas is off-screen to the top."""
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3160 self.tk.call(self._w, 'yview', 'moveto', fraction)
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3161 def yview_scroll(self, number, what):
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3162 """Shift the y-view according to NUMBER which is measured
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3163 in "units" or "pages" (WHAT)."""
99e19c982f94 -- added xview_moveto, xview_scroll, yview_moveto, yview_scroll
Fredrik Lundh <fredrik@pythonware.com>
parents: 13903
diff changeset
3164 self.tk.call(self._w, 'yview', 'scroll', number, what)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3165 def yview_pickplace(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3166 """Obsolete function, use see."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3167 self.tk.call((self._w, 'yview', '-pickplace') + what)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3168
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3169
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
3170 class _setit:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3171 """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
3172 def __init__(self, var, value, callback=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3173 self.__value = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3174 self.__var = var
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3175 self.__callback = callback
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3176 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3177 self.__var.set(self.__value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3178 if self.__callback:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3179 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
3180
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3181 class OptionMenu(Menubutton):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3182 """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
3183 def __init__(self, master, variable, value, *values, **kwargs):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3184 """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
3185 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
3186 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
3187 keyword argument command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3188 kw = {"borderwidth": 2, "textvariable": variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3189 "indicatoron": 1, "relief": RAISED, "anchor": "c",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3190 "highlightthickness": 2}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3191 Widget.__init__(self, master, "menubutton", kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3192 self.widgetName = 'tk_optionMenu'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3193 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
3194 self.menuname = menu._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3195 # 'command' is the only supported keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3196 callback = kwargs.get('command')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3197 if kwargs.has_key('command'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3198 del kwargs['command']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3199 if kwargs:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3200 raise TclError, 'unknown option -'+kwargs.keys()[0]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3201 menu.add_command(label=value,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3202 command=_setit(variable, value, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3203 for v in values:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3204 menu.add_command(label=v,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3205 command=_setit(variable, v, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3206 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
3207
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3208 def __getitem__(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3209 if name == 'menu':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3210 return self.__menu
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3211 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
3212
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3213 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3214 """Destroy this widget and the associated menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3215 Menubutton.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3216 self.__menu = None
3067
6ec820db2ffa added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents: 2968
diff changeset
3217
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3218 class Image:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3219 """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
3220 _last_id = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3221 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
3222 self.name = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3223 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3224 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3225 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3226 raise RuntimeError, 'Too early to create image'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3227 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3228 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
3229 Image._last_id += 1
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
3230 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
3231 # 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
3232 # 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
3233 if name[0] == '-': name = '_' + name[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3234 if kw and cnf: cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3235 elif kw: cnf = kw
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3236 options = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3237 for k, v in cnf.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3238 if callable(v):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3239 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3240 options = options + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3241 self.tk.call(('image', 'create', imgtype, name,) + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3242 self.name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3243 def __str__(self): return self.name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3244 def __del__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3245 if self.name:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3246 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3247 self.tk.call('image', 'delete', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3248 except TclError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3249 # May happen if the root was destroyed
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3250 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3251 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3252 self.tk.call(self.name, 'configure', '-'+key, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3253 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3254 return self.tk.call(self.name, 'configure', '-'+key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3255 def configure(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3256 """Configure the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3257 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3258 for k, v in _cnfmerge(kw).items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3259 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3260 if k[-1] == '_': k = k[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3261 if callable(v):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3262 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3263 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3264 self.tk.call((self.name, 'config') + res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3265 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3266 def height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3267 """Return the height of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3268 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3269 self.tk.call('image', 'height', self.name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3270 def type(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3271 """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
3272 return self.tk.call('image', 'type', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3273 def width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3274 """Return the width of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3275 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3276 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
3277
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3278 class PhotoImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3279 """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
3280 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
3281 """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
3282
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3283 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
3284 width."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3285 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
3286 def blank(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3287 """Display a transparent image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3288 self.tk.call(self.name, 'blank')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3289 def cget(self, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3290 """Return the value of OPTION."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3291 return self.tk.call(self.name, 'cget', '-' + option)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3292 # XXX config
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3293 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3294 return self.tk.call(self.name, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3295 # XXX copy -from, -to, ...?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3296 def copy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3297 """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
3298 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3299 self.tk.call(destImage, 'copy', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3300 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3301 def zoom(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3302 """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
3303 but zoom it with X and Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3304 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3305 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3306 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
3307 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3308 def subsample(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3309 """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
3310 but use only every Xth or Yth pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3311 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3312 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3313 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
3314 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3315 def get(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3316 """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
3317 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
3318 def put(self, data, to=None):
51775
af9b6c43804e Issue #5341: Fix a variety of spelling errors.
Mark Dickinson <dickinsm@gmail.com>
parents: 51482
diff changeset
3319 """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
3320 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
3321 args = (self.name, 'put', data)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3322 if to:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3323 if to[0] == '-to':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3324 to = to[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3325 args = args + ('-to',) + tuple(to)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3326 self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3327 # XXX read
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3328 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
3329 """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
3330 position FROM_COORDS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3331 args = (self.name, 'write', filename)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3332 if format:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3333 args = args + ('-format', format)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3334 if from_coords:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3335 args = args + ('-from',) + tuple(from_coords)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3336 self.tk.call(args)
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3337
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3338 class BitmapImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3339 """Widget which can display a bitmap."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3340 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
3341 """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
3342
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3343 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
3344 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
3345
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3346 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
3347 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
3348
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3349
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3350 class Spinbox(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3351 """spinbox widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3352 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
3353 """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
3354
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3355 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3356
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3357 activebackground, background, borderwidth,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3358 cursor, exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3359 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3360 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3361 insertborderwidth, insertofftime,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3362 insertontime, insertwidth, justify, relief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3363 repeatdelay, repeatinterval,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3364 selectbackground, selectborderwidth
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3365 selectforeground, takefocus, textvariable
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3366 xscrollcommand.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3367
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3368 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3369
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3370 buttonbackground, buttoncursor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3371 buttondownrelief, buttonuprelief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3372 command, disabledbackground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3373 disabledforeground, format, from,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3374 invalidcommand, increment,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3375 readonlybackground, state, to,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3376 validate, validatecommand values,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3377 width, wrap,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3378 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3379 Widget.__init__(self, master, 'spinbox', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3380
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3381 def bbox(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3382 """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
3383 rectangle which encloses the character given by index.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3384
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3385 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
3386 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
3387 area covered by the character (in pixels relative
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3388 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
3389 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
3390 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
3391 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
3392 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3393 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
3394
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3395 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
3396 """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
3397
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3398 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
3399 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
3400 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
3401 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
3402 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
3403 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3404 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
3405
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3406 def get(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3407 """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
3408 return self.tk.call(self._w, 'get')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3409
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3410 def icursor(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3411 """Alter the position of the insertion cursor.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3412
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3413 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
3414 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
3415 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3416 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
3417
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3418 def identify(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3419 """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
3420
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3421 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
3422 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3423 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
3424
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3425 def index(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3426 """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
3427 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3428 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
3429
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3430 def insert(self, index, s):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3431 """Insert string s at index
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3432
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3433 Returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3434 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3435 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
3436
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3437 def invoke(self, element):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3438 """Causes the specified element to be invoked
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3439
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3440 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
3441 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
3442 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3443 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
3444
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3445 def scan(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3446 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3447 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3448 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
3449
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3450 def scan_mark(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3451 """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
3452
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3453 used in conjunction with later scan dragto commands.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3454 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
3455 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
3456 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3457 return self.scan("mark", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3458
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3459 def scan_dragto(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3460 """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
3461 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
3462
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3463 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
3464 difference in x-coordinates. This command is typically
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3465 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
3466 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
3467 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
3468 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3469 return self.scan("dragto", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3470
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3471 def selection(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3472 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3473 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3474 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
3475
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3476 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
3477 """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
3478 given by index,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3479
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3480 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
3481 (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
3482 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
3483 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
3484 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
3485 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
3486 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
3487 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3488 return self.selection("adjust", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3489
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3490 def selection_clear(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3491 """Clear the selection
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3492
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3493 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
3494 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
3495 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3496 return self.selection("clear")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3497
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3498 def selection_element(self, element=None):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3499 """Sets or gets the currently selected element.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3500
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3501 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
3502 displayed depressed
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.selection("element", element)
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3505
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3506 ###########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3507
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3508 class LabelFrame(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3509 """labelframe widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3510 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
3511 """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
3512
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3513 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3514
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3515 borderwidth, cursor, font, foreground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3516 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3517 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
3518 takefocus, text
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3519
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3520 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3521
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3522 background, class, colormap, container,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3523 height, labelanchor, labelwidget,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3524 visual, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3525 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3526 Widget.__init__(self, master, 'labelframe', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3527
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3528 ########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3529
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3530 class PanedWindow(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3531 """panedwindow widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3532 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
3533 """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
3534
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3535 STANDARD OPTIONS
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 background, borderwidth, cursor, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3538 orient, relief, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3539
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3540 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3541
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3542 handlepad, handlesize, opaqueresize,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3543 sashcursor, sashpad, sashrelief,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3544 sashwidth, showhandle,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3545 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3546 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
3547
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3548 def add(self, child, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3549 """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
3550
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3551 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
3552 followed by pairs of arguments that specify how to
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3553 manage the windows. Options may have any of the values
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3554 accepted by the configure subcommand.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3555 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3556 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
3557
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3558 def remove(self, child):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3559 """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
3560
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3561 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
3562 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3563 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
3564 forget=remove
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3565
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3566 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
3567 """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
3568
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3569 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
3570 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
3571 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
3572 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
3573 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
3574 an empty list.
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 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
3577
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3578 def proxy(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3579 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3580 return self._getints(
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3581 self.tk.call((self._w, 'proxy') + args)) or ()
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3582
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3583 def proxy_coord(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3584 """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
3585 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3586 return self.proxy("coord")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3587
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3588 def proxy_forget(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3589 """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
3590 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3591 return self.proxy("forget")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3592
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3593 def proxy_place(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3594 """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
3595 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3596 return self.proxy("place", x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3597
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3598 def sash(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3599 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3600 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3601 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
3602
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3603 def sash_coord(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3604 """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
3605
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3606 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
3607 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
3608 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
3609 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
3610 difference between the given coordinates and the coordinates
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3611 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
3612 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
3613 empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3614 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3615 return self.sash("coord", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3616
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3617 def sash_mark(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3618 """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
3619
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3620 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
3621 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3622 return self.sash("mark", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3623
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3624 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
3625 """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
3626 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3627 return self.sash("place", index, x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3628
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3629 def panecget(self, child, option):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3630 """Query a management option for window.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3631
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3632 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
3633 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3634 return self.tk.call(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3635 (self._w, 'panecget') + (child, '-'+option))
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3636
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3637 def paneconfigure(self, tagOrId, cnf=None, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3638 """Query or modify the management options for window.
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 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
3641 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
3642 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
3643 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
3644 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
3645 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
3646 specified, then the command modifies the given widget
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3647 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
3648 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
3649 are supported:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3650
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3651 after window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3652 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
3653 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
3654 before window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3655 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
3656 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
3657 height size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3658 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
3659 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
3660 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
3661 specified, then the height requested internally by the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3662 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
3663 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
3664 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
3665 minsize n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3666 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
3667 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
3668 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
3669 for horizontal panedwindows, the y dimension for
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3670 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
3671 Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3672 padx n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3673 Specifies a non-negative value indicating how much
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3674 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
3675 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
3676 accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3677 pady n
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3678 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
3679 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
3680 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
3681 accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3682 sticky style
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3683 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
3684 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
3685 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
3686 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
3687 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
3688 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
3689 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
3690 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
3691 (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
3692 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
3693 its cavity.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3694 width size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3695 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
3696 the outer dimension of the window including its
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3697 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
3698 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
3699 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
3700 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
3701 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
3702 Tk_GetPixels.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3703
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3704 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3705 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
3706 cnf = {}
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3707 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
3708 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
3709 'paneconfigure', tagOrId)):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3710 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
3711 return cnf
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3712 if type(cnf) == StringType and not kw:
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3713 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
3714 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
3715 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
3716 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
3717 self._options(cnf, kw))
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3718 paneconfig = paneconfigure
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3719
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3720 def panes(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3721 """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
3722 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
3723
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
3724 ######################################################################
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3725 # 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
3726
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3727 class Studbutton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3728 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3729 Widget.__init__(self, master, 'studbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3730 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3731 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3732 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3733 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
3734
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3735 class Tributton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3736 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3737 Widget.__init__(self, master, 'tributton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3738 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3739 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3740 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3741 self.bind('<ButtonRelease-1>', self.tkButtonUp)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3742 self['fg'] = self['bg']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3743 self['activebackground'] = self['bg']
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
3744
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3745 ######################################################################
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3746 # Test:
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3747
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3748 def _test():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3749 root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3750 text = "This is Tcl/Tk version %s" % TclVersion
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3751 if TclVersion >= 8.1:
13905
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3752 try:
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3753 text = text + unicode("\nThis should be a cedilla: \347",
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3754 "iso-8859-1")
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3755 except NameError:
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3756 pass # no unicode support
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3757 label = Label(root, text=text)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3758 label.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3759 test = Button(root, text="Click me!",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3760 command=lambda root=root: root.test.configure(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3761 text="[%s]" % root.test['text']))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3762 test.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3763 root.test = test
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3764 quit = Button(root, text="QUIT", command=root.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3765 quit.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3766 # 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
3767 # up on top on Windows...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3768 root.iconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3769 root.update()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3770 root.deiconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3771 root.mainloop()
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3772
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3773 if __name__ == '__main__':
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3774 _test()