annotate Lib/lib-tk/Tkinter.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents f70fa654f70e
children 822b472eff13
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):
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
21 import Tkinter
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
22 from Tkconstants import *
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
23 tk = Tkinter.Tk()
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
24 frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
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)
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
26 label = Tkinter.Label(frame, text="Hello, World")
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)
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
28 button = Tkinter.Button(frame,text="Exit",command=tk.destroy)
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
71539
f15442543e24 Fix closes Issue11439 - Handle the SVN Keywords in 2.7 by replacing them with a high number so that code relying on them does not break.
Senthil Kumaran <senthil@uthcode.com>
parents: 68503
diff changeset
33 __version__ = "$Revision: 81008 $"
3551
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
5123
05fffd55b014 Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents: 5096
diff changeset
40 tkinter = _tkinter # b/w compat for export
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 *
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
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
76974
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
537 or FILE_NAME. Type defaults to STRING, except on X11, where the default
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
538 is to try UTF8_STRING and fall back to STRING.
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
539
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
540 This command is equivalent to:
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
541
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
542 selection_get(CLIPBOARD)
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
543 """
76974
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
544 if 'type' not in kw and self._windowingsystem == 'x11':
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
545 try:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
546 kw['type'] = 'UTF8_STRING'
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
547 return self.tk.call(('clipboard', 'get') + self._options(kw))
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
548 except TclError:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
549 del kw['type']
37774
5bb6e54f9408 Patch #1063914: Add clipboard_get.
Martin v. Löwis <martin@v.loewis.de>
parents: 37402
diff changeset
550 return self.tk.call(('clipboard', 'get') + self._options(kw))
37778
be238cb26d32 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 37774
diff changeset
551
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
552 def clipboard_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
553 """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
554
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
555 A widget specified for 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."""
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
557 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
558 self.tk.call(('clipboard', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
559 def clipboard_append(self, string, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
560 """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
561
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
562 A widget specified at the optional displayof keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
563 argument specifies the target display. The clipboard
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
564 can be retrieved with selection_get."""
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
565 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
566 self.tk.call(('clipboard', 'append') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
567 + ('--', string))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
568 # XXX grab current w/o window argument
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
569 def grab_current(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
570 """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
571 or None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
572 name = self.tk.call('grab', 'current', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
573 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
574 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
575 def grab_release(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
576 """Release grab for this widget if currently set."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
577 self.tk.call('grab', 'release', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
578 def grab_set(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
579 """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
580
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
581 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
582 widgets in the application."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
583 self.tk.call('grab', 'set', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
584 def grab_set_global(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
585 """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
586
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
587 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
588 descendant widgets on the display. Use with caution -
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
589 other applications do not get events anymore."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
590 self.tk.call('grab', 'set', '-global', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
591 def grab_status(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
592 """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
593 no, a local or a global grab."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
594 status = self.tk.call('grab', 'status', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
595 if status == 'none': status = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
596 return status
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
597 def option_add(self, pattern, value, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
598 """Set a VALUE (second parameter) for an option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
599 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
600
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
601 An optional third parameter gives the numeric priority
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
602 (defaults to 80)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
603 self.tk.call('option', 'add', pattern, value, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
604 def option_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
605 """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
606
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
607 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
608 self.tk.call('option', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
609 def option_get(self, name, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
610 """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
611 with CLASSNAME.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
612
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
613 Values with higher priority override lower values."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
614 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
615 def option_readfile(self, fileName, priority = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
616 """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
617
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
618 An optional second parameter gives the numeric
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
619 priority."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
620 self.tk.call('option', 'readfile', fileName, priority)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
621 def selection_clear(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
622 """Clear the current X selection."""
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
623 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
624 self.tk.call(('selection', 'clear') + self._options(kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
625 def selection_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
626 """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
627
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
628 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
629 the selection and defaults to PRIMARY. A keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
630 parameter displayof specifies a widget on the display
76974
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
631 to use. A keyword parameter type specifies the form of data to be
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
632 fetched, defaulting to STRING except on X11, where UTF8_STRING is tried
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
633 before STRING."""
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
634 if 'displayof' not in kw: kw['displayof'] = self._w
76974
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
635 if 'type' not in kw and self._windowingsystem == 'x11':
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
636 try:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
637 kw['type'] = 'UTF8_STRING'
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
638 return self.tk.call(('selection', 'get') + self._options(kw))
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
639 except TclError:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
640 del kw['type']
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
641 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
642 def selection_handle(self, command, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
643 """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
644 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
645 application.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
646
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
647 This function must return the contents of the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
648 selection. The function will be called with the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
649 arguments OFFSET and LENGTH which allows the chunking
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
650 of very long selections. The following keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
651 parameters can be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
652 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
653 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
654 name = self._register(command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
655 self.tk.call(('selection', 'handle') + self._options(kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
656 + (self._w, name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
657 def selection_own(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
658 """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
659
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
660 A keyword parameter selection specifies the name of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
661 the selection (default PRIMARY)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
662 self.tk.call(('selection', 'own') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
663 self._options(kw) + (self._w,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
664 def selection_own_get(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
665 """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
666
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
667 The following keyword parameter can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
668 be provided:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
669 selection - name of the selection (default PRIMARY),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
670 type - type of the selection (e.g. STRING, FILE_NAME)."""
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
671 if 'displayof' not in kw: kw['displayof'] = self._w
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
672 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
673 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
674 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
675 def send(self, interp, cmd, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
676 """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
677 return self.tk.call(('send', interp, cmd) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
678 def lower(self, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
679 """Lower this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
680 self.tk.call('lower', self._w, belowThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
681 def tkraise(self, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
682 """Raise this widget in the stacking order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
683 self.tk.call('raise', self._w, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
684 lift = tkraise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
685 def colormodel(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
686 """Useless. Not implemented in Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
687 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
688 def winfo_atom(self, name, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
689 """Return integer which represents atom NAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
690 args = ('winfo', 'atom') + self._displayof(displayof) + (name,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
691 return getint(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
692 def winfo_atomname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
693 """Return name of atom with identifier ID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
694 args = ('winfo', 'atomname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
695 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
696 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
697 def winfo_cells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
698 """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
699 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
700 self.tk.call('winfo', 'cells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
701 def winfo_children(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
702 """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
703 result = []
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
704 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
705 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
706 try:
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
707 # 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
708 # 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
709 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
710 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
711 pass
83776ba580ef Ignore widgets with unknown names in winfo_children. Fixes #518283.
Martin v. Löwis <martin@v.loewis.de>
parents: 20414
diff changeset
712 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
713
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
714 def winfo_class(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
715 """Return window class name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
716 return self.tk.call('winfo', 'class', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
717 def winfo_colormapfull(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
718 """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
719 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
720 self.tk.call('winfo', 'colormapfull', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
721 def winfo_containing(self, rootX, rootY, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
722 """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
723 args = ('winfo', 'containing') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
724 + self._displayof(displayof) + (rootX, rootY)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
725 name = self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
726 if not name: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
727 return self._nametowidget(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
728 def winfo_depth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
729 """Return the number of bits per pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
730 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
731 def winfo_exists(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
732 """Return true if this widget exists."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
733 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
734 self.tk.call('winfo', 'exists', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
735 def winfo_fpixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
736 """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
737 (e.g. "3c") as float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
738 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
739 'winfo', 'fpixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
740 def winfo_geometry(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
741 """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
742 return self.tk.call('winfo', 'geometry', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
743 def winfo_height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
744 """Return height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
745 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
746 self.tk.call('winfo', 'height', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
747 def winfo_id(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
748 """Return identifier ID for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
749 return self.tk.getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
750 self.tk.call('winfo', 'id', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
751 def winfo_interps(self, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
752 """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
753 args = ('winfo', 'interps') + self._displayof(displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
754 return self.tk.splitlist(self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
755 def winfo_ismapped(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
756 """Return true if this widget is mapped."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
757 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
758 self.tk.call('winfo', 'ismapped', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
759 def winfo_manager(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
760 """Return the window mananger name for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
761 return self.tk.call('winfo', 'manager', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
762 def winfo_name(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
763 """Return the name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
764 return self.tk.call('winfo', 'name', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
765 def winfo_parent(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
766 """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
767 return self.tk.call('winfo', 'parent', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
768 def winfo_pathname(self, id, displayof=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
769 """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
770 args = ('winfo', 'pathname') \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
771 + self._displayof(displayof) + (id,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
772 return self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
773 def winfo_pixels(self, number):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
774 """Rounded integer value of winfo_fpixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
775 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
776 self.tk.call('winfo', 'pixels', self._w, number))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
777 def winfo_pointerx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
778 """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
779 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
780 self.tk.call('winfo', 'pointerx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
781 def winfo_pointerxy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
782 """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
783 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
784 self.tk.call('winfo', 'pointerxy', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
785 def winfo_pointery(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
786 """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
787 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
788 self.tk.call('winfo', 'pointery', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
789 def winfo_reqheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
790 """Return requested height of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
791 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
792 self.tk.call('winfo', 'reqheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
793 def winfo_reqwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
794 """Return requested width of this widget."""
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', 'reqwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
797 def winfo_rgb(self, color):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
798 """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
799 COLOR in this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
800 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
801 self.tk.call('winfo', 'rgb', self._w, color))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
802 def winfo_rootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
803 """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
804 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
805 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
806 self.tk.call('winfo', 'rootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
807 def winfo_rooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
808 """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
809 root window."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
810 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
811 self.tk.call('winfo', 'rooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
812 def winfo_screen(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
813 """Return the screen name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
814 return self.tk.call('winfo', 'screen', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
815 def winfo_screencells(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
816 """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
817 of this widget."""
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', 'screencells', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
820 def winfo_screendepth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
821 """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
822 screen of this widget."""
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', 'screendepth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
825 def winfo_screenheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
826 """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
827 in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
828 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
829 self.tk.call('winfo', 'screenheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
830 def winfo_screenmmheight(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 height of the screen of
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
832 this widget in mm."""
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', 'screenmmheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
835 def winfo_screenmmwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
836 """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
837 this widget in mm."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
838 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
839 self.tk.call('winfo', 'screenmmwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
840 def winfo_screenvisual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
841 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
842 staticcolor, staticgray, or truecolor for the default
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
843 colormodel of this screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
844 return self.tk.call('winfo', 'screenvisual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
845 def winfo_screenwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
846 """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
847 this widget in pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
848 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
849 self.tk.call('winfo', 'screenwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
850 def winfo_server(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
851 """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
852 the form "XmajorRminor vendor vendorVersion"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
853 return self.tk.call('winfo', 'server', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
854 def winfo_toplevel(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
855 """Return the toplevel widget of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
856 return self._nametowidget(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
857 'winfo', 'toplevel', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
858 def winfo_viewable(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
859 """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
860 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
861 self.tk.call('winfo', 'viewable', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
862 def winfo_visual(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
863 """Return one of the strings directcolor, grayscale, pseudocolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
864 staticcolor, staticgray, or truecolor for the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
865 colormodel of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
866 return self.tk.call('winfo', 'visual', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
867 def winfo_visualid(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
868 """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
869 return self.tk.call('winfo', 'visualid', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
870 def winfo_visualsavailable(self, includeids=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
871 """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
872 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
873
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
874 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
875 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
876 data = self.tk.split(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
877 self.tk.call('winfo', 'visualsavailable', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
878 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
879 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
880 data = [self.tk.split(data)]
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
881 return map(self.__winfo_parseitem, data)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
882 def __winfo_parseitem(self, t):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
883 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
884 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
885 def __winfo_getint(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
886 """Internal function."""
16517
eee67a84e5fa String method conversion.
Eric S. Raymond <esr@thyrsus.com>
parents: 15540
diff changeset
887 return int(x, 0)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
888 def winfo_vrootheight(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
889 """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
890 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
891 height of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
892 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
893 self.tk.call('winfo', 'vrootheight', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
894 def winfo_vrootwidth(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
895 """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
896 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
897 width of the screen."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
898 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
899 self.tk.call('winfo', 'vrootwidth', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
900 def winfo_vrootx(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
901 """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
902 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
903 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
904 self.tk.call('winfo', 'vrootx', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
905 def winfo_vrooty(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
906 """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
907 window of the screen of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
908 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
909 self.tk.call('winfo', 'vrooty', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
910 def winfo_width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
911 """Return the width of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
912 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
913 self.tk.call('winfo', 'width', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
914 def winfo_x(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
915 """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
916 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
917 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
918 self.tk.call('winfo', 'x', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
919 def winfo_y(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
920 """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
921 in the parent."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
922 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
923 self.tk.call('winfo', 'y', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
924 def update(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
925 """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
926 self.tk.call('update')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
927 def update_idletasks(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
928 """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
929 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
930 the user."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
931 self.tk.call('update', 'idletasks')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
932 def bindtags(self, tagList=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
933 """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
934
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
935 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
936 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
937 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
938 processed (see bind)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
939 if tagList is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
940 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
941 self.tk.call('bindtags', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
942 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
943 self.tk.call('bindtags', self._w, tagList)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
944 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
945 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
946 if type(func) is StringType:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
947 self.tk.call(what + (sequence, func))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
948 elif func:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
949 funcid = self._register(func, self._substitute,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
950 needcleanup)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
951 cmd = ('%sif {"[%s %s]" == "break"} break\n'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
952 %
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
953 (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
954 funcid, self._subst_format_str))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
955 self.tk.call(what + (sequence, cmd))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
956 return funcid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
957 elif sequence:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
958 return self.tk.call(what + (sequence,))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
959 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
960 return self.tk.splitlist(self.tk.call(what))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
961 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
962 """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
963
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
964 SEQUENCE is a string of concatenated event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
965 patterns. An event pattern is of the form
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
966 <MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
967 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
968 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
969 B3, Alt, Button4, B4, Double, Button5, B5 Triple,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
970 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
971 ButtonPress, Button, Expose, Motion, ButtonRelease
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
972 FocusIn, MouseWheel, Circulate, FocusOut, Property,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
973 Colormap, Gravity Reparent, Configure, KeyPress, Key,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
974 Unmap, Deactivate, KeyRelease Visibility, Destroy,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
975 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
976 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
977 KeyRelease. Examples are
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
978 <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
979 <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
980 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
981 <<AString>> where AString can be arbitrary. This
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
982 event can be generated by event_generate.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
983 If events are concatenated they must appear shortly
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
984 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
985
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
986 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
987 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
988 "break" no further bound function is invoked.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
989
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
990 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
991 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
992 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
993
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
994 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
995 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
996
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
997 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
998 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
999
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1000 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
1001 def unbind(self, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1002 """Unbind for this widget for event SEQUENCE the
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1003 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1004 self.tk.call('bind', self._w, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1005 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1006 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1007 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
1008 """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
1009 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
1010 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
1011 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
1012 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
1013 def unbind_all(self, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1014 """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
1015 self.tk.call('bind', 'all' , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1016 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
1017
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1018 """Bind to widgets with bindtag CLASSNAME at event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1019 SEQUENCE a call of function FUNC. An additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1020 boolean parameter ADD specifies whether FUNC will be
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1021 called additionally to the other bound function or
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1022 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
1023 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
1024
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1025 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
1026 def unbind_class(self, className, sequence):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1027 """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
1028 all functions."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1029 self.tk.call('bind', className , sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1030 def mainloop(self, n=0):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1031 """Call the mainloop of Tk."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1032 self.tk.mainloop(n)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1033 def quit(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1034 """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
1035 self.tk.quit()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1036 def _getints(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1037 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1038 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1039 return tuple(map(getint, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1040 def _getdoubles(self, string):
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 string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1043 return tuple(map(getdouble, self.tk.splitlist(string)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1044 def _getboolean(self, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1045 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1046 if string:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1047 return self.tk.getboolean(string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1048 def _displayof(self, displayof):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1049 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1050 if displayof:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1051 return ('-displayof', displayof)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1052 if displayof is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1053 return ('-displayof', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1054 return ()
76974
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1055 @property
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1056 def _windowingsystem(self):
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1057 """Internal function."""
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1058 try:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1059 return self._root()._windowingsystem_cached
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1060 except AttributeError:
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1061 ws = self._root()._windowingsystem_cached = \
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1062 self.tk.call('tk', 'windowingsystem')
f70fa654f70e Issue #14777: In an X11 windowing environment, tkinter may return
Ned Deily <nad@acm.org>
parents: 71539
diff changeset
1063 return ws
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1064 def _options(self, cnf, kw = None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1065 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1066 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1067 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1068 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1069 cnf = _cnfmerge(cnf)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1070 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1071 for k, v in cnf.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1072 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1073 if k[-1] == '_': k = k[:-1]
56435
57ee0793e462 replace callable()
Benjamin Peterson <benjamin@python.org>
parents: 55641
diff changeset
1074 if hasattr(v, '__call__'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1075 v = self._register(v)
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1076 elif isinstance(v, (tuple, list)):
47456
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1077 nv = []
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1078 for item in v:
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1079 if not isinstance(item, (basestring, int)):
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1080 break
47456
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1081 elif isinstance(item, int):
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1082 nv.append('%d' % item)
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1083 else:
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1084 # format it to proper Tcl code if it contains space
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1085 nv.append(('{%s}' if ' ' in item else '%s') % item)
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1086 else:
47456
86ed979de898 Fix tkinter sequence passing. #2906. Backport from r63914.
Georg Brandl <georg@python.org>
parents: 47408
diff changeset
1087 v = ' '.join(nv)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1088 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1089 return res
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1090 def nametowidget(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1091 """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
1092 its Tcl name NAME."""
48137
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1093 name = str(name).split('.')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1094 w = self
48137
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1095
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1096 if not name[0]:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1097 w = w._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1098 name = name[1:]
48137
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1099
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1100 for n in name:
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1101 if not n:
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1102 break
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1103 w = w.children[n]
4a4c20a2167b Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap
Martin v. Löwis <martin@v.loewis.de>
parents: 47456
diff changeset
1104
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1105 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1106 _nametowidget = nametowidget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1107 def _register(self, func, subst=None, needcleanup=1):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1108 """Return a newly created Tcl function. If this
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1109 function is called, the Python function FUNC will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1110 be executed. An optional function SUBST can
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1111 be given which will be executed before FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1112 f = CallWrapper(func, subst, self).__call__
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
1113 name = repr(id(f))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1114 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1115 func = func.im_func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1116 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1117 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1118 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1119 name = name + func.__name__
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1120 except AttributeError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1121 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1122 self.tk.createcommand(name, f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1123 if needcleanup:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1124 if self._tclCommands is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1125 self._tclCommands = []
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1126 self._tclCommands.append(name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1127 return name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1128 register = _register
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1129 def _root(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1130 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1131 w = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1132 while w.master: w = w.master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1133 return w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1134 _subst_format = ('%#', '%b', '%f', '%h', '%k',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1135 '%s', '%t', '%w', '%x', '%y',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1136 '%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
1137 _subst_format_str = " ".join(_subst_format)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1138 def _substitute(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1139 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1140 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
1141 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
1142
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1143 getint = int
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1144 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
1145 """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
1146 try:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1147 return int(s)
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1148 except ValueError:
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1149 return s
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1150
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1151 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
1152 # 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
1153 e = Event()
28435
ee1c709050b2 Patch #707701: Expect '??' in event fields. Fixes #698517.
Martin v. Löwis <martin@v.loewis.de>
parents: 27341
diff changeset
1154 # 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
1155 # 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
1156 # 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
1157 # 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
1158 # 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
1159 # 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
1160 # 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
1161 # 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
1162 # 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
1163 # 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
1164 # 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
1165 # 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
1166 # KeyRelease,and Motion events
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1167 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
1168 e.num = getint_event(b)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1169 try: e.focus = getboolean(f)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1170 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
1171 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
1172 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
1173 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
1174 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
1175 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
1176 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
1177 e.y = getint_event(y)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1178 e.char = A
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1179 try: e.send_event = getboolean(E)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1180 except TclError: pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1181 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
1182 e.keysym_num = getint_event(N)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1183 e.type = T
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1184 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1185 e.widget = self._nametowidget(W)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1186 except KeyError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1187 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
1188 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
1189 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
1190 try:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1191 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
1192 except ValueError:
0d1025aefebf Older Tk versions don't support mousewheel support. Set event.delta
Fredrik Lundh <fredrik@pythonware.com>
parents: 13907
diff changeset
1193 e.delta = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1194 return (e,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1195 def _report_exception(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1196 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1197 import sys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1198 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
1199 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1200 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
1201 def _configure(self, cmd, cnf, kw):
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1202 """Internal function."""
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1203 if kw:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1204 cnf = _cnfmerge((cnf, kw))
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1205 elif cnf:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1206 cnf = _cnfmerge(cnf)
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1207 if cnf is None:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1208 cnf = {}
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1209 for x in self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1210 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
1211 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
1212 return cnf
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1213 if type(cnf) is StringType:
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1214 x = self.tk.split(
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1215 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
1216 return (x[0][1:],) + x[1:]
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1217 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
1218 # These used to be defined in Widget:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1219 def configure(self, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1220 """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
1221
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1222 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1223 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1224 the allowed keyword arguments call the method keys.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1225 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
1226 return self._configure('configure', cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1227 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1228 def cget(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1229 """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
1230 return self.tk.call(self._w, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1231 __getitem__ = cget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1232 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1233 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
1234 def __contains__(self, key):
de11bf84491d #615772: raise a more explicit error from Tkinter.Misc.__contains__.
Georg Brandl <georg@python.org>
parents: 47187
diff changeset
1235 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
1236 def keys(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1237 """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
1238 return map(lambda x: x[0][1:],
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1239 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
1240 def __str__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1241 """Return the window path name of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1242 return self._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1243 # Pack methods that apply to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1244 _noarg_ = ['_noarg_']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1245 def pack_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1246 """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
1247
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1248 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1249 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
1250 is given the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1251 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1252 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1253 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1254 'pack', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1255 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1256 self.tk.call('pack', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1257 propagate = pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1258 def pack_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1259 """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
1260 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1261 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1262 self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1263 self.tk.call('pack', 'slaves', self._w)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1264 slaves = pack_slaves
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1265 # Place method that applies to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1266 def place_slaves(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1267 """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
1268 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1269 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1270 self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1271 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1272 'place', 'slaves', self._w)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1273 # Grid methods that apply to the master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1274 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
1275 """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
1276 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
1277
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1278 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
1279 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
1280 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
1281 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
1282
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1283 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
1284 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
1285 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1286 args = ('grid', 'bbox', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1287 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
1288 args = args + (column, row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1289 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
1290 args = args + (col2, row2)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1291 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
1292
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1293 bbox = grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1294 def _grid_configure(self, command, index, cnf, kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1295 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1296 if type(cnf) is StringType and not kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1297 if cnf[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1298 cnf = cnf[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1299 if cnf[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1300 cnf = '-'+cnf
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1301 options = (cnf,)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1302 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1303 options = self._options(cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1304 if not options:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1305 res = self.tk.call('grid',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1306 command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1307 words = self.tk.splitlist(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1308 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1309 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1310 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1311 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1312 if not value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1313 value = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1314 elif '.' in value:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1315 value = getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1316 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1317 value = getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1318 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1319 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1320 res = self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1321 ('grid', command, self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1322 + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1323 if len(options) == 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1324 if not res: return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1325 # 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
1326 if '.' in res: return getdouble(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1327 return getint(res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1328 def grid_columnconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1329 """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
1330
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1331 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
1332 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
1333 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1334 return self._grid_configure('columnconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1335 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
1336 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
1337 """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
1338 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
1339 widget is located."""
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1340 return self._getints(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1341 self.tk.call(
e4d0b1f94eca Move grid_location into Misc. Fixes bug #426892.
Martin v. Löwis <martin@v.loewis.de>
parents: 20198
diff changeset
1342 '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
1343 def grid_propagate(self, flag=_noarg_):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1344 """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
1345
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1346 A boolean argument specifies whether the geometry information
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1347 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
1348 is given, the current setting will be returned.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1349 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1350 if flag is Misc._noarg_:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1351 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1352 'grid', 'propagate', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1353 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1354 self.tk.call('grid', 'propagate', self._w, flag)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1355 def grid_rowconfigure(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1356 """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
1357
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1358 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
1359 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
1360 and pad (how much space to let additionally)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1361 return self._grid_configure('rowconfigure', index, cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1362 rowconfigure = grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1363 def grid_size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1364 """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
1365 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1366 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
1367 size = grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1368 def grid_slaves(self, row=None, column=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1369 """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
1370 in its packing order."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1371 args = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1372 if row is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1373 args = args + ('-row', row)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1374 if column is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1375 args = args + ('-column', column)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1376 return map(self._nametowidget,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1377 self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1378 ('grid', 'slaves', self._w) + args)))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1379
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1380 # 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
1381 # 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
1382
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1383 def event_add(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1384 """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
1385 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
1386 whenever SEQUENCE occurs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1387 args = ('event', 'add', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1388 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
1389
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1390 def event_delete(self, virtual, *sequences):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1391 """Unbind a virtual event VIRTUAL from SEQUENCE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1392 args = ('event', 'delete', virtual) + sequences
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1393 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
1394
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1395 def event_generate(self, sequence, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1396 """Generate an event SEQUENCE. Additional
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1397 keyword arguments specify parameter of the event
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1398 (e.g. x, y, rootx, rooty)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1399 args = ('event', 'generate', self._w, sequence)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1400 for k, v in kw.items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1401 args = args + ('-%s' % k, str(v))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1402 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
1403
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1404 def event_info(self, virtual=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1405 """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
1406 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
1407 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1408 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
1409
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1410 # 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
1411
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1412 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1413 """Return a list of all existing image names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1414 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
1415
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1416 def image_types(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1417 """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
1418 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
1419
6712
ff16448e8f24 Support for the "event" command, new in Tk 4.2.
Guido van Rossum <guido@python.org>
parents: 6625
diff changeset
1420
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
1421 class CallWrapper:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1422 """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
1423 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
1424 def __init__(self, func, subst, widget):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1425 """Store FUNC, SUBST and WIDGET as members."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1426 self.func = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1427 self.subst = subst
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1428 self.widget = widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1429 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1430 """Apply first function SUBST to arguments, than FUNC."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1431 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1432 if self.subst:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1433 args = self.subst(*args)
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1434 return self.func(*args)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1435 except SystemExit, msg:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1436 raise SystemExit, msg
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1437 except:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1438 self.widget._report_exception()
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1439
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
1440
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1441 class XView:
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1442 """Mix-in class for querying and changing the horizontal position
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1443 of a widget's window."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1444
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1445 def xview(self, *args):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1446 """Query and change the horizontal position of the view."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1447 res = self.tk.call(self._w, 'xview', *args)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1448 if not args:
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1449 return self._getdoubles(res)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1450
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1451 def xview_moveto(self, fraction):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1452 """Adjusts the view in the window so that FRACTION of the
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1453 total width of the canvas is off-screen to the left."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1454 self.tk.call(self._w, 'xview', 'moveto', fraction)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1455
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1456 def xview_scroll(self, number, what):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1457 """Shift the x-view according to NUMBER which is measured in "units"
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1458 or "pages" (WHAT)."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1459 self.tk.call(self._w, 'xview', 'scroll', number, what)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1460
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1461
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1462 class YView:
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1463 """Mix-in class for querying and changing the vertical position
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1464 of a widget's window."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1465
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1466 def yview(self, *args):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1467 """Query and change the vertical position of the view."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1468 res = self.tk.call(self._w, 'yview', *args)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1469 if not args:
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1470 return self._getdoubles(res)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1471
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1472 def yview_moveto(self, fraction):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1473 """Adjusts the view in the window so that FRACTION of the
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1474 total height of the canvas is off-screen to the top."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1475 self.tk.call(self._w, 'yview', 'moveto', fraction)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1476
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1477 def yview_scroll(self, number, what):
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1478 """Shift the y-view according to NUMBER which is measured in
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1479 "units" or "pages" (WHAT)."""
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1480 self.tk.call(self._w, 'yview', 'scroll', number, what)
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1481
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
1482
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1483 class Wm:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1484 """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
1485
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1486 def wm_aspect(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1487 minNumer=None, minDenom=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1488 maxNumer=None, maxDenom=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1489 """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
1490 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
1491 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
1492 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1493 self.tk.call('wm', 'aspect', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1494 minNumer, minDenom,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1495 maxNumer, maxDenom))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1496 aspect = wm_aspect
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1497
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1498 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
1499 """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
1500
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1501 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
1502 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
1503 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
1504 are as follows:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1505
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1506 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
1507 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
1508 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
1509 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
1510 windows).
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1511
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1512 On Macintosh, XXXXX
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1513
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1514 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
1515 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
1516 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
1517 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
1518 attributes=wm_attributes
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
1519
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1520 def wm_client(self, name=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1521 """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
1522 current value."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1523 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
1524 client = wm_client
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1525 def wm_colormapwindows(self, *wlist):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1526 """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
1527 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
1528 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
1529 if len(wlist) > 1:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1530 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
1531 args = ('wm', 'colormapwindows', self._w) + wlist
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1532 return map(self._nametowidget, self.tk.call(args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1533 colormapwindows = wm_colormapwindows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1534 def wm_command(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1535 """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
1536 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
1537 command if VALUE is None."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1538 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
1539 command = wm_command
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1540 def wm_deiconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1541 """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
1542 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
1543 return self.tk.call('wm', 'deiconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1544 deiconify = wm_deiconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1545 def wm_focusmodel(self, model=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1546 """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
1547 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
1548 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
1549 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
1550 focusmodel = wm_focusmodel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1551 def wm_frame(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1552 """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
1553 return self.tk.call('wm', 'frame', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1554 frame = wm_frame
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1555 def wm_geometry(self, newGeometry=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1556 """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
1557 current value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1558 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
1559 geometry = wm_geometry
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1560 def wm_grid(self,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1561 baseWidth=None, baseHeight=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1562 widthInc=None, heightInc=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1563 """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
1564 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
1565 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
1566 number of grid units requested in Tk_GeometryRequest."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1567 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1568 'wm', 'grid', self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1569 baseWidth, baseHeight, widthInc, heightInc))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1570 grid = wm_grid
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1571 def wm_group(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1572 """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
1573 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
1574 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
1575 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
1576 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
1577 """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
1578 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
1579
38875
118c650e2c9b Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 38863
diff changeset
1580 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
1581 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
1582 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
1583 (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
1584 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
1585 if default:
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1586 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
1587 else:
f6dc55d32f70 Patch #1096231: Add default argument to wm_iconbitmap.
Martin v. Löwis <martin@v.loewis.de>
parents: 38854
diff changeset
1588 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
1589 iconbitmap = wm_iconbitmap
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1590 def wm_iconify(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1591 """Display widget as icon."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1592 return self.tk.call('wm', 'iconify', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1593 iconify = wm_iconify
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1594 def wm_iconmask(self, bitmap=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1595 """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
1596 mask if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1597 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
1598 iconmask = wm_iconmask
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1599 def wm_iconname(self, newName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1600 """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
1601 None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1602 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
1603 iconname = wm_iconname
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1604 def wm_iconposition(self, x=None, y=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1605 """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
1606 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
1607 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1608 'wm', 'iconposition', self._w, x, y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1609 iconposition = wm_iconposition
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1610 def wm_iconwindow(self, pathName=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1611 """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
1612 value if None is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1613 return self.tk.call('wm', 'iconwindow', self._w, pathName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1614 iconwindow = wm_iconwindow
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1615 def wm_maxsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1616 """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
1617 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
1618 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1619 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1620 'wm', 'maxsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1621 maxsize = wm_maxsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1622 def wm_minsize(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1623 """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
1624 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
1625 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1626 return self._getints(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1627 'wm', 'minsize', self._w, width, height))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1628 minsize = wm_minsize
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1629 def wm_overrideredirect(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1630 """Instruct the window manager to ignore this widget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1631 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
1632 is given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1633 return self._getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1634 'wm', 'overrideredirect', self._w, boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1635 overrideredirect = wm_overrideredirect
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1636 def wm_positionfrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1637 """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
1638 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
1639 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1640 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
1641 positionfrom = wm_positionfrom
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1642 def wm_protocol(self, name=None, func=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1643 """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
1644 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
1645 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
1646 if hasattr(func, '__call__'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1647 command = self._register(func)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1648 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1649 command = func
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1650 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1651 'wm', 'protocol', self._w, name, command)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1652 protocol = wm_protocol
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1653 def wm_resizable(self, width=None, height=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1654 """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
1655 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
1656 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
1657 resizable = wm_resizable
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1658 def wm_sizefrom(self, who=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1659 """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
1660 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
1661 "program"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1662 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
1663 sizefrom = wm_sizefrom
13906
c45accc8e6d0 -- added optional newstate argument to Wm.state. The newstate arg
Fredrik Lundh <fredrik@pythonware.com>
parents: 13905
diff changeset
1664 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
1665 """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
1666 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
1667 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
1668 state = wm_state
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1669 def wm_title(self, string=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1670 """Set the title of this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1671 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
1672 title = wm_title
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1673 def wm_transient(self, master=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1674 """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
1675 with regard to widget MASTER."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1676 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
1677 transient = wm_transient
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1678 def wm_withdraw(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1679 """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
1680 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
1681 return self.tk.call('wm', 'withdraw', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1682 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
1683
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1684
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1685 class Tk(Misc, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1686 """Toplevel widget of Tk which represents mostly the main window
68503
ee5350f1d0c2 #11515: fix several typos. Patch by Piotr Kasprzyk.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 68256
diff changeset
1687 of an application. It has an associated Tcl interpreter."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1688 _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
1689 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
1690 useTk=1, sync=0, use=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1691 """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
1692 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
1693 readprofile).
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1694 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
1695 is the name of the widget class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1696 self.master = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1697 self.children = {}
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1698 self._tkloaded = 0
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1699 # 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
1700 # ensure that self.tk is always _something_.
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31547
diff changeset
1701 self.tk = None
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1702 if baseName is None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1703 import sys, os
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1704 baseName = os.path.basename(sys.argv[0])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1705 baseName, ext = os.path.splitext(baseName)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1706 if ext not in ('.py', '.pyc', '.pyo'):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1707 baseName = baseName + ext
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1708 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
1709 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
1710 if useTk:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1711 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1712 self.readprofile(baseName, className)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1713 def loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1714 if not self._tkloaded:
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1715 self.tk.loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1716 self._loadtk()
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1717 def _loadtk(self):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1718 self._tkloaded = 1
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1719 global _default_root
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1720 # Version sanity checks
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1721 tk_version = self.tk.getvar('tk_version')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1722 if tk_version != _tkinter.TK_VERSION:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1723 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1724 "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
1725 % (_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
1726 # 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
1727 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
1728 if tcl_version != _tkinter.TCL_VERSION:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1729 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1730 "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
1731 % (_tkinter.TCL_VERSION, tcl_version)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1732 if TkVersion < 4.0:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1733 raise RuntimeError, \
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1734 "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
1735 % str(TkVersion)
34642
b5a25c56a852 Patch #1121234: Properly cleanup _exit and tkerror commands.
Martin v. Löwis <martin@v.loewis.de>
parents: 32941
diff changeset
1736 # 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
1737 # 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
1738 # 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
1739 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
1740 self._tclCommands = []
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1741 self.tk.createcommand('tkerror', _tkerror)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1742 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
1743 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
1744 self._tclCommands.append('exit')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1745 if _support_default_root and not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1746 _default_root = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1747 self.protocol("WM_DELETE_WINDOW", self.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1748 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1749 """Destroy this and all descendants widgets. This will
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1750 end the application of this Tcl interpreter."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1751 for c in self.children.values(): c.destroy()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1752 self.tk.call('destroy', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1753 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1754 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1755 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
1756 _default_root = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1757 def readprofile(self, baseName, className):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1758 """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
1759 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
1760 such a file exists in the home directory."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1761 import os
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
1762 if 'HOME' in os.environ: home = os.environ['HOME']
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1763 else: home = os.curdir
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1764 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
1765 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
1766 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
1767 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
1768 dir = {'self': self}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1769 exec 'from Tkinter import *' in dir
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1770 if os.path.isfile(class_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1771 self.tk.call('source', class_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1772 if os.path.isfile(class_py):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1773 execfile(class_py, dir)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1774 if os.path.isfile(base_tcl):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1775 self.tk.call('source', base_tcl)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1776 if os.path.isfile(base_py):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1777 execfile(base_py, dir)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1778 def report_callback_exception(self, exc, val, tb):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1779 """Internal function. It reports exception on sys.stderr."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1780 import traceback, sys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1781 sys.stderr.write("Exception in Tkinter callback\n")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1782 sys.last_type = exc
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1783 sys.last_value = val
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1784 sys.last_traceback = tb
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1785 traceback.print_exception(exc, val, tb)
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1786 def __getattr__(self, attr):
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1787 "Delegate attribute access to the interpreter object"
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1788 return getattr(self.tk, attr)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1789
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1790 # Ideally, the classes Pack, Place and Grid disappear, the
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1791 # pack/place/grid methods are defined on the Widget class, and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1792 # everybody uses w.pack_whatever(...) instead of Pack.whatever(w,
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1793 # ...), with pack(), place() and grid() being short for
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1794 # pack_configure(), place_configure() and grid_columnconfigure(), and
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1795 # 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
1796 # 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
1797 # 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
1798 # backwards compatibility features. Also note that those methods that
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1799 # 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
1800 # the Misc class (which now incorporates all methods common between
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1801 # toplevel and interior widgets). Again, for compatibility, these are
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1802 # copied into the Pack, Place or Grid class.
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1803
31547
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1804
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1805 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
1806 return Tk(screenName, baseName, className, useTk)
470f95ad6750 Implementation of patch 869468
David Ascher <david.ascher@gmail.com>
parents: 31515
diff changeset
1807
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1808 class Pack:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1809 """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
1810
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1811 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
1812 def pack_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1813 """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
1814 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
1815 anchor=NSEW (or subset) - position widget according to
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1816 given direction
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1817 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
1818 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
1819 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
1820 in=master - use master to contain this widget
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1821 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1822 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1823 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1824 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1825 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1826 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
1827 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1828 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1829 ('pack', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1830 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1831 pack = configure = config = pack_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1832 def pack_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1833 """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
1834 self.tk.call('pack', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1835 forget = pack_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1836 def pack_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1837 """Return information about the packing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1838 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1839 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1840 self.tk.call('pack', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1841 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1842 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1843 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1844 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1845 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1846 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1847 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1848 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1849 info = pack_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1850 propagate = pack_propagate = Misc.pack_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1851 slaves = pack_slaves = Misc.pack_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1852
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1853 class Place:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1854 """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
1855
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1856 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
1857 def place_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1858 """Place a widget in the parent widget. Use as options:
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1859 in=master - master relative to which the widget is placed
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1860 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1861 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
1862 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
1863 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
1864 relative to width of master (1.0 is right edge)
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1865 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
1866 relative to height of master (1.0 is bottom edge)
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1867 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
1868 width=amount - width of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1869 height=amount - height of this widget in pixel
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1870 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
1871 relative to width of master (1.0 is the same width
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1872 as the master)
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1873 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
1874 relative to height of master (1.0 is the same
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1875 height as the master)
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1876 bordermode="inside" or "outside" - whether to take border width of
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1877 master widget into account
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1878 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1879 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1880 ('place', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1881 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1882 place = configure = config = place_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1883 def place_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1884 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1885 self.tk.call('place', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1886 forget = place_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1887 def place_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1888 """Return information about the placing options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1889 for this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1890 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1891 self.tk.call('place', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1892 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1893 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1894 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1895 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1896 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1897 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1898 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1899 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1900 info = place_info
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1901 slaves = place_slaves = Misc.place_slaves
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1902
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1903 class Grid:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1904 """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
1905
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1906 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
1907 # Thanks to Masazumi Yoshikawa (yosikawa@isi.edu)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1908 def grid_configure(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1909 """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
1910 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
1911 columnspan=number - this widget will span several columns
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1912 in=master - use master to contain this widget
47408
075c6bd20f07 Backport r63776: tkinter fixes.
Georg Brandl <georg@python.org>
parents: 39116
diff changeset
1913 in_=master - see 'in' option description
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1914 ipadx=amount - add internal padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1915 ipady=amount - add internal padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1916 padx=amount - add padding in x direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1917 pady=amount - add padding in y direction
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1918 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
1919 rowspan=number - this widget will span several rows
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1920 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
1921 widget stick to the cell boundary
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1922 """
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1923 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1924 ('grid', 'configure', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1925 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1926 grid = configure = config = grid_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1927 bbox = grid_bbox = Misc.grid_bbox
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1928 columnconfigure = grid_columnconfigure = Misc.grid_columnconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1929 def grid_forget(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1930 """Unmap this widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1931 self.tk.call('grid', 'forget', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1932 forget = grid_forget
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1933 def grid_remove(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1934 """Unmap this widget but remember the grid options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1935 self.tk.call('grid', 'remove', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1936 def grid_info(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1937 """Return information about the options
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1938 for positioning this widget in a grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1939 words = self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1940 self.tk.call('grid', 'info', self._w))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1941 dict = {}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1942 for i in range(0, len(words), 2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1943 key = words[i][1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1944 value = words[i+1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1945 if value[:1] == '.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1946 value = self._nametowidget(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1947 dict[key] = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1948 return dict
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1949 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
1950 location = grid_location = Misc.grid_location
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1951 propagate = grid_propagate = Misc.grid_propagate
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1952 rowconfigure = grid_rowconfigure = Misc.grid_rowconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1953 size = grid_size = Misc.grid_size
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1954 slaves = grid_slaves = Misc.grid_slaves
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
1955
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
1956 class BaseWidget(Misc):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1957 """Internal class."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1958 def _setup(self, master, cnf):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1959 """Internal function. Sets up information about children."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1960 if _support_default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1961 global _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1962 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1963 if not _default_root:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1964 _default_root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1965 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1966 self.master = master
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1967 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1968 name = None
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
1969 if 'name' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1970 name = cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1971 del cnf['name']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1972 if not name:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
1973 name = repr(id(self))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1974 self._name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1975 if master._w=='.':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1976 self._w = '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1977 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1978 self._w = master._w + '.' + name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1979 self.children = {}
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
1980 if self._name in self.master.children:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1981 self.master.children[self._name].destroy()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1982 self.master.children[self._name] = self
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1983 def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1984 """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
1985 and appropriate options."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1986 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1987 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1988 self.widgetName = widgetName
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1989 BaseWidget._setup(self, master, cnf)
49632
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
1990 if self._tclCommands is None:
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
1991 self._tclCommands = []
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1992 classes = []
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1993 for k in cnf.keys():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1994 if type(k) is ClassType:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1995 classes.append((k, cnf[k]))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1996 del cnf[k]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1997 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1998 (widgetName, self._w) + extra + self._options(cnf))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
1999 for k, v in classes:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2000 k.configure(self, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2001 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2002 """Destroy this and all descendants widgets."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2003 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
2004 self.tk.call('destroy', self._w)
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
2005 if self._name in self.master.children:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2006 del self.master.children[self._name]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2007 Misc.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2008 def _do(self, name, args=()):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2009 # XXX Obsolete -- better use self.tk.call directly!
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2010 return self.tk.call((self._w, name) + args)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2011
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2012 class Widget(BaseWidget, Pack, Place, Grid):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2013 """Internal class.
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2014
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2015 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
2016 Pack, Place or Grid."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2017 pass
6571
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2018
8b14312a0290 Some restructuring.
Guido van Rossum <guido@python.org>
parents: 6349
diff changeset
2019 class Toplevel(BaseWidget, Wm):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2020 """Toplevel widget, e.g. for dialogs."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2021 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2022 """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
2023
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2024 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2025 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2026 highlightcolor, highlightthickness, menu, relief, screen, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2027 use, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2028 if kw:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2029 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2030 extra = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2031 for wmkey in ['screen', 'class_', 'class', 'visual',
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2032 'colormap']:
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
2033 if wmkey in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2034 val = cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2035 # TBD: a hack needed because some keys
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2036 # are not valid as keyword arguments
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2037 if wmkey[-1] == '_': opt = '-'+wmkey[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2038 else: opt = '-'+wmkey
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2039 extra = extra + (opt, val)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2040 del cnf[wmkey]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2041 BaseWidget.__init__(self, master, 'toplevel', cnf, {}, extra)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2042 root = self._root()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2043 self.iconname(root.iconname())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2044 self.title(root.title())
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2045 self.protocol("WM_DELETE_WINDOW", self.destroy)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2046
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2047 class Button(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2048 """Button widget."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2049 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2050 """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
2051
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2052 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2053
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2054 activebackground, activeforeground, anchor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2055 background, bitmap, borderwidth, cursor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2056 disabledforeground, font, foreground
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2057 highlightbackground, highlightcolor,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2058 highlightthickness, image, justify,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2059 padx, pady, relief, repeatdelay,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2060 repeatinterval, takefocus, text,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2061 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2062
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2063 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2064
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2065 command, compound, default, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2066 overrelief, state, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2067 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2068 Widget.__init__(self, master, 'button', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2069
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2070 def tkButtonEnter(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2071 self.tk.call('tkButtonEnter', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2072
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2073 def tkButtonLeave(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2074 self.tk.call('tkButtonLeave', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2075
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2076 def tkButtonDown(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2077 self.tk.call('tkButtonDown', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2078
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2079 def tkButtonUp(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2080 self.tk.call('tkButtonUp', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2081
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2082 def tkButtonInvoke(self, *dummy):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2083 self.tk.call('tkButtonInvoke', self._w)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2084
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2085 def flash(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2086 """Flash the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2087
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2088 This is accomplished by redisplaying
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2089 the button several times, alternating between active and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2090 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
2091 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
2092 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
2093 disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2094 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2095 self.tk.call(self._w, 'flash')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2096
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2097 def invoke(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2098 """Invoke the command associated with the button.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2099
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2100 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
2101 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
2102 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
2103 is disabled.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2104 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2105 return self.tk.call(self._w, 'invoke')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2106
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2107 # Indices:
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
2108 # XXX I don't like these -- take them away
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2109 def AtEnd():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2110 return 'end'
1669
273451892327 Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents: 1666
diff changeset
2111 def AtInsert(*args):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2112 s = 'insert'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2113 for a in args:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2114 if a: s = s + (' ' + a)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2115 return s
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2116 def AtSelFirst():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2117 return 'sel.first'
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2118 def AtSelLast():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2119 return 'sel.last'
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2120 def At(x, y=None):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2121 if y is None:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
2122 return '@%r' % (x,)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2123 else:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
2124 return '@%r,%r' % (x, y)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2125
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
2126 class Canvas(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2127 """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
2128 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2129 """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
2130
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2131 Valid resource names: background, bd, bg, borderwidth, closeenough,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2132 confine, cursor, height, highlightbackground, highlightcolor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2133 highlightthickness, insertbackground, insertborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2134 insertofftime, insertontime, insertwidth, offset, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2135 scrollregion, selectbackground, selectborderwidth, selectforeground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2136 state, takefocus, width, xscrollcommand, xscrollincrement,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2137 yscrollcommand, yscrollincrement."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2138 Widget.__init__(self, master, 'canvas', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2139 def addtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2140 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2141 self.tk.call((self._w, 'addtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2142 def addtag_above(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2143 """Add tag NEWTAG to all items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2144 self.addtag(newtag, 'above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2145 def addtag_all(self, newtag):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2146 """Add tag NEWTAG to all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2147 self.addtag(newtag, 'all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2148 def addtag_below(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2149 """Add tag NEWTAG to all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2150 self.addtag(newtag, 'below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2151 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
2152 """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
2153 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2154 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
2155 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
2156 self.addtag(newtag, 'closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2157 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
2158 """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
2159 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2160 self.addtag(newtag, 'enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2161 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
2162 """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
2163 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2164 self.addtag(newtag, 'overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2165 def addtag_withtag(self, newtag, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2166 """Add tag NEWTAG to all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2167 self.addtag(newtag, 'withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2168 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2169 """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
2170 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
2171 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2172 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
2173 def tag_unbind(self, tagOrId, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2174 """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
2175 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2176 self.tk.call(self._w, 'bind', tagOrId, sequence, '')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2177 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2178 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2179 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
2180 """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
2181
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2182 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
2183 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
2184 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
2185 return self._bind((self._w, 'bind', tagOrId),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2186 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2187 def canvasx(self, screenx, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2188 """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
2189 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2190 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2191 self._w, 'canvasx', screenx, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2192 def canvasy(self, screeny, gridspacing=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2193 """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
2194 to nearest multiple of GRIDSPACING units."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2195 return getdouble(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2196 self._w, 'canvasy', screeny, gridspacing))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2197 def coords(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2198 """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
2199 # XXX Should use _flatten on args
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2200 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
2201 self.tk.splitlist(
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2202 self.tk.call((self._w, 'coords') + args)))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2203 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
2204 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2205 args = _flatten(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2206 cnf = args[-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2207 if type(cnf) in (DictionaryType, TupleType):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2208 args = args[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2209 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2210 cnf = {}
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2211 return getint(self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2212 self._w, 'create', itemType,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2213 *(args + self._options(cnf, kw))))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2214 def create_arc(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2215 """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
2216 return self._create('arc', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2217 def create_bitmap(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2218 """Create bitmap with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2219 return self._create('bitmap', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2220 def create_image(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2221 """Create image item with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2222 return self._create('image', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2223 def create_line(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2224 """Create line with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2225 return self._create('line', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2226 def create_oval(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2227 """Create oval with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2228 return self._create('oval', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2229 def create_polygon(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2230 """Create polygon with coordinates x1,y1,...,xn,yn."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2231 return self._create('polygon', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2232 def create_rectangle(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2233 """Create rectangle with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2234 return self._create('rectangle', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2235 def create_text(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2236 """Create text with coordinates x1,y1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2237 return self._create('text', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2238 def create_window(self, *args, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2239 """Create window with coordinates x1,y1,x2,y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2240 return self._create('window', args, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2241 def dchars(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2242 """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
2243 several times) from FIRST to LAST character (including)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2244 self.tk.call((self._w, 'dchars') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2245 def delete(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2246 """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
2247 self.tk.call((self._w, 'delete') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2248 def dtag(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2249 """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
2250 identified by first argument in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2251 self.tk.call((self._w, 'dtag') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2252 def find(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2253 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2254 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2255 self.tk.call((self._w, 'find') + args)) or ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2256 def find_above(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2257 """Return items above TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2258 return self.find('above', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2259 def find_all(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2260 """Return all items."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2261 return self.find('all')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2262 def find_below(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2263 """Return all items below TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2264 return self.find('below', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2265 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
2266 """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
2267 If several match take the top-most.
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2268 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
2269 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
2270 return self.find('closest', x, y, halo, start)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2271 def find_enclosed(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2272 """Return all items in rectangle defined
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2273 by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2274 return self.find('enclosed', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2275 def find_overlapping(self, x1, y1, x2, y2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2276 """Return all items which overlap the rectangle
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2277 defined by X1,Y1,X2,Y2."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2278 return self.find('overlapping', x1, y1, x2, y2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2279 def find_withtag(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2280 """Return all items with TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2281 return self.find('withtag', tagOrId)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2282 def focus(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2283 """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
2284 return self.tk.call((self._w, 'focus') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2285 def gettags(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2286 """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
2287 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2288 self.tk.call((self._w, 'gettags') + args))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2289 def icursor(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2290 """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
2291 In ARGS TAGORID must be first."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2292 self.tk.call((self._w, 'icursor') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2293 def index(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2294 """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
2295 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
2296 def insert(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2297 """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
2298 be TAGORID POS TEXT."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2299 self.tk.call((self._w, 'insert') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2300 def itemcget(self, tagOrId, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2301 """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
2302 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2303 (self._w, 'itemcget') + (tagOrId, '-'+option))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2304 def itemconfigure(self, tagOrId, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2305 """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
2306
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2307 The values for resources are specified as keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2308 arguments. To get an overview about
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2309 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
2310 """
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2311 return self._configure(('itemconfigure', tagOrId), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2312 itemconfig = itemconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2313 # 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
2314 # 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
2315 # (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
2316 # 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
2317 def tag_lower(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2318 """Lower an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2319 (optional below another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2320 self.tk.call((self._w, 'lower') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2321 lower = tag_lower
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2322 def move(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2323 """Move an item TAGORID given in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2324 self.tk.call((self._w, 'move') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2325 def postscript(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2326 """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
2327 file. Valid options: colormap, colormode, file, fontmap,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2328 height, pageanchor, pageheight, pagewidth, pagex, pagey,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2329 rotate, witdh, x, y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2330 return self.tk.call((self._w, 'postscript') +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2331 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2332 def tag_raise(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2333 """Raise an item TAGORID given in ARGS
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2334 (optional above another item)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2335 self.tk.call((self._w, 'raise') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2336 lift = tkraise = tag_raise
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2337 def scale(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2338 """Scale item TAGORID with XORIGIN, YORIGIN, XSCALE, YSCALE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2339 self.tk.call((self._w, 'scale') + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2340 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2341 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2342 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
2343 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
2344 """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
2345 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
2346 scan_mark."""
27211
a494f5a8639f Fix SF bug # 602259, 3rd parameter for Tkinter.scan_dragto
Neal Norwitz <nnorwitz@gmail.com>
parents: 26428
diff changeset
2347 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
2348 def select_adjust(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2349 """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
2350 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
2351 def select_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2352 """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
2353 self.tk.call(self._w, 'select', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2354 def select_from(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2355 """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
2356 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
2357 def select_item(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2358 """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
2359 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
2360 def select_to(self, tagOrId, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2361 """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
2362 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
2363 def type(self, tagOrId):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2364 """Return the type of the item TAGORID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2365 return self.tk.call(self._w, 'type', tagOrId) or None
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2366
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2367 class Checkbutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2368 """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
2369 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2370 """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
2371
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2372 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2373 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2374 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2375 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2376 indicatoron, justify, offvalue, onvalue, padx, pady, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2377 selectcolor, selectimage, state, takefocus, text, textvariable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2378 underline, variable, width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2379 Widget.__init__(self, master, 'checkbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2380 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2381 """Put the button in off-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2382 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2383 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2384 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2385 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2386 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2387 """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
2388 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2389 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2390 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2391 self.tk.call(self._w, 'select')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2392 def toggle(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2393 """Toggle the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2394 self.tk.call(self._w, 'toggle')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2395
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
2396 class Entry(Widget, XView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2397 """Entry widget which allows to display simple text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2398 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2399 """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
2400
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2401 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2402 exportselection, fg, font, foreground, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2403 highlightcolor, highlightthickness, insertbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2404 insertborderwidth, insertofftime, insertontime, insertwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2405 invalidcommand, invcmd, justify, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2406 selectborderwidth, selectforeground, show, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2407 textvariable, validate, validatecommand, vcmd, width,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2408 xscrollcommand."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2409 Widget.__init__(self, master, 'entry', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2410 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2411 """Delete text from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2412 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2413 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2414 """Return the text."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2415 return self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2416 def icursor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2417 """Insert cursor at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2418 self.tk.call(self._w, 'icursor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2419 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2420 """Return position of cursor."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2421 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2422 self._w, 'index', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2423 def insert(self, index, string):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2424 """Insert STRING at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2425 self.tk.call(self._w, 'insert', index, string)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2426 def scan_mark(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2427 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2428 self.tk.call(self._w, 'scan', 'mark', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2429 def scan_dragto(self, x):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2430 """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
2431 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
2432 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2433 self.tk.call(self._w, 'scan', 'dragto', x)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2434 def selection_adjust(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2435 """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
2436 self.tk.call(self._w, 'selection', 'adjust', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2437 select_adjust = selection_adjust
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2438 def selection_clear(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2439 """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
2440 self.tk.call(self._w, 'selection', 'clear')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2441 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2442 def selection_from(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2443 """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
2444 self.tk.call(self._w, 'selection', 'from', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2445 select_from = selection_from
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2446 def selection_present(self):
55641
ae817fa4e605 Clarifying Entry.selection_present's docstring.
Guilherme Polo <ggpolo@gmail.com>
parents: 55640
diff changeset
2447 """Return True if there are characters selected in the entry, False
ae817fa4e605 Clarifying Entry.selection_present's docstring.
Guilherme Polo <ggpolo@gmail.com>
parents: 55640
diff changeset
2448 otherwise."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2449 return self.tk.getboolean(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2450 self.tk.call(self._w, 'selection', 'present'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2451 select_present = selection_present
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2452 def selection_range(self, start, end):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2453 """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
2454 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
2455 select_range = selection_range
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2456 def selection_to(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2457 """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
2458 self.tk.call(self._w, 'selection', 'to', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2459 select_to = selection_to
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2460
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2461 class Frame(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2462 """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
2463 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2464 """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
2465
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2466 Valid resource names: background, bd, bg, borderwidth, class,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2467 colormap, container, cursor, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2468 highlightcolor, highlightthickness, relief, takefocus, visual, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2469 cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2470 extra = ()
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
2471 if 'class_' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2472 extra = ('-class', cnf['class_'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2473 del cnf['class_']
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
2474 elif 'class' in cnf:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2475 extra = ('-class', cnf['class'])
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2476 del cnf['class']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2477 Widget.__init__(self, master, 'frame', cnf, {}, extra)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2478
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2479 class Label(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2480 """Label widget which can display text and bitmaps."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2481 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2482 """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
2483
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2484 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2485
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2486 activebackground, activeforeground, anchor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2487 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
2488 disabledforeground, font, foreground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2489 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2490 highlightthickness, image, justify,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2491 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
2492 textvariable, underline, wraplength
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2493
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2494 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2495
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2496 height, state, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2497
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2498 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2499 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
2500
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
2501 class Listbox(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2502 """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
2503 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2504 """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
2505
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2506 Valid resource names: background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2507 exportselection, fg, font, foreground, height, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2508 highlightcolor, highlightthickness, relief, selectbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2509 selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2510 width, xscrollcommand, yscrollcommand, listvariable."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2511 Widget.__init__(self, master, 'listbox', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2512 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2513 """Activate item identified by INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2514 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2515 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2516 """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
2517 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
2518 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2519 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
2520 def curselection(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2521 """Return list of indices of currently selected item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2522 # XXX Ought to apply self._getints()...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2523 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2524 self._w, 'curselection'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2525 def delete(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2526 """Delete items from FIRST to LAST (not included)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2527 self.tk.call(self._w, 'delete', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2528 def get(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2529 """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
2530 if last:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2531 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2532 self._w, 'get', first, last))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2533 else:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2534 return self.tk.call(self._w, 'get', first)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2535 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2536 """Return index of item identified with INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2537 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2538 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2539 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2540 def insert(self, index, *elements):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2541 """Insert ELEMENTS at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2542 self.tk.call((self._w, 'insert', index) + elements)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2543 def nearest(self, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2544 """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
2545 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2546 self._w, 'nearest', y))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2547 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2548 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2549 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
2550 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2551 """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
2552 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
2553 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2554 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
2555 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2556 """Scroll such that INDEX is visible."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2557 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2558 def selection_anchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2559 """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
2560 self.tk.call(self._w, 'selection', 'anchor', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2561 select_anchor = selection_anchor
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2562 def selection_clear(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2563 """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
2564 self.tk.call(self._w,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2565 'selection', 'clear', first, last)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2566 select_clear = selection_clear
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2567 def selection_includes(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2568 """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
2569 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2570 self._w, 'selection', 'includes', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2571 select_includes = selection_includes
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2572 def selection_set(self, first, last=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2573 """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
2574 changing the currently selected elements."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2575 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
2576 select_set = selection_set
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2577 def size(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2578 """Return the number of elements in the listbox."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2579 return getint(self.tk.call(self._w, 'size'))
19743
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2580 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
2581 """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
2582 return self.tk.call(
8541878cf2e1 class Listbox: add itemcget, to satisfy SF patch #457713.
Guido van Rossum <guido@python.org>
parents: 19638
diff changeset
2583 (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
2584 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
2585 """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
2586
40feaedb7867 Add Listbox.itemconfig[ure] call. (A "recent" addition to Tk -- 8.0
Guido van Rossum <guido@python.org>
parents: 19439
diff changeset
2587 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
2588 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
2589 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
2590 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
2591 selectbackground, selectforeground."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
2592 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
2593 itemconfig = itemconfigure
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2594
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2595 class Menu(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2596 """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
2597 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2598 """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
2599
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2600 Valid resource names: activebackground, activeborderwidth,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2601 activeforeground, background, bd, bg, borderwidth, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2602 disabledforeground, fg, font, foreground, postcommand, relief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2603 selectcolor, takefocus, tearoff, tearoffcommand, title, type."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2604 Widget.__init__(self, master, 'menu', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2605 def tk_bindForTraversal(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2606 pass # obsolete since Tk 4.0
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2607 def tk_mbPost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2608 self.tk.call('tk_mbPost', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2609 def tk_mbUnpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2610 self.tk.call('tk_mbUnpost')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2611 def tk_traverseToMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2612 self.tk.call('tk_traverseToMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2613 def tk_traverseWithinMenu(self, char):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2614 self.tk.call('tk_traverseWithinMenu', self._w, char)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2615 def tk_getMenuButtons(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2616 return self.tk.call('tk_getMenuButtons', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2617 def tk_nextMenu(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2618 self.tk.call('tk_nextMenu', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2619 def tk_nextMenuEntry(self, count):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2620 self.tk.call('tk_nextMenuEntry', count)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2621 def tk_invokeMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2622 self.tk.call('tk_invokeMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2623 def tk_firstMenu(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2624 self.tk.call('tk_firstMenu', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2625 def tk_mbButtonDown(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2626 self.tk.call('tk_mbButtonDown', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2627 def tk_popup(self, x, y, entry=""):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2628 """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
2629 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
2630 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2631 """Activate entry at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2632 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2633 def add(self, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2634 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2635 self.tk.call((self._w, 'add', itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2636 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2637 def add_cascade(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2638 """Add hierarchical menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2639 self.add('cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2640 def add_checkbutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2641 """Add checkbutton menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2642 self.add('checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2643 def add_command(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2644 """Add command menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2645 self.add('command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2646 def add_radiobutton(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2647 """Addd radio menu item."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2648 self.add('radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2649 def add_separator(self, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2650 """Add separator."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2651 self.add('separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2652 def insert(self, index, itemType, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2653 """Internal function."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2654 self.tk.call((self._w, 'insert', index, itemType) +
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2655 self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2656 def insert_cascade(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2657 """Add hierarchical menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2658 self.insert(index, 'cascade', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2659 def insert_checkbutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2660 """Add checkbutton menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2661 self.insert(index, 'checkbutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2662 def insert_command(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2663 """Add command menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2664 self.insert(index, 'command', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2665 def insert_radiobutton(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2666 """Addd radio menu item at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2667 self.insert(index, 'radiobutton', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2668 def insert_separator(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2669 """Add separator at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2670 self.insert(index, 'separator', cnf or kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2671 def delete(self, index1, index2=None):
49632
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2672 """Delete menu items between INDEX1 and INDEX2 (included)."""
48208
ac8103341b80 Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48137
diff changeset
2673 if index2 is None:
ac8103341b80 Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
Robert Schuppenies <okkotonushi@googlemail.com>
parents: 48137
diff changeset
2674 index2 = index1
49632
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2675
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2676 num_index1, num_index2 = self.index(index1), self.index(index2)
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2677 if (num_index1 is None) or (num_index2 is None):
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2678 num_index1, num_index2 = 0, -1
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2679
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2680 for i in range(num_index1, num_index2 + 1):
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2681 if 'command' in self.entryconfig(i):
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2682 c = str(self.entrycget(i, 'command'))
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2683 if c:
45046f07227a Issue #3774: Fixed an error when create a Tkinter menu item without command
Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
parents: 48822
diff changeset
2684 self.deletecommand(c)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2685 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2686 def entrycget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2687 """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
2688 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
2689 def entryconfigure(self, index, cnf=None, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2690 """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
2691 return self._configure(('entryconfigure', index), cnf, kw)
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2692 entryconfig = entryconfigure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2693 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2694 """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
2695 i = self.tk.call(self._w, 'index', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2696 if i == 'none': return None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2697 return getint(i)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2698 def invoke(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2699 """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
2700 the associated command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2701 return self.tk.call(self._w, 'invoke', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2702 def post(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2703 """Display a menu at position X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2704 self.tk.call(self._w, 'post', x, y)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2705 def type(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2706 """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
2707 return self.tk.call(self._w, 'type', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2708 def unpost(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2709 """Unmap a menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2710 self.tk.call(self._w, 'unpost')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2711 def yposition(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2712 """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
2713 return getint(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2714 self._w, 'yposition', index))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2715
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2716 class Menubutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2717 """Menubutton widget, obsolete since Tk8.0."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2718 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2719 Widget.__init__(self, master, 'menubutton', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2720
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2721 class Message(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2722 """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
2723 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2724 Widget.__init__(self, master, 'message', cnf, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2725
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2726 class Radiobutton(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2727 """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
2728 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2729 """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
2730
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2731 Valid resource names: activebackground, activeforeground, anchor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2732 background, bd, bg, bitmap, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2733 disabledforeground, fg, font, foreground, height,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2734 highlightbackground, highlightcolor, highlightthickness, image,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2735 indicatoron, justify, padx, pady, relief, selectcolor, selectimage,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2736 state, takefocus, text, textvariable, underline, value, variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2737 width, wraplength."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2738 Widget.__init__(self, master, 'radiobutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2739 def deselect(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2740 """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
2741
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2742 self.tk.call(self._w, 'deselect')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2743 def flash(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2744 """Flash the button."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2745 self.tk.call(self._w, 'flash')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2746 def invoke(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2747 """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
2748 return self.tk.call(self._w, 'invoke')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2749 def select(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2750 """Put the button in on-state."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2751 self.tk.call(self._w, 'select')
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2752
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2753 class Scale(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2754 """Scale widget which can display a numerical scale."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2755 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2756 """Construct a 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
2757
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2758 Valid resource names: activebackground, background, bigincrement, bd,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2759 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
2760 highlightbackground, highlightcolor, highlightthickness, label,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2761 length, orient, relief, repeatdelay, repeatinterval, resolution,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2762 showvalue, sliderlength, sliderrelief, state, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2763 tickinterval, to, troughcolor, variable, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2764 Widget.__init__(self, master, 'scale', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2765 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2766 """Get the current value as integer or float."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2767 value = self.tk.call(self._w, 'get')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2768 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2769 return getint(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2770 except ValueError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2771 return getdouble(value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2772 def set(self, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2773 """Set the value to VALUE."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2774 self.tk.call(self._w, 'set', value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2775 def coords(self, value=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2776 """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
2777 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
2778 given."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2779
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2780 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
2781 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2782 """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
2783 "though1" and "though2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2784 return self.tk.call(self._w, 'identify', x, y)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2785
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2786 class Scrollbar(Widget):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2787 """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
2788 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2789 """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
2790
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2791 Valid resource names: activebackground, activerelief,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2792 background, bd, bg, borderwidth, command, cursor,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2793 elementborderwidth, highlightbackground,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2794 highlightcolor, highlightthickness, jump, orient,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2795 relief, repeatdelay, repeatinterval, takefocus,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2796 troughcolor, width."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2797 Widget.__init__(self, master, 'scrollbar', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2798 def activate(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2799 """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
2800 INDEX can be "arrow1","slider" or "arrow2"."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2801 self.tk.call(self._w, 'activate', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2802 def delta(self, deltax, deltay):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2803 """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
2804 would be moved by DELTAX or DELTAY pixels."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2805 return getdouble(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2806 self.tk.call(self._w, 'delta', deltax, deltay))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2807 def fraction(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2808 """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
2809 position of X,Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2810 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
2811 def identify(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2812 """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
2813 "arrow1","slider","arrow2" or ""."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2814 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
2815 def get(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2816 """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
2817 of the slider position."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2818 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
2819 def set(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2820 """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
2821 lower ends as value between 0 and 1)."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2822 self.tk.call((self._w, 'set') + args)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2823
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2824
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2825
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
2826 class Text(Widget, XView, YView):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2827 """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
2828 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2829 """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
2830
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2831 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2832
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2833 background, borderwidth, cursor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2834 exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2835 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2836 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2837 insertborderwidth, insertofftime,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2838 insertontime, insertwidth, padx, pady,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2839 relief, selectbackground,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2840 selectborderwidth, selectforeground,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2841 setgrid, takefocus,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2842 xscrollcommand, yscrollcommand,
13133
15651490af34 Nils Fischbeck: added doc strings to everything. Martin von Loewis
Guido van Rossum <guido@python.org>
parents: 12953
diff changeset
2843
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2844 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2845
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2846 autoseparators, height, maxundo,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2847 spacing1, spacing2, spacing3,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2848 state, tabs, undo, width, wrap,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2849
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2850 """
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2851 Widget.__init__(self, master, 'text', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2852 def bbox(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2853 """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
2854 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
2855 return self._getints(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2856 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
2857 def tk_textSelectTo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2858 self.tk.call('tk_textSelectTo', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2859 def tk_textBackspace(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2860 self.tk.call('tk_textBackspace', self._w)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2861 def tk_textIndexCloser(self, a, b, c):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2862 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
2863 def tk_textResetAnchor(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2864 self.tk.call('tk_textResetAnchor', self._w, index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2865 def compare(self, index1, op, index2):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2866 """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
2867 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
2868 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2869 self._w, 'compare', index1, op, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2870 def debug(self, boolean=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2871 """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
2872 widget according to BOOLEAN."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2873 return self.tk.getboolean(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2874 self._w, 'debug', boolean))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2875 def delete(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2876 """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
2877 self.tk.call(self._w, 'delete', index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2878 def dlineinfo(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2879 """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
2880 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
2881 the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2882 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
2883 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
2884 """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
2885
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2886 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
2887 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
2888 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
2889 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
2890 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
2891
23241
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2892 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
2893 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
2894 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
2895 args = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2896 func_name = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2897 result = None
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2898 if not command:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2899 # 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
2900 # 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
2901 # 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
2902 # 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
2903 result = []
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2904 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
2905 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
2906 command = append_triple
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2907 try:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2908 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
2909 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
2910 args += ["-command", command]
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2911 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
2912 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
2913 args.append(index1)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2914 if index2:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2915 args.append(index2)
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2916 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
2917 return result
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2918 finally:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2919 if func_name:
30458a11b5e0 SF patch 546244 by John Williams: add Text.dump() method.
Guido van Rossum <guido@python.org>
parents: 22608
diff changeset
2920 self.deletecommand(func_name)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2921
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2922 ## new in tk8.4
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2923 def edit(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2924 """Internal method
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2925
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2926 This method controls the undo mechanism and
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2927 the modified flag. The exact behavior of the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2928 command depends on the option argument that
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2929 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
2930 of the command are currently supported:
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 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
2933 and edit_undo
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2934
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2935 """
47124
ac93edc396a6 #961805: fix Edit.text_modified().
Georg Brandl <georg@python.org>
parents: 47099
diff changeset
2936 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
2937
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2938 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
2939 """Get or Set the modified flag
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2940
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2941 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
2942 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
2943 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
2944 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
2945 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
2946 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2947 return self.edit("modified", arg)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2948
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2949 def edit_redo(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2950 """Redo the last undone edit
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2951
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2952 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
2953 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
2954 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
2955 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
2956 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2957 return self.edit("redo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2958
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2959 def edit_reset(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2960 """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
2961 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2962 return self.edit("reset")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2963
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2964 def edit_separator(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2965 """Inserts a separator (boundary) on the undo stack.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2966
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2967 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
2968 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2969 return self.edit("separator")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2970
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2971 def edit_undo(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2972 """Undoes the last edit action
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2973
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2974 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
2975 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
2976 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
2977 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
2978 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
2979 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
2980 return self.edit("undo")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2981
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2982 def get(self, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2983 """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
2984 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
2985 # (Image commands are new in 8.0)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2986 def image_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2987 """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
2988 if option[:1] != "-":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2989 option = "-" + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2990 if option[-1:] == "_":
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2991 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2992 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
2993 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
2994 """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
2995 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
2996 def image_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
2997 """Create an embedded image at INDEX."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2998 return self.tk.call(
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
2999 self._w, "image", "create", index,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3000 *self._options(cnf, kw))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3001 def image_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3002 """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
3003 return self.tk.call(self._w, "image", "names")
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3004 def index(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3005 """Return the index in the form line.char for INDEX."""
50147
76f189ea5509 Backport of r59654.
Martin v. Löwis <martin@v.loewis.de>
parents: 49632
diff changeset
3006 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
3007 def insert(self, index, chars, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3008 """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
3009 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
3010 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
3011 def mark_gravity(self, markName, direction=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3012 """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
3013 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
3014 return self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3015 (self._w, 'mark', 'gravity', markName, direction))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3016 def mark_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3017 """Return all mark names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3018 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3019 self._w, 'mark', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3020 def mark_set(self, markName, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3021 """Set mark MARKNAME before the character at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3022 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
3023 def mark_unset(self, *markNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3024 """Delete all marks in MARKNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3025 self.tk.call((self._w, 'mark', 'unset') + markNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3026 def mark_next(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3027 """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
3028 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
3029 def mark_previous(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3030 """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
3031 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
3032 def scan_mark(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3033 """Remember the current X, Y coordinates."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3034 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
3035 def scan_dragto(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3036 """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
3037 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
3038 scan_mark."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3039 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
3040 def search(self, pattern, index, stopindex=None,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3041 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
3042 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
3043 """Search PATTERN beginning from INDEX until STOPINDEX.
51482
e45525195317 Merged revisions 69461 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 49631
diff changeset
3044 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
3045 empty string."""
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3046 args = [self._w, 'search']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3047 if forwards: args.append('-forwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3048 if backwards: args.append('-backwards')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3049 if exact: args.append('-exact')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3050 if regexp: args.append('-regexp')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3051 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
3052 if elide: args.append('-elide')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3053 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
3054 if pattern and pattern[0] == '-': args.append('--')
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3055 args.append(pattern)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3056 args.append(index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3057 if stopindex: args.append(stopindex)
52056
4e7449348c1a Merged revisions 70218-70219 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 51482
diff changeset
3058 return str(self.tk.call(tuple(args)))
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3059 def see(self, index):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3060 """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
3061 self.tk.call(self._w, 'see', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3062 def tag_add(self, tagName, index1, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3063 """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
3064 Additional pairs of indices may follow in ARGS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3065 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3066 (self._w, 'tag', 'add', tagName, index1) + args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3067 def tag_unbind(self, tagName, sequence, funcid=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3068 """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
3069 function identified with FUNCID."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3070 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
3071 if funcid:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3072 self.deletecommand(funcid)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3073 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
3074 """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
3075
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3076 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
3077 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
3078 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
3079 return self._bind((self._w, 'tag', 'bind', tagName),
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3080 sequence, func, add)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3081 def tag_cget(self, tagName, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3082 """Return the value of OPTION for tag TAGNAME."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3083 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3084 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3085 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3086 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3087 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
3088 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
3089 """Configure a tag TAGNAME."""
25695
50013d1c6a43 Patch #612602: Streamline configure methods.
Martin v. Löwis <martin@v.loewis.de>
parents: 24357
diff changeset
3090 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
3091 tag_config = tag_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3092 def tag_delete(self, *tagNames):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3093 """Delete all tags in TAGNAMES."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3094 self.tk.call((self._w, 'tag', 'delete') + tagNames)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3095 def tag_lower(self, tagName, belowThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3096 """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
3097 than the priority of BELOWTHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3098 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
3099 def tag_names(self, index=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3100 """Return a list of all tag names."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3101 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3102 self.tk.call(self._w, 'tag', 'names', index))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3103 def tag_nextrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3104 """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
3105 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
3106 The text is searched forward from INDEX1."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3107 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3108 self._w, 'tag', 'nextrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3109 def tag_prevrange(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3110 """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
3111 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
3112 The text is searched backwards from INDEX1."""
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', 'prevrange', tagName, index1, index2))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3115 def tag_raise(self, tagName, aboveThis=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3116 """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
3117 than the priority of ABOVETHIS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3118 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3119 self._w, 'tag', 'raise', tagName, aboveThis)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3120 def tag_ranges(self, tagName):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3121 """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
3122 return self.tk.splitlist(self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3123 self._w, 'tag', 'ranges', tagName))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3124 def tag_remove(self, tagName, index1, index2=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3125 """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
3126 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3127 self._w, 'tag', 'remove', tagName, index1, index2)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3128 def window_cget(self, index, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3129 """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
3130 if option[:1] != '-':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3131 option = '-' + option
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3132 if option[-1:] == '_':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3133 option = option[:-1]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3134 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
3135 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
3136 """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
3137 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
3138 window_config = window_configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3139 def window_create(self, index, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3140 """Create a window at INDEX."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3141 self.tk.call(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3142 (self._w, 'window', 'create', index)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3143 + self._options(cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3144 def window_names(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3145 """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
3146 return self.tk.splitlist(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3147 self.tk.call(self._w, 'window', 'names'))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3148 def yview_pickplace(self, *what):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3149 """Obsolete function, use see."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3150 self.tk.call((self._w, 'yview', '-pickplace') + what)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3151
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3152
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
3153 class _setit:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3154 """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
3155 def __init__(self, var, value, callback=None):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3156 self.__value = value
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3157 self.__var = var
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3158 self.__callback = callback
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3159 def __call__(self, *args):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3160 self.__var.set(self.__value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3161 if self.__callback:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3162 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
3163
938be7a3106f (Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents: 4358
diff changeset
3164 class OptionMenu(Menubutton):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3165 """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
3166 def __init__(self, master, variable, value, *values, **kwargs):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3167 """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
3168 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
3169 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
3170 keyword argument command."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3171 kw = {"borderwidth": 2, "textvariable": variable,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3172 "indicatoron": 1, "relief": RAISED, "anchor": "c",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3173 "highlightthickness": 2}
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3174 Widget.__init__(self, master, "menubutton", kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3175 self.widgetName = 'tk_optionMenu'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3176 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
3177 self.menuname = menu._w
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3178 # 'command' is the only supported keyword
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3179 callback = kwargs.get('command')
56436
684960fb1cbf replace has_key with 'in' operator
Benjamin Peterson <benjamin@python.org>
parents: 56435
diff changeset
3180 if 'command' in kwargs:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3181 del kwargs['command']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3182 if kwargs:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3183 raise TclError, 'unknown option -'+kwargs.keys()[0]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3184 menu.add_command(label=value,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3185 command=_setit(variable, value, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3186 for v in values:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3187 menu.add_command(label=v,
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3188 command=_setit(variable, v, callback))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3189 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
3190
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3191 def __getitem__(self, name):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3192 if name == 'menu':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3193 return self.__menu
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3194 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
3195
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3196 def destroy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3197 """Destroy this widget and the associated menu."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3198 Menubutton.destroy(self)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3199 self.__menu = None
3067
6ec820db2ffa added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents: 2968
diff changeset
3200
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3201 class Image:
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3202 """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
3203 _last_id = 0
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3204 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
3205 self.name = None
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3206 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3207 master = _default_root
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3208 if not master:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3209 raise RuntimeError, 'Too early to create image'
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3210 self.tk = master.tk
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3211 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
3212 Image._last_id += 1
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 29729
diff changeset
3213 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
3214 # 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
3215 # 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
3216 if name[0] == '-': name = '_' + name[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3217 if kw and cnf: cnf = _cnfmerge((cnf, kw))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3218 elif kw: cnf = kw
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3219 options = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3220 for k, v in cnf.items():
56435
57ee0793e462 replace callable()
Benjamin Peterson <benjamin@python.org>
parents: 55641
diff changeset
3221 if hasattr(v, '__call__'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3222 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3223 options = options + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3224 self.tk.call(('image', 'create', imgtype, name,) + options)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3225 self.name = name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3226 def __str__(self): return self.name
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3227 def __del__(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3228 if self.name:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3229 try:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3230 self.tk.call('image', 'delete', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3231 except TclError:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3232 # May happen if the root was destroyed
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3233 pass
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3234 def __setitem__(self, key, value):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3235 self.tk.call(self.name, 'configure', '-'+key, value)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3236 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3237 return self.tk.call(self.name, 'configure', '-'+key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3238 def configure(self, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3239 """Configure the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3240 res = ()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3241 for k, v in _cnfmerge(kw).items():
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3242 if v is not None:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3243 if k[-1] == '_': k = k[:-1]
56435
57ee0793e462 replace callable()
Benjamin Peterson <benjamin@python.org>
parents: 55641
diff changeset
3244 if hasattr(v, '__call__'):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3245 v = self._register(v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3246 res = res + ('-'+k, v)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3247 self.tk.call((self.name, 'config') + res)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3248 config = configure
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3249 def height(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3250 """Return the height of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3251 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3252 self.tk.call('image', 'height', self.name))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3253 def type(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3254 """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
3255 return self.tk.call('image', 'type', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3256 def width(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3257 """Return the width of the image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3258 return getint(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3259 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
3260
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3261 class PhotoImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3262 """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
3263 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
3264 """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
3265
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3266 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
3267 width."""
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3268 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
3269 def blank(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3270 """Display a transparent image."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3271 self.tk.call(self.name, 'blank')
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3272 def cget(self, option):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3273 """Return the value of OPTION."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3274 return self.tk.call(self.name, 'cget', '-' + option)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3275 # XXX config
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3276 def __getitem__(self, key):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3277 return self.tk.call(self.name, 'cget', '-' + key)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3278 # XXX copy -from, -to, ...?
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3279 def copy(self):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3280 """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
3281 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3282 self.tk.call(destImage, 'copy', self.name)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3283 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3284 def zoom(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3285 """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
3286 but zoom it with X and Y."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3287 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3288 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3289 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
3290 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3291 def subsample(self,x,y=''):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3292 """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
3293 but use only every Xth or Yth pixel."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3294 destImage = PhotoImage()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3295 if y=='': y=x
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3296 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
3297 return destImage
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3298 def get(self, x, y):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3299 """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
3300 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
3301 def put(self, data, to=None):
55049
74c0a78114ae Merged revisions 69846 via svnmerge from
Jesus Cea <jcea@jcea.es>
parents: 52056
diff changeset
3302 """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
3303 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
3304 args = (self.name, 'put', data)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3305 if to:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3306 if to[0] == '-to':
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3307 to = to[1:]
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3308 args = args + ('-to',) + tuple(to)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3309 self.tk.call(args)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3310 # XXX read
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3311 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
3312 """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
3313 position FROM_COORDS."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3314 args = (self.name, 'write', filename)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3315 if format:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3316 args = args + ('-format', format)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3317 if from_coords:
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3318 args = args + ('-from',) + tuple(from_coords)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3319 self.tk.call(args)
2884
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3320
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3321 class BitmapImage(Image):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3322 """Widget which can display a bitmap."""
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3323 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
3324 """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
3325
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3326 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
3327 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
3328
e006ed88b4aa keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents: 2830
diff changeset
3329 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
3330 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
3331
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3332
55640
b7a571d4aaa7 Issue #1135: Add the XView and YView mix-ins to avoid duplicating
Guilherme Polo <ggpolo@gmail.com>
parents: 54474
diff changeset
3333 class Spinbox(Widget, XView):
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3334 """spinbox widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3335 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
3336 """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
3337
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3338 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3339
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3340 activebackground, background, borderwidth,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3341 cursor, exportselection, font, foreground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3342 highlightbackground, highlightcolor,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3343 highlightthickness, insertbackground,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3344 insertborderwidth, insertofftime,
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3345 insertontime, insertwidth, justify, relief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3346 repeatdelay, repeatinterval,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3347 selectbackground, selectborderwidth
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3348 selectforeground, takefocus, textvariable
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3349 xscrollcommand.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3350
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3351 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3352
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3353 buttonbackground, buttoncursor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3354 buttondownrelief, buttonuprelief,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3355 command, disabledbackground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3356 disabledforeground, format, from,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3357 invalidcommand, increment,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3358 readonlybackground, state, to,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3359 validate, validatecommand values,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3360 width, wrap,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3361 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3362 Widget.__init__(self, master, 'spinbox', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3363
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3364 def bbox(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3365 """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
3366 rectangle which encloses the character given by index.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3367
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3368 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
3369 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
3370 area covered by the character (in pixels relative
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3371 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
3372 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
3373 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
3374 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
3375 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3376 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
3377
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3378 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
3379 """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
3380
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3381 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
3382 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
3383 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
3384 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
3385 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
3386 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3387 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
3388
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3389 def get(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3390 """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
3391 return self.tk.call(self._w, 'get')
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3392
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3393 def icursor(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3394 """Alter the position of the insertion cursor.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3395
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3396 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
3397 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
3398 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3399 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
3400
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3401 def identify(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3402 """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
3403
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3404 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
3405 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3406 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
3407
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3408 def index(self, index):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3409 """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
3410 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3411 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
3412
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3413 def insert(self, index, s):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3414 """Insert string s at index
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3415
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3416 Returns an empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3417 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3418 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
3419
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3420 def invoke(self, element):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3421 """Causes the specified element to be invoked
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3422
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3423 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
3424 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
3425 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3426 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
3427
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3428 def scan(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3429 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3430 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3431 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
3432
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3433 def scan_mark(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3434 """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
3435
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3436 used in conjunction with later scan dragto commands.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3437 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
3438 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
3439 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3440 return self.scan("mark", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3441
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3442 def scan_dragto(self, x):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3443 """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
3444 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
3445
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3446 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
3447 difference in x-coordinates. This command is typically
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3448 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
3449 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
3450 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
3451 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3452 return self.scan("dragto", x)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3453
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3454 def selection(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3455 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3456 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3457 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
3458
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3459 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
3460 """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
3461 given by index,
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 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
3464 (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
3465 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
3466 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
3467 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
3468 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
3469 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
3470 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3471 return self.selection("adjust", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3472
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3473 def selection_clear(self):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3474 """Clear the selection
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3475
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3476 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
3477 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
3478 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3479 return self.selection("clear")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3480
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3481 def selection_element(self, element=None):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3482 """Sets or gets the currently selected element.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3483
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3484 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
3485 displayed depressed
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3486 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3487 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
3488
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3489 ###########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3490
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3491 class LabelFrame(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3492 """labelframe widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3493 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
3494 """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
3495
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3496 STANDARD OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3497
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3498 borderwidth, cursor, font, foreground,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3499 highlightbackground, highlightcolor,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3500 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
3501 takefocus, text
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3502
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3503 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3504
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3505 background, class, colormap, container,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3506 height, labelanchor, labelwidget,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3507 visual, width
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3508 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3509 Widget.__init__(self, master, 'labelframe', cnf, kw)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3510
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3511 ########################################################################
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3512
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3513 class PanedWindow(Widget):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3514 """panedwindow widget."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3515 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
3516 """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
3517
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3518 STANDARD OPTIONS
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 background, borderwidth, cursor, height,
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3521 orient, relief, width
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3522
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3523 WIDGET-SPECIFIC OPTIONS
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3524
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3525 handlepad, handlesize, opaqueresize,
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3526 sashcursor, sashpad, sashrelief,
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3527 sashwidth, showhandle,
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 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
3530
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3531 def add(self, child, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3532 """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
3533
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3534 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
3535 followed by pairs of arguments that specify how to
54474
5db0556ed122 Improved PanedWindow.add's docstring. 'subcomand' is a Tcl term, and the possible options and values are the same accepted by paneconfigure (not configure).
Guilherme Polo <ggpolo@gmail.com>
parents: 52054
diff changeset
3536 manage the windows. The possible options and values
5db0556ed122 Improved PanedWindow.add's docstring. 'subcomand' is a Tcl term, and the possible options and values are the same accepted by paneconfigure (not configure).
Guilherme Polo <ggpolo@gmail.com>
parents: 52054
diff changeset
3537 are the ones accepted by the paneconfigure method.
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3538 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3539 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
3540
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3541 def remove(self, child):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3542 """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
3543
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3544 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
3545 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3546 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
3547 forget=remove
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3548
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3549 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
3550 """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
3551
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3552 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
3553 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
3554 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
3555 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
3556 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
3557 an empty list.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3558 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3559 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
3560
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3561 def proxy(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3562 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3563 return self._getints(
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3564 self.tk.call((self._w, 'proxy') + args)) or ()
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 proxy_coord(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3567 """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
3568 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3569 return self.proxy("coord")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3570
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3571 def proxy_forget(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3572 """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
3573 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3574 return self.proxy("forget")
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3575
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3576 def proxy_place(self, x, y):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3577 """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
3578 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3579 return self.proxy("place", x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3580
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3581 def sash(self, *args):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3582 """Internal function."""
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3583 return self._getints(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3584 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
3585
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3586 def sash_coord(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3587 """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
3588
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3589 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
3590 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
3591 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
3592 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
3593 difference between the given coordinates and the coordinates
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3594 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
3595 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
3596 empty string.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3597 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3598 return self.sash("coord", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3599
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3600 def sash_mark(self, index):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3601 """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
3602
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3603 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
3604 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3605 return self.sash("mark", index)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3606
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3607 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
3608 """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
3609 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3610 return self.sash("place", index, x, y)
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3611
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3612 def panecget(self, child, option):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3613 """Query a management option for window.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3614
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3615 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
3616 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3617 return self.tk.call(
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3618 (self._w, 'panecget') + (child, '-'+option))
28513
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 def paneconfigure(self, tagOrId, cnf=None, **kw):
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3621 """Query or modify the management options for window.
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3622
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3623 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
3624 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
3625 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
3626 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
3627 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
3628 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
3629 specified, then the command modifies the given widget
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3630 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
3631 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
3632 are supported:
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3633
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3634 after window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3635 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
3636 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
3637 before window
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3638 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
3639 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
3640 height size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3641 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
3642 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
3643 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
3644 specified, then the height requested internally by the
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3645 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
3646 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
3647 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
3648 minsize n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3649 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
3650 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
3651 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
3652 for horizontal panedwindows, the y dimension for
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3653 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
3654 Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3655 padx n
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3656 Specifies a non-negative value indicating how much
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3657 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
3658 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
3659 accepted by Tk_GetPixels.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3660 pady n
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3661 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
3662 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
3663 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
3664 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 sticky style
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3666 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
3667 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
3668 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
3669 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
3670 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
3671 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
3672 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
3673 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
3674 (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
3675 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
3676 its cavity.
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3677 width size
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3678 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
3679 the outer dimension of the window including its
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3680 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
3681 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
3682 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
3683 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
3684 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
3685 Tk_GetPixels.
28513
90c77b8af1a4 SF patch #701494: more apply removals
Raymond Hettinger <python@rcn.com>
parents: 28435
diff changeset
3686
25754
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3687 """
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3688 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
3689 cnf = {}
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3690 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
3691 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
3692 'paneconfigure', tagOrId)):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3693 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
3694 return cnf
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3695 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
3696 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
3697 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
3698 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
3699 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
3700 self._options(cnf, kw))
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3701 paneconfig = paneconfigure
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3702
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3703 def panes(self):
75cbec40db7d Patch #621205: Tkinter updates for tk8.4.
Martin v. Löwis <martin@v.loewis.de>
parents: 25695
diff changeset
3704 """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
3705 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
3706
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
3707 ######################################################################
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3708 # 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
3709
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3710 class Studbutton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3711 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3712 Widget.__init__(self, master, 'studbutton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3713 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3714 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3715 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3716 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
3717
bb61816e1dab Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents: 1687
diff changeset
3718 class Tributton(Button):
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3719 def __init__(self, master=None, cnf={}, **kw):
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3720 Widget.__init__(self, master, 'tributton', cnf, kw)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3721 self.bind('<Any-Enter>', self.tkButtonEnter)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3722 self.bind('<Any-Leave>', self.tkButtonLeave)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3723 self.bind('<1>', self.tkButtonDown)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3724 self.bind('<ButtonRelease-1>', self.tkButtonUp)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3725 self['fg'] = self['bg']
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3726 self['activebackground'] = self['bg']
3551
e8a2a5e4c7b0 Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents: 3246
diff changeset
3727
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3728 ######################################################################
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3729 # Test:
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3730
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3731 def _test():
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3732 root = Tk()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3733 text = "This is Tcl/Tk version %s" % TclVersion
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3734 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
3735 try:
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3736 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
3737 "iso-8859-1")
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3738 except NameError:
9c1e68984027 -- use explicit conversion instead of u-string literal in the test
Fredrik Lundh <fredrik@pythonware.com>
parents: 13904
diff changeset
3739 pass # no unicode support
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3740 label = Label(root, text=text)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3741 label.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3742 test = Button(root, text="Click me!",
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3743 command=lambda root=root: root.test.configure(
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3744 text="[%s]" % root.test['text']))
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3745 test.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3746 root.test = test
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3747 quit = Button(root, text="QUIT", command=root.destroy)
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3748 quit.pack()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3749 # 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
3750 # up on top on Windows...
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3751 root.iconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3752 root.update()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3753 root.deiconify()
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3754 root.mainloop()
4103
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3755
a5a82666977b Added a small test program.
Guido van Rossum <guido@python.org>
parents: 3952
diff changeset
3756 if __name__ == '__main__':
13903
0ac919ca8e69 -- untabification (use "diff -b" to verify)
Fredrik Lundh <fredrik@pythonware.com>
parents: 13620
diff changeset
3757 _test()