Mercurial > cpython-lru_cache-weakref
annotate Lib/lib-tk/Tkinter.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 07e1aab23115 |
| children | e742e41a4b11 |
| rev | line source |
|---|---|
| 1664 | 1 # Tkinter.py -- Tk/Tcl widget wrappers |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
2 |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
3 __version__ = "$Revision$" |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
4 |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
5 import _tkinter # If this fails your Python is not configured for Tk |
|
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
6 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
|
7 TclError = _tkinter.TclError |
|
2577
498dad8045d3
add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents:
2045
diff
changeset
|
8 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
|
9 from Tkconstants import * |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
10 import string; _string = string; del string |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
11 |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
12 TkVersion = _string.atof(_tkinter.TK_VERSION) |
|
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
13 TclVersion = _string.atof(_tkinter.TCL_VERSION) |
| 1664 | 14 |
|
3552
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
15 ###################################################################### |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
16 # Since the values of file event masks changed from Tk 4.0 to Tk 4.1, |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
17 # they are defined here (and not in Tkconstants): |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
18 ###################################################################### |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
19 if TkVersion >= 4.1: |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
20 READABLE = 2 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
21 WRITABLE = 4 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
22 EXCEPTION = 8 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
23 else: |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
24 READABLE = 1 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
25 WRITABLE = 2 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
26 EXCEPTION = 4 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
27 |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
28 |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
29 def _flatten(tuple): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
30 res = () |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
31 for item in tuple: |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
32 if type(item) in (TupleType, ListType): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
33 res = res + _flatten(item) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
34 elif item is not None: |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
35 res = res + (item,) |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
36 return res |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
37 |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
38 def _cnfmerge(cnfs): |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
39 if type(cnfs) is DictionaryType: |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
40 return cnfs |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
41 elif type(cnfs) in (NoneType, StringType): |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
42 return cnfs |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
43 else: |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
44 cnf = {} |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
45 for c in _flatten(cnfs): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
46 for k, v in c.items(): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
47 cnf[k] = v |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
48 return cnf |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
49 |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
50 class Event: |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
51 pass |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
52 |
|
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
|
53 _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
|
54 |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
55 def _tkerror(err): |
| 1664 | 56 pass |
| 57 | |
|
1714
db0eaef42cb9
Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents:
1709
diff
changeset
|
58 def _exit(code='0'): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
59 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
|
60 |
|
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
|
61 _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
|
62 class Variable: |
|
4211
4a93cc7e7fb6
Add initial values to variables to avoid crash in __del__
Guido van Rossum <guido@python.org>
parents:
4115
diff
changeset
|
63 _default = "" |
|
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
|
64 def __init__(self, master=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
|
65 global _default_root |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
66 global _varnum |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
67 if master: |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
68 self._tk = master.tk |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
69 else: |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
70 self._tk = _default_root.tk |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
71 self._name = 'PY_VAR' + `_varnum` |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
72 _varnum = _varnum + 1 |
|
4211
4a93cc7e7fb6
Add initial values to variables to avoid crash in __del__
Guido van Rossum <guido@python.org>
parents:
4115
diff
changeset
|
73 self.set(self._default) |
|
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
|
74 def __del__(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
75 self._tk.globalunsetvar(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
|
76 def __str__(self): |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
77 return self._name |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
78 def set(self, value): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
79 return self._tk.globalsetvar(self._name, 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
|
80 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
81 class StringVar(Variable): |
|
4211
4a93cc7e7fb6
Add initial values to variables to avoid crash in __del__
Guido van Rossum <guido@python.org>
parents:
4115
diff
changeset
|
82 _default = "" |
|
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
|
83 def __init__(self, master=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
|
84 Variable.__init__(self, master) |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
85 def get(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
86 return 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
|
87 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
88 class IntVar(Variable): |
|
4832
50f4983b6b79
Change the default values for IntVar and DoubleVar to numbers (they
Guido van Rossum <guido@python.org>
parents:
4693
diff
changeset
|
89 _default = 0 |
|
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
|
90 def __init__(self, master=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
|
91 Variable.__init__(self, master) |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
92 def get(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
93 return self._tk.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
|
94 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
95 class DoubleVar(Variable): |
|
4832
50f4983b6b79
Change the default values for IntVar and DoubleVar to numbers (they
Guido van Rossum <guido@python.org>
parents:
4693
diff
changeset
|
96 _default = 0.0 |
|
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
|
97 def __init__(self, master=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
|
98 Variable.__init__(self, master) |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
99 def get(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
100 return self._tk.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
|
101 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
102 class BooleanVar(Variable): |
|
4211
4a93cc7e7fb6
Add initial values to variables to avoid crash in __del__
Guido van Rossum <guido@python.org>
parents:
4115
diff
changeset
|
103 _default = "false" |
|
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
|
104 def __init__(self, master=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
|
105 Variable.__init__(self, master) |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
106 def get(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
107 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
|
108 |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
109 def mainloop(n=0): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
110 _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
|
111 |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
112 def getint(s): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
113 return _default_root.tk.getint(s) |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
114 |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
115 def getdouble(s): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
116 return _default_root.tk.getdouble(s) |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
117 |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
118 def getboolean(s): |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
119 return _default_root.tk.getboolean(s) |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
120 |
| 1664 | 121 class Misc: |
|
5400
7918e8739148
Misc.__init__(): Removed method, replaced with class attribute (which
Fred Drake <fdrake@acm.org>
parents:
5323
diff
changeset
|
122 _tclCommands = None |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
123 def destroy(self): |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
124 if self._tclCommands is not None: |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
125 for name in self._tclCommands: |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
126 #print '- Tkinter: deleted command', name |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
127 self.tk.deletecommand(name) |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
128 self._tclCommands = None |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
129 def deletecommand(self, name): |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
130 #print '- Tkinter: deleted command', name |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
131 self.tk.deletecommand(name) |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
132 index = self._tclCommands.index(name) |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
133 del self._tclCommands[index] |
| 1664 | 134 def tk_strictMotif(self, boolean=None): |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
135 return self.tk.getboolean(self.tk.call( |
| 1664 | 136 'set', 'tk_strictMotif', boolean)) |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
137 def tk_bisque(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
138 self.tk.call('tk_bisque') |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
139 def tk_setPalette(self, *args, **kw): |
|
4355
eb455d99ba98
(Tkinter.py): Fixed dumb typo in Misc.tk_setPalette().
Fred Drake <fdrake@acm.org>
parents:
4338
diff
changeset
|
140 apply(self.tk.call, ('tk_setPalette',) |
|
eb455d99ba98
(Tkinter.py): Fixed dumb typo in Misc.tk_setPalette().
Fred Drake <fdrake@acm.org>
parents:
4338
diff
changeset
|
141 + _flatten(args) + _flatten(kw.items())) |
|
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
|
142 def tk_menuBar(self, *args): |
|
4255
64704d36b198
simpler version of the previous fix
Guido van Rossum <guido@python.org>
parents:
4254
diff
changeset
|
143 pass # obsolete since Tk 4.0 |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
144 def wait_variable(self, name='PY_VAR'): |
| 1664 | 145 self.tk.call('tkwait', 'variable', name) |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
146 waitvar = wait_variable # XXX b/w compat |
|
1694
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
147 def wait_window(self, window=None): |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
148 if window == None: |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
149 window = self |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
150 self.tk.call('tkwait', 'window', window._w) |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
151 def wait_visibility(self, window=None): |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
152 if window == None: |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
153 window = self |
|
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
154 self.tk.call('tkwait', 'visibility', window._w) |
|
1688
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
155 def setvar(self, name='PY_VAR', value='1'): |
| 1664 | 156 self.tk.setvar(name, 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
|
157 def getvar(self, name='PY_VAR'): |
|
1666
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
158 return self.tk.getvar(name) |
|
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
159 def getint(self, s): |
|
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
160 return self.tk.getint(s) |
|
1669
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
161 def getdouble(self, s): |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
162 return self.tk.getdouble(s) |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
163 def getboolean(self, s): |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
164 return self.tk.getboolean(s) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
165 def focus_set(self): |
| 1664 | 166 self.tk.call('focus', self._w) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
167 focus = focus_set # XXX b/w compat? |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
168 def focus_force(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
169 self.tk.call('focus', '-force', self._w) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
170 def focus_get(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
171 name = self.tk.call('focus') |
|
3952
7ee1b100ed29
stupid typo in latest fix ('Name' should be 'name')
Guido van Rossum <guido@python.org>
parents:
3876
diff
changeset
|
172 if name == 'none' or not name: return None |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
173 return self._nametowidget(name) |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
174 def focus_displayof(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
175 name = self.tk.call('focus', '-displayof', self._w) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
176 if name == 'none' or not name: return None |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
177 return self._nametowidget(name) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
178 def focus_lastfor(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
179 name = self.tk.call('focus', '-lastfor', self._w) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
180 if name == 'none' or not name: return None |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
181 return self._nametowidget(name) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
182 def tk_focusFollowsMouse(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
183 self.tk.call('tk_focusFollowsMouse') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
184 def tk_focusNext(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
185 name = self.tk.call('tk_focusNext', self._w) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
186 if not name: return None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
187 return self._nametowidget(name) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
188 def tk_focusPrev(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
189 name = self.tk.call('tk_focusPrev', self._w) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
190 if not name: return None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
191 return self._nametowidget(name) |
| 1664 | 192 def after(self, ms, func=None, *args): |
| 193 if not func: | |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
194 # I'd rather use time.sleep(ms*0.001) |
| 1664 | 195 self.tk.call('after', ms) |
| 196 else: | |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
197 # XXX Disgusting hack to clean up after calling func |
|
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
198 tmp = [] |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
199 def callit(func=func, args=args, self=self, tmp=tmp): |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
200 try: |
|
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
201 apply(func, args) |
|
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
202 finally: |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
203 self.deletecommand(tmp[0]) |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
204 name = self._register(callit) |
|
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
205 tmp.append(name) |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
206 return self.tk.call('after', ms, name) |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
207 def after_idle(self, func, *args): |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
208 return apply(self.after, ('idle', func) + args) |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
209 def after_cancel(self, id): |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
210 self.tk.call('after', 'cancel', id) |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
211 def bell(self, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
212 apply(self.tk.call, ('bell',) + self._displayof(displayof)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
213 # Clipboard handling: |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
214 def clipboard_clear(self, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
215 if not kw.has_key('displayof'): kw['displayof'] = self._w |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
216 apply(self.tk.call, |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
217 ('clipboard', 'clear') + self._options(kw)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
218 def clipboard_append(self, string, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
219 if not kw.has_key('displayof'): kw['displayof'] = self._w |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
220 apply(self.tk.call, |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
221 ('clipboard', 'append') + self._options(kw) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
222 + ('--', string)) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
223 # XXX grab current w/o window argument |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
224 def grab_current(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
225 name = self.tk.call('grab', 'current', self._w) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
226 if not name: return None |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
227 return self._nametowidget(name) |
| 1664 | 228 def grab_release(self): |
| 229 self.tk.call('grab', 'release', self._w) | |
| 230 def grab_set(self): | |
| 231 self.tk.call('grab', 'set', self._w) | |
| 232 def grab_set_global(self): | |
| 233 self.tk.call('grab', 'set', '-global', self._w) | |
| 234 def grab_status(self): | |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
235 status = self.tk.call('grab', 'status', self._w) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
236 if status == 'none': status = None |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
237 return status |
| 1664 | 238 def lower(self, belowThis=None): |
| 239 self.tk.call('lower', self._w, belowThis) | |
|
1990
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
240 def option_add(self, pattern, value, priority = None): |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
241 self.tk.call('option', 'add', pattern, value, priority) |
|
1990
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
242 def option_clear(self): |
|
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
243 self.tk.call('option', 'clear') |
|
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
244 def option_get(self, name, className): |
|
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
245 return self.tk.call('option', 'get', self._w, name, className) |
|
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
246 def option_readfile(self, fileName, priority = None): |
|
4e6056d980e1
added option interface
Guido van Rossum <guido@python.org>
parents:
1853
diff
changeset
|
247 self.tk.call('option', 'readfile', fileName, priority) |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
248 def selection_clear(self, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
249 if not kw.has_key('displayof'): kw['displayof'] = self._w |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
250 apply(self.tk.call, ('selection', 'clear') + self._options(kw)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
251 def selection_get(self, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
252 if not kw.has_key('displayof'): kw['displayof'] = self._w |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
253 return apply(self.tk.call, |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
254 ('selection', 'get') + self._options(kw)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
255 def selection_handle(self, command, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
256 name = self._register(command) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
257 apply(self.tk.call, |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
258 ('selection', 'handle') + self._options(kw) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
259 + (self._w, name)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
260 def selection_own(self, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
261 "Become owner of X selection." |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
262 apply(self.tk.call, |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
263 ('selection', 'own') + self._options(kw) + (self._w,)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
264 def selection_own_get(self, **kw): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
265 "Find owner of X selection." |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
266 if not kw.has_key('displayof'): kw['displayof'] = self._w |
|
5026
b5a1bb2d17fa
Avoid traceback in selection_own_get() when no Tk widget owns the
Guido van Rossum <guido@python.org>
parents:
4922
diff
changeset
|
267 name = apply(self.tk.call, |
|
b5a1bb2d17fa
Avoid traceback in selection_own_get() when no Tk widget owns the
Guido van Rossum <guido@python.org>
parents:
4922
diff
changeset
|
268 ('selection', 'own') + self._options(kw)) |
|
b5a1bb2d17fa
Avoid traceback in selection_own_get() when no Tk widget owns the
Guido van Rossum <guido@python.org>
parents:
4922
diff
changeset
|
269 if not name: return None |
|
b5a1bb2d17fa
Avoid traceback in selection_own_get() when no Tk widget owns the
Guido van Rossum <guido@python.org>
parents:
4922
diff
changeset
|
270 return self._nametowidget(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
|
271 def send(self, interp, cmd, *args): |
| 1664 | 272 return apply(self.tk.call, ('send', interp, cmd) + args) |
|
1666
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
273 def lower(self, belowThis=None): |
|
4277
befdf0dc096b
Implement lower by calling lower, not lift.
Guido van Rossum <guido@python.org>
parents:
4255
diff
changeset
|
274 self.tk.call('lower', self._w, belowThis) |
|
1666
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
275 def tkraise(self, aboveThis=None): |
|
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
276 self.tk.call('raise', self._w, aboveThis) |
|
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
277 lift = tkraise |
| 1664 | 278 def colormodel(self, value=None): |
| 279 return self.tk.call('tk', 'colormodel', self._w, value) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
280 def winfo_atom(self, name, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
281 args = ('winfo', 'atom') + self._displayof(displayof) + (name,) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
282 return self.tk.getint(apply(self.tk.call, args)) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
283 def winfo_atomname(self, id, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
284 args = ('winfo', 'atomname') \ |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
285 + self._displayof(displayof) + (id,) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
286 return apply(self.tk.call, args) |
| 1664 | 287 def winfo_cells(self): |
| 288 return self.tk.getint( | |
| 289 self.tk.call('winfo', 'cells', self._w)) | |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
290 def winfo_children(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
291 return map(self._nametowidget, |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
292 self.tk.splitlist(self.tk.call( |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
293 'winfo', 'children', self._w))) |
| 1664 | 294 def winfo_class(self): |
| 295 return self.tk.call('winfo', 'class', self._w) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
296 def winfo_colormapfull(self): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
297 return self.tk.getboolean( |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
298 self.tk.call('winfo', 'colormapfull', self._w)) |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
299 def winfo_containing(self, rootX, rootY, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
300 args = ('winfo', 'containing') \ |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
301 + self._displayof(displayof) + (rootX, rootY) |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
302 name = apply(self.tk.call, args) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
303 if not name: return None |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
304 return self._nametowidget(name) |
| 1664 | 305 def winfo_depth(self): |
| 306 return self.tk.getint(self.tk.call('winfo', 'depth', self._w)) | |
| 307 def winfo_exists(self): | |
| 308 return self.tk.getint( | |
| 309 self.tk.call('winfo', 'exists', self._w)) | |
| 310 def winfo_fpixels(self, number): | |
| 311 return self.tk.getdouble(self.tk.call( | |
| 312 'winfo', 'fpixels', self._w, number)) | |
| 313 def winfo_geometry(self): | |
| 314 return self.tk.call('winfo', 'geometry', self._w) | |
| 315 def winfo_height(self): | |
| 316 return self.tk.getint( | |
| 317 self.tk.call('winfo', 'height', self._w)) | |
| 318 def winfo_id(self): | |
| 319 return self.tk.getint( | |
| 320 self.tk.call('winfo', 'id', self._w)) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
321 def winfo_interps(self, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
322 args = ('winfo', 'interps') + self._displayof(displayof) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
323 return self.tk.splitlist(apply(self.tk.call, args)) |
| 1664 | 324 def winfo_ismapped(self): |
| 325 return self.tk.getint( | |
| 326 self.tk.call('winfo', 'ismapped', self._w)) | |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
327 def winfo_manager(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
328 return self.tk.call('winfo', 'manager', self._w) |
| 1664 | 329 def winfo_name(self): |
| 330 return self.tk.call('winfo', 'name', self._w) | |
| 331 def winfo_parent(self): | |
| 332 return self.tk.call('winfo', 'parent', self._w) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
333 def winfo_pathname(self, id, displayof=0): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
334 args = ('winfo', 'pathname') \ |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
335 + self._displayof(displayof) + (id,) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
336 return apply(self.tk.call, args) |
| 1664 | 337 def winfo_pixels(self, number): |
| 338 return self.tk.getint( | |
| 339 self.tk.call('winfo', 'pixels', self._w, number)) | |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
340 def winfo_pointerx(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
341 return self.tk.getint( |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
342 self.tk.call('winfo', 'pointerx', self._w)) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
343 def winfo_pointerxy(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
344 return self._getints( |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
345 self.tk.call('winfo', 'pointerxy', self._w)) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
346 def winfo_pointery(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
347 return self.tk.getint( |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
348 self.tk.call('winfo', 'pointery', self._w)) |
| 1664 | 349 def winfo_reqheight(self): |
| 350 return self.tk.getint( | |
| 351 self.tk.call('winfo', 'reqheight', self._w)) | |
| 352 def winfo_reqwidth(self): | |
| 353 return self.tk.getint( | |
| 354 self.tk.call('winfo', 'reqwidth', self._w)) | |
| 355 def winfo_rgb(self, color): | |
| 356 return self._getints( | |
| 357 self.tk.call('winfo', 'rgb', self._w, color)) | |
| 358 def winfo_rootx(self): | |
| 359 return self.tk.getint( | |
| 360 self.tk.call('winfo', 'rootx', self._w)) | |
| 361 def winfo_rooty(self): | |
| 362 return self.tk.getint( | |
| 363 self.tk.call('winfo', 'rooty', self._w)) | |
| 364 def winfo_screen(self): | |
| 365 return self.tk.call('winfo', 'screen', self._w) | |
| 366 def winfo_screencells(self): | |
| 367 return self.tk.getint( | |
| 368 self.tk.call('winfo', 'screencells', self._w)) | |
| 369 def winfo_screendepth(self): | |
| 370 return self.tk.getint( | |
| 371 self.tk.call('winfo', 'screendepth', self._w)) | |
| 372 def winfo_screenheight(self): | |
| 373 return self.tk.getint( | |
| 374 self.tk.call('winfo', 'screenheight', self._w)) | |
| 375 def winfo_screenmmheight(self): | |
| 376 return self.tk.getint( | |
| 377 self.tk.call('winfo', 'screenmmheight', self._w)) | |
| 378 def winfo_screenmmwidth(self): | |
| 379 return self.tk.getint( | |
| 380 self.tk.call('winfo', 'screenmmwidth', self._w)) | |
| 381 def winfo_screenvisual(self): | |
| 382 return self.tk.call('winfo', 'screenvisual', self._w) | |
| 383 def winfo_screenwidth(self): | |
| 384 return self.tk.getint( | |
| 385 self.tk.call('winfo', 'screenwidth', self._w)) | |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
386 def winfo_server(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
387 return self.tk.call('winfo', 'server', self._w) |
| 1664 | 388 def winfo_toplevel(self): |
|
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
|
389 return self._nametowidget(self.tk.call( |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
390 'winfo', 'toplevel', self._w)) |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
391 def winfo_viewable(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
392 return self.tk.getint( |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
393 self.tk.call('winfo', 'viewable', self._w)) |
| 1664 | 394 def winfo_visual(self): |
| 395 return self.tk.call('winfo', 'visual', self._w) | |
|
4693
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
396 def winfo_visualid(self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
397 return self.tk.call('winfo', 'visualid', self._w) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
398 def winfo_visualsavailable(self, includeids=0): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
399 data = self.tk.split( |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
400 self.tk.call('winfo', 'visualsavailable', self._w, |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
401 includeids and 'includeids' or None)) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
402 def parseitem(x, self=self): |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
403 return x[:1] + tuple(map(self.tk.getint, x[1:])) |
|
faddf6d55af0
Added a bunch of new winfo options; we should now be up to date with
Guido van Rossum <guido@python.org>
parents:
4560
diff
changeset
|
404 return map(parseitem, data) |
| 1664 | 405 def winfo_vrootheight(self): |
| 406 return self.tk.getint( | |
| 407 self.tk.call('winfo', 'vrootheight', self._w)) | |
| 408 def winfo_vrootwidth(self): | |
| 409 return self.tk.getint( | |
| 410 self.tk.call('winfo', 'vrootwidth', self._w)) | |
| 411 def winfo_vrootx(self): | |
| 412 return self.tk.getint( | |
| 413 self.tk.call('winfo', 'vrootx', self._w)) | |
| 414 def winfo_vrooty(self): | |
| 415 return self.tk.getint( | |
| 416 self.tk.call('winfo', 'vrooty', self._w)) | |
| 417 def winfo_width(self): | |
| 418 return self.tk.getint( | |
| 419 self.tk.call('winfo', 'width', self._w)) | |
| 420 def winfo_x(self): | |
| 421 return self.tk.getint( | |
| 422 self.tk.call('winfo', 'x', self._w)) | |
| 423 def winfo_y(self): | |
| 424 return self.tk.getint( | |
| 425 self.tk.call('winfo', 'y', self._w)) | |
| 426 def update(self): | |
| 427 self.tk.call('update') | |
| 428 def update_idletasks(self): | |
| 429 self.tk.call('update', 'idletasks') | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
430 def bindtags(self, tagList=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
431 if tagList is None: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
432 return self.tk.splitlist( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
433 self.tk.call('bindtags', self._w)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
434 else: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
435 self.tk.call('bindtags', self._w, tagList) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
436 def _bind(self, what, sequence, func, add): |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
437 if func: |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
438 cmd = ("%sset _tkinter_break [%s %s]\n" |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
439 'if {"$_tkinter_break" == "break"} break\n') \ |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
440 % (add and '+' or '', |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
441 self._register(func, self._substitute), |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
442 _string.join(self._subst_format)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
443 apply(self.tk.call, what + (sequence, cmd)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
444 elif func == '': |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
445 apply(self.tk.call, what + (sequence, func)) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
446 else: |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
447 return apply(self.tk.call, what + (sequence,)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
448 def bind(self, sequence=None, func=None, add=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
449 return self._bind(('bind', self._w), sequence, func, add) |
|
1768
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
450 def unbind(self, sequence): |
|
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
451 self.tk.call('bind', self._w, sequence, '') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
452 def bind_all(self, sequence=None, func=None, add=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
453 return self._bind(('bind', 'all'), sequence, func, add) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
454 def unbind_all(self, sequence): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
455 self.tk.call('bind', 'all' , sequence, '') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
456 def bind_class(self, className, sequence=None, func=None, add=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
457 self._bind(('bind', className), sequence, func, add) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
458 def unbind_class(self, className, sequence): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
459 self.tk.call('bind', className , sequence, '') |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
460 def mainloop(self, n=0): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
461 self.tk.mainloop(n) |
| 1664 | 462 def quit(self): |
| 463 self.tk.quit() | |
| 464 def _getints(self, string): | |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
465 if not string: return None |
|
2577
498dad8045d3
add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents:
2045
diff
changeset
|
466 return tuple(map(self.tk.getint, self.tk.splitlist(string))) |
|
498dad8045d3
add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents:
2045
diff
changeset
|
467 def _getdoubles(self, string): |
|
498dad8045d3
add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents:
2045
diff
changeset
|
468 if not string: return None |
|
498dad8045d3
add TkVersion,TclVersion; don't drop in debugger
Guido van Rossum <guido@python.org>
parents:
2045
diff
changeset
|
469 return tuple(map(self.tk.getdouble, self.tk.splitlist(string))) |
| 1664 | 470 def _getboolean(self, string): |
| 471 if string: | |
| 472 return self.tk.getboolean(string) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
473 def _displayof(self, displayof): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
474 if displayof: |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
475 return ('-displayof', displayof) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
476 if displayof is None: |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
477 return ('-displayof', self._w) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
478 return () |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
479 def _options(self, cnf, kw = None): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
480 if kw: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
481 cnf = _cnfmerge((cnf, kw)) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
482 else: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
483 cnf = _cnfmerge(cnf) |
| 1664 | 484 res = () |
| 485 for k, v in cnf.items(): | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
486 if v is not None: |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
487 if k[-1] == '_': k = k[:-1] |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
488 if callable(v): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
489 v = self._register(v) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
490 res = res + ('-'+k, v) |
| 1664 | 491 return res |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
492 def _nametowidget(self, name): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
493 w = self |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
494 if name[0] == '.': |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
495 w = w._root() |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
496 name = name[1:] |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
497 find = _string.find |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
498 while name: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
499 i = find(name, '.') |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
500 if i >= 0: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
501 name, tail = name[:i], name[i+1:] |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
502 else: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
503 tail = '' |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
504 w = w.children[name] |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
505 name = tail |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
506 return w |
| 1664 | 507 def _register(self, func, subst=None): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
508 f = CallWrapper(func, subst, self).__call__ |
| 1664 | 509 name = `id(f)` |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
510 try: |
| 1664 | 511 func = func.im_func |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
512 except AttributeError: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
513 pass |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
514 try: |
|
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
|
515 name = name + func.__name__ |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
516 except AttributeError: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
517 pass |
| 1664 | 518 self.tk.createcommand(name, f) |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
519 if self._tclCommands is None: |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
520 self._tclCommands = [] |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
521 self._tclCommands.append(name) |
|
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
522 #print '+ Tkinter created command', name |
| 1664 | 523 return name |
|
1694
03d351b6f738
wait_{variable,window,visibility}
Guido van Rossum <guido@python.org>
parents:
1689
diff
changeset
|
524 register = _register |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
525 def _root(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
526 w = self |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
527 while w.master: w = w.master |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
528 return w |
|
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
|
529 _subst_format = ('%#', '%b', '%f', '%h', '%k', |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
530 '%s', '%t', '%w', '%x', '%y', |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
531 '%A', '%E', '%K', '%N', '%W', '%T', '%X', '%Y') |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
532 def _substitute(self, *args): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
533 tk = self.tk |
|
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
|
534 if len(args) != len(self._subst_format): return args |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
535 nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y = args |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
536 # Missing: (a, c, d, m, o, v, B, R) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
537 e = Event() |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
538 e.serial = tk.getint(nsign) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
539 e.num = tk.getint(b) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
540 try: e.focus = tk.getboolean(f) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
541 except TclError: pass |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
542 e.height = tk.getint(h) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
543 e.keycode = tk.getint(k) |
|
3552
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
544 # For Visibility events, event state is a string and |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
545 # not an integer: |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
546 try: |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
547 e.state = tk.getint(s) |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
548 except TclError: |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
549 e.state = s |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
550 e.time = tk.getint(t) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
551 e.width = tk.getint(w) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
552 e.x = tk.getint(x) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
553 e.y = tk.getint(y) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
554 e.char = A |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
555 try: e.send_event = tk.getboolean(E) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
556 except TclError: pass |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
557 e.keysym = K |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
558 e.keysym_num = tk.getint(N) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
559 e.type = T |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
560 e.widget = self._nametowidget(W) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
561 e.x_root = tk.getint(X) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
562 e.y_root = tk.getint(Y) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
563 return (e,) |
|
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
|
564 def _report_exception(self): |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
565 import sys |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
566 exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
567 root = self._root() |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
568 root.report_callback_exception(exc, val, tb) |
| 1664 | 569 |
|
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
|
570 class CallWrapper: |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
571 def __init__(self, func, subst, widget): |
| 1664 | 572 self.func = func |
| 573 self.subst = subst | |
|
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
|
574 self.widget = widget |
| 1664 | 575 def __call__(self, *args): |
| 576 try: | |
|
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
|
577 if self.subst: |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
578 args = apply(self.subst, args) |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
579 return apply(self.func, args) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
580 except SystemExit, msg: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
581 raise SystemExit, msg |
| 1664 | 582 except: |
|
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
|
583 self.widget._report_exception() |
| 1664 | 584 |
| 585 class Wm: | |
| 586 def aspect(self, | |
| 587 minNumer=None, minDenom=None, | |
| 588 maxNumer=None, maxDenom=None): | |
| 589 return self._getints( | |
| 590 self.tk.call('wm', 'aspect', self._w, | |
| 591 minNumer, minDenom, | |
| 592 maxNumer, maxDenom)) | |
| 593 def client(self, name=None): | |
| 594 return self.tk.call('wm', 'client', self._w, name) | |
|
4338
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
595 def colormapwindows(self, *wlist): |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
596 args = ('wm', 'colormapwindows', self._w) + _flatten(wlist) |
|
af1684fc9c63
(Tkinter.py): Many revisions for Tk 4.X: Added clipboard support, updated
Fred Drake <fdrake@acm.org>
parents:
4277
diff
changeset
|
597 return map(self._nametowidget, apply(self.tk.call, args)) |
| 1664 | 598 def command(self, value=None): |
| 599 return self.tk.call('wm', 'command', self._w, value) | |
| 600 def deiconify(self): | |
| 601 return self.tk.call('wm', 'deiconify', self._w) | |
| 602 def focusmodel(self, model=None): | |
| 603 return self.tk.call('wm', 'focusmodel', self._w, model) | |
| 604 def frame(self): | |
| 605 return self.tk.call('wm', 'frame', self._w) | |
| 606 def geometry(self, newGeometry=None): | |
| 607 return self.tk.call('wm', 'geometry', self._w, newGeometry) | |
| 608 def grid(self, | |
| 609 baseWidht=None, baseHeight=None, | |
| 610 widthInc=None, heightInc=None): | |
| 611 return self._getints(self.tk.call( | |
| 612 'wm', 'grid', self._w, | |
| 613 baseWidht, baseHeight, widthInc, heightInc)) | |
| 614 def group(self, pathName=None): | |
| 615 return self.tk.call('wm', 'group', self._w, pathName) | |
| 616 def iconbitmap(self, bitmap=None): | |
| 617 return self.tk.call('wm', 'iconbitmap', self._w, bitmap) | |
| 618 def iconify(self): | |
| 619 return self.tk.call('wm', 'iconify', self._w) | |
| 620 def iconmask(self, bitmap=None): | |
| 621 return self.tk.call('wm', 'iconmask', self._w, bitmap) | |
| 622 def iconname(self, newName=None): | |
| 623 return self.tk.call('wm', 'iconname', self._w, newName) | |
| 624 def iconposition(self, x=None, y=None): | |
| 625 return self._getints(self.tk.call( | |
| 626 'wm', 'iconposition', self._w, x, y)) | |
| 627 def iconwindow(self, pathName=None): | |
| 628 return self.tk.call('wm', 'iconwindow', self._w, pathName) | |
| 629 def maxsize(self, width=None, height=None): | |
| 630 return self._getints(self.tk.call( | |
| 631 'wm', 'maxsize', self._w, width, height)) | |
| 632 def minsize(self, width=None, height=None): | |
| 633 return self._getints(self.tk.call( | |
| 634 'wm', 'minsize', self._w, width, height)) | |
| 635 def overrideredirect(self, boolean=None): | |
| 636 return self._getboolean(self.tk.call( | |
| 637 'wm', 'overrideredirect', self._w, boolean)) | |
| 638 def positionfrom(self, who=None): | |
| 639 return self.tk.call('wm', 'positionfrom', self._w, who) | |
| 640 def protocol(self, name=None, func=None): | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
641 if callable(func): |
| 1664 | 642 command = self._register(func) |
| 643 else: | |
| 644 command = func | |
| 645 return self.tk.call( | |
| 646 'wm', 'protocol', self._w, name, command) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
647 def resizable(self, width=None, height=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
648 return self.tk.call('wm', 'resizable', self._w, width, height) |
| 1664 | 649 def sizefrom(self, who=None): |
| 650 return self.tk.call('wm', 'sizefrom', self._w, who) | |
| 651 def state(self): | |
| 652 return self.tk.call('wm', 'state', self._w) | |
| 653 def title(self, string=None): | |
| 654 return self.tk.call('wm', 'title', self._w, string) | |
| 655 def transient(self, master=None): | |
| 656 return self.tk.call('wm', 'transient', self._w, master) | |
| 657 def withdraw(self): | |
| 658 return self.tk.call('wm', 'withdraw', self._w) | |
| 659 | |
| 660 class Tk(Misc, Wm): | |
| 661 _w = '.' | |
| 662 def __init__(self, screenName=None, baseName=None, className='Tk'): | |
|
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
|
663 global _default_root |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
664 self.master = None |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
665 self.children = {} |
| 1664 | 666 if baseName is None: |
| 667 import sys, os | |
| 668 baseName = os.path.basename(sys.argv[0]) | |
|
4358
0212b480944b
(Tkinter.py): Improve application basename determination to make .py and
Fred Drake <fdrake@acm.org>
parents:
4355
diff
changeset
|
669 baseName, ext = os.path.splitext(baseName) |
|
0212b480944b
(Tkinter.py): Improve application basename determination to make .py and
Fred Drake <fdrake@acm.org>
parents:
4355
diff
changeset
|
670 if ext not in ('.py', 'pyc'): baseName = baseName + ext |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
671 self.tk = _tkinter.create(screenName, baseName, className) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
672 try: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
673 # Disable event scanning except for Command-Period |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
674 import MacOS |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
675 MacOS.EnableAppswitch(0) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
676 except ImportError: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
677 pass |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
678 else: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
679 # Work around nasty MacTk bug |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
680 self.update() |
|
3151
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
681 # Version sanity checks |
|
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
682 tk_version = self.tk.getvar('tk_version') |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
683 if tk_version != _tkinter.TK_VERSION: |
|
3151
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
684 raise RuntimeError, \ |
|
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
685 "tk.h version (%s) doesn't match libtk.a version (%s)" \ |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
686 % (_tkinter.TK_VERSION, tk_version) |
|
3151
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
687 tcl_version = self.tk.getvar('tcl_version') |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
688 if tcl_version != _tkinter.TCL_VERSION: |
|
3151
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
689 raise RuntimeError, \ |
|
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
690 "tcl.h version (%s) doesn't match libtcl.a version (%s)" \ |
|
5123
05fffd55b014
Require _tkinter -- don't attempt to import tkinter when _tkinter does
Guido van Rossum <guido@python.org>
parents:
5096
diff
changeset
|
691 % (_tkinter.TCL_VERSION, tcl_version) |
|
3151
acff79dd14b7
better version sanity checks; get rid of Widget.unbind_class()
Guido van Rossum <guido@python.org>
parents:
3137
diff
changeset
|
692 if TkVersion < 4.0: |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
693 raise RuntimeError, \ |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
694 "Tk 4.0 or higher is required; found Tk %s" \ |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
695 % str(TkVersion) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
696 self.tk.createcommand('tkerror', _tkerror) |
|
1714
db0eaef42cb9
Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents:
1709
diff
changeset
|
697 self.tk.createcommand('exit', _exit) |
|
1726
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
698 self.readprofile(baseName, className) |
|
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
|
699 if not _default_root: |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
700 _default_root = self |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
701 def destroy(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
702 for c in self.children.values(): c.destroy() |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
703 self.tk.call('destroy', self._w) |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
704 Misc.destroy(self) |
| 1664 | 705 def __str__(self): |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
706 return self._w |
|
1726
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
707 def readprofile(self, baseName, className): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
708 import os |
|
1726
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
709 if os.environ.has_key('HOME'): home = os.environ['HOME'] |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
710 else: home = os.curdir |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
711 class_tcl = os.path.join(home, '.%s.tcl' % className) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
712 class_py = os.path.join(home, '.%s.py' % className) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
713 base_tcl = os.path.join(home, '.%s.tcl' % baseName) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
714 base_py = os.path.join(home, '.%s.py' % baseName) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
715 dir = {'self': self} |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
716 exec 'from Tkinter import *' in dir |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
717 if os.path.isfile(class_tcl): |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
718 print 'source', `class_tcl` |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
719 self.tk.call('source', class_tcl) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
720 if os.path.isfile(class_py): |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
721 print 'execfile', `class_py` |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
722 execfile(class_py, dir) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
723 if os.path.isfile(base_tcl): |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
724 print 'source', `base_tcl` |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
725 self.tk.call('source', base_tcl) |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
726 if os.path.isfile(base_py): |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
727 print 'execfile', `base_py` |
|
cdf44c14c270
read various startup files in Tcl and Python based upon className and
Guido van Rossum <guido@python.org>
parents:
1725
diff
changeset
|
728 execfile(base_py, dir) |
|
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
|
729 def report_callback_exception(self, exc, val, tb): |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
730 import traceback |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
731 print "Exception in Tkinter callback" |
|
fbb8eddc9309
move constants to Tkconstants; added some; overridable error reporting; fix typo in propagate
Guido van Rossum <guido@python.org>
parents:
3067
diff
changeset
|
732 traceback.print_exception(exc, val, tb) |
| 1664 | 733 |
| 734 class Pack: | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
735 def config(self, cnf={}, **kw): |
| 1664 | 736 apply(self.tk.call, |
| 737 ('pack', 'configure', self._w) | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
738 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
739 configure = config |
| 1664 | 740 pack = config |
| 741 def __setitem__(self, key, value): | |
| 742 Pack.config({key: value}) | |
| 743 def forget(self): | |
| 744 self.tk.call('pack', 'forget', self._w) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
745 pack_forget = forget |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
746 def info(self): |
|
1722
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
747 words = self.tk.splitlist( |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
748 self.tk.call('pack', 'info', self._w)) |
|
1722
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
749 dict = {} |
|
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
750 for i in range(0, len(words), 2): |
|
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
751 key = words[i][1:] |
|
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
752 value = words[i+1] |
|
3555
29c18fb13d8f
Yet another mini fix to pack/grid info.
Guido van Rossum <guido@python.org>
parents:
3552
diff
changeset
|
753 if value[:1] == '.': |
|
1722
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
754 value = self._nametowidget(value) |
|
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
755 dict[key] = value |
|
1dd31153709d
Make Pack.newinfo() return a dict
Guido van Rossum <guido@python.org>
parents:
1714
diff
changeset
|
756 return dict |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
757 pack_info = info |
|
2045
62bbbfe6bbf6
Fixed 'propagate' method
Guido van Rossum <guido@python.org>
parents:
1990
diff
changeset
|
758 _noarg_ = ['_noarg_'] |
|
62bbbfe6bbf6
Fixed 'propagate' method
Guido van Rossum <guido@python.org>
parents:
1990
diff
changeset
|
759 def propagate(self, flag=_noarg_): |
|
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
|
760 if flag is Pack._noarg_: |
| 1664 | 761 return self._getboolean(self.tk.call( |
| 762 'pack', 'propagate', self._w)) | |
|
2045
62bbbfe6bbf6
Fixed 'propagate' method
Guido van Rossum <guido@python.org>
parents:
1990
diff
changeset
|
763 else: |
|
62bbbfe6bbf6
Fixed 'propagate' method
Guido van Rossum <guido@python.org>
parents:
1990
diff
changeset
|
764 self.tk.call('pack', 'propagate', self._w, flag) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
765 pack_propagate = propagate |
| 1664 | 766 def slaves(self): |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
767 return map(self._nametowidget, |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
768 self.tk.splitlist( |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
769 self.tk.call('pack', 'slaves', self._w))) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
770 pack_slaves = slaves |
| 1664 | 771 |
| 772 class Place: | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
773 def config(self, cnf={}, **kw): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
774 for k in ['in_']: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
775 if kw.has_key(k): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
776 kw[k[:-1]] = kw[k] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
777 del kw[k] |
| 1664 | 778 apply(self.tk.call, |
| 779 ('place', 'configure', self._w) | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
780 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
781 configure = config |
| 1664 | 782 place = config |
| 783 def __setitem__(self, key, value): | |
| 784 Place.config({key: value}) | |
| 785 def forget(self): | |
| 786 self.tk.call('place', 'forget', self._w) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
787 place_forget = forget |
| 1664 | 788 def info(self): |
|
3556
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
789 words = self.tk.splitlist( |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
790 self.tk.call('place', 'info', self._w)) |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
791 dict = {} |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
792 for i in range(0, len(words), 2): |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
793 key = words[i][1:] |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
794 value = words[i+1] |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
795 if value[:1] == '.': |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
796 value = self._nametowidget(value) |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
797 dict[key] = value |
|
53c66d19d127
Made Place.info == Pack.info
Guido van Rossum <guido@python.org>
parents:
3555
diff
changeset
|
798 return dict |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
799 place_info = info |
| 1664 | 800 def slaves(self): |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
801 return map(self._nametowidget, |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
802 self.tk.splitlist( |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
803 self.tk.call( |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
804 'place', 'slaves', self._w))) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
805 place_slaves = slaves |
| 1664 | 806 |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
807 class Grid: |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
808 # Thanks to Masazumi Yoshikawa (yosikawa@isi.edu) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
809 def config(self, cnf={}, **kw): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
810 apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
811 ('grid', 'configure', self._w) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
812 + self._options(cnf, kw)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
813 grid = config |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
814 def __setitem__(self, key, value): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
815 Grid.config({key: value}) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
816 def bbox(self, column, row): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
817 return self._getints( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
818 self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
819 'grid', 'bbox', self._w, column, row)) or None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
820 grid_bbox = bbox |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
821 def columnconfigure(self, index, cnf={}, **kw): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
822 if type(cnf) is not DictionaryType and not kw: |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
823 options = self._options({cnf: None}) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
824 else: |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
825 options = self._options(cnf, kw) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
826 res = apply(self.tk.call, |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
827 ('grid', 'columnconfigure', self._w, index) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
828 + options) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
829 if options == ('-minsize', None): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
830 return self.tk.getint(res) or None |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
831 elif options == ('-weight', None): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
832 return self.tk.getdouble(res) or None |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
833 def forget(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
834 self.tk.call('grid', 'forget', self._w) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
835 grid_forget = forget |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
836 def info(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
837 words = self.tk.splitlist( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
838 self.tk.call('grid', 'info', self._w)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
839 dict = {} |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
840 for i in range(0, len(words), 2): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
841 key = words[i][1:] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
842 value = words[i+1] |
|
3555
29c18fb13d8f
Yet another mini fix to pack/grid info.
Guido van Rossum <guido@python.org>
parents:
3552
diff
changeset
|
843 if value[:1] == '.': |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
844 value = self._nametowidget(value) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
845 dict[key] = value |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
846 return dict |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
847 grid_info = info |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
848 def location(self, x, y): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
849 return self._getints( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
850 self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
851 'grid', 'location', self._w, x, y)) or None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
852 _noarg_ = ['_noarg_'] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
853 def propagate(self, flag=_noarg_): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
854 if flag is Grid._noarg_: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
855 return self._getboolean(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
856 'grid', 'propagate', self._w)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
857 else: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
858 self.tk.call('grid', 'propagate', self._w, flag) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
859 grid_propagate = propagate |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
860 def rowconfigure(self, index, cnf={}, **kw): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
861 if type(cnf) is not DictionaryType and not kw: |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
862 options = self._options({cnf: None}) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
863 else: |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
864 options = self._options(cnf, kw) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
865 res = apply(self.tk.call, |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
866 ('grid', 'rowconfigure', self._w, index) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
867 + options) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
868 if options == ('-minsize', None): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
869 return self.tk.getint(res) or None |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
870 elif options == ('-weight', None): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
871 return self.tk.getdouble(res) or None |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
872 def size(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
873 return self._getints( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
874 self.tk.call('grid', 'size', self._w)) or None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
875 def slaves(self, *args): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
876 return map(self._nametowidget, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
877 self.tk.splitlist( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
878 apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
879 ('grid', 'slaves', self._w) + args))) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
880 grid_slaves = slaves |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
881 |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
882 class Widget(Misc, Pack, Place, Grid): |
|
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
|
883 def _setup(self, master, cnf): |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
884 global _default_root |
| 1664 | 885 if not master: |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
886 if not _default_root: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
887 _default_root = Tk() |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
888 master = _default_root |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
889 if not _default_root: |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
890 _default_root = master |
| 1664 | 891 self.master = master |
| 892 self.tk = master.tk | |
|
5649
07e1aab23115
Widget._setup(): Support name=None in a similar way to the handling of other
Fred Drake <fdrake@acm.org>
parents:
5454
diff
changeset
|
893 name = None |
| 1664 | 894 if cnf.has_key('name'): |
| 895 name = cnf['name'] | |
| 896 del cnf['name'] | |
|
5649
07e1aab23115
Widget._setup(): Support name=None in a similar way to the handling of other
Fred Drake <fdrake@acm.org>
parents:
5454
diff
changeset
|
897 if not name: |
| 1664 | 898 name = `id(self)` |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
899 self._name = name |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
900 if master._w=='.': |
| 1664 | 901 self._w = '.' + name |
| 902 else: | |
| 903 self._w = master._w + '.' + 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
|
904 self.children = {} |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
905 if self.master.children.has_key(self._name): |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
906 self.master.children[self._name].destroy() |
|
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
|
907 self.master.children[self._name] = self |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
908 def __init__(self, master, widgetName, cnf={}, kw={}, extra=()): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
909 if kw: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
910 cnf = _cnfmerge((cnf, kw)) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
911 self.widgetName = widgetName |
|
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
|
912 Widget._setup(self, master, cnf) |
|
3783
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
913 classes = [] |
|
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
914 for k in cnf.keys(): |
|
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
915 if type(k) is ClassType: |
|
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
916 classes.append((k, cnf[k])) |
|
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
917 del cnf[k] |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
918 apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
919 (widgetName, self._w) + extra + self._options(cnf)) |
|
3783
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
920 for k, v in classes: |
|
a6203d17158b
Restore the capability to pass a class (usually Pack) as an option to widget
Guido van Rossum <guido@python.org>
parents:
3756
diff
changeset
|
921 k.config(self, v) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
922 def config(self, cnf=None, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
923 # XXX ought to generalize this so tag_config etc. can use it |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
924 if kw: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
925 cnf = _cnfmerge((cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
926 elif cnf: |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
927 cnf = _cnfmerge(cnf) |
| 1675 | 928 if cnf is None: |
| 929 cnf = {} | |
| 930 for x in self.tk.split( | |
| 931 self.tk.call(self._w, 'configure')): | |
| 932 cnf[x[0][1:]] = (x[0][1:],) + x[1:] | |
| 933 return cnf | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
934 if type(cnf) is StringType: |
| 1675 | 935 x = self.tk.split(self.tk.call( |
| 936 self._w, 'configure', '-'+cnf)) | |
| 937 return (x[0][1:],) + x[1:] | |
| 1664 | 938 apply(self.tk.call, (self._w, 'configure') |
| 939 + self._options(cnf)) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
940 configure = config |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
941 def cget(self, key): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
942 return self.tk.call(self._w, 'cget', '-' + key) |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
943 __getitem__ = cget |
| 1664 | 944 def __setitem__(self, key, value): |
| 945 Widget.config(self, {key: value}) | |
| 1675 | 946 def keys(self): |
| 947 return map(lambda x: x[0][1:], | |
| 948 self.tk.split(self.tk.call(self._w, 'configure'))) | |
| 1664 | 949 def __str__(self): |
| 950 return self._w | |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
951 def destroy(self): |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
952 for c in self.children.values(): c.destroy() |
|
1853
9d4add42ee22
Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents:
1768
diff
changeset
|
953 if self.master.children.has_key(self._name): |
|
9d4add42ee22
Dialog.py: d.num should be numeric, not string
Guido van Rossum <guido@python.org>
parents:
1768
diff
changeset
|
954 del self.master.children[self._name] |
| 1664 | 955 self.tk.call('destroy', self._w) |
|
5323
91f991812718
Patch by Craig McPheeters to clean up the back-references to widgets
Guido van Rossum <guido@python.org>
parents:
5123
diff
changeset
|
956 Misc.destroy(self) |
| 1664 | 957 def _do(self, name, args=()): |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
958 return apply(self.tk.call, (self._w, name) + args) |
| 1664 | 959 |
| 960 class Toplevel(Widget, Wm): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
961 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
962 if kw: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
963 cnf = _cnfmerge((cnf, kw)) |
| 1664 | 964 extra = () |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
965 for wmkey in ['screen', 'class_', 'class', 'visual', |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
966 'colormap']: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
967 if cnf.has_key(wmkey): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
968 val = cnf[wmkey] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
969 # TBD: a hack needed because some keys |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
970 # are not valid as keyword arguments |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
971 if wmkey[-1] == '_': opt = '-'+wmkey[:-1] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
972 else: opt = '-'+wmkey |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
973 extra = extra + (opt, val) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
974 del cnf[wmkey] |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
975 Widget.__init__(self, master, 'toplevel', cnf, {}, extra) |
|
1671
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
976 root = self._root() |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
977 self.iconname(root.iconname()) |
|
953e74eac006
Added dictionary mapping names to children, and _name attribute.
Guido van Rossum <guido@python.org>
parents:
1669
diff
changeset
|
978 self.title(root.title()) |
| 1664 | 979 |
| 980 class Button(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
981 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
982 Widget.__init__(self, master, 'button', cnf, kw) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
983 def tkButtonEnter(self, *dummy): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
984 self.tk.call('tkButtonEnter', self._w) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
985 def tkButtonLeave(self, *dummy): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
986 self.tk.call('tkButtonLeave', self._w) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
987 def tkButtonDown(self, *dummy): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
988 self.tk.call('tkButtonDown', self._w) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
989 def tkButtonUp(self, *dummy): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
990 self.tk.call('tkButtonUp', self._w) |
|
3552
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
991 def tkButtonInvoke(self, *dummy): |
|
c7e808596d14
Some more changes from the net... Typos, 4.0/4.1 issues, new tkButtonInvoke().
Guido van Rossum <guido@python.org>
parents:
3551
diff
changeset
|
992 self.tk.call('tkButtonInvoke', self._w) |
| 1664 | 993 def flash(self): |
| 994 self.tk.call(self._w, 'flash') | |
| 995 def invoke(self): | |
| 996 self.tk.call(self._w, 'invoke') | |
| 997 | |
| 998 # Indices: | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
999 # XXX I don't like these -- take them away |
| 1664 | 1000 def AtEnd(): |
| 1001 return 'end' | |
|
1669
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
1002 def AtInsert(*args): |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
1003 s = 'insert' |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
1004 for a in args: |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
1005 if a: s = s + (' ' + a) |
|
273451892327
Added getdouble, getboolean.
Guido van Rossum <guido@python.org>
parents:
1666
diff
changeset
|
1006 return s |
| 1664 | 1007 def AtSelFirst(): |
| 1008 return 'sel.first' | |
| 1009 def AtSelLast(): | |
| 1010 return 'sel.last' | |
| 1011 def At(x, y=None): | |
|
1725
e16769cd7a90
Fix bug in At() (Steen)
Guido van Rossum <guido@python.org>
parents:
1722
diff
changeset
|
1012 if y is None: |
|
e16769cd7a90
Fix bug in At() (Steen)
Guido van Rossum <guido@python.org>
parents:
1722
diff
changeset
|
1013 return '@' + `x` |
|
e16769cd7a90
Fix bug in At() (Steen)
Guido van Rossum <guido@python.org>
parents:
1722
diff
changeset
|
1014 else: |
| 1664 | 1015 return '@' + `x` + ',' + `y` |
| 1016 | |
| 1017 class Canvas(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1018 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1019 Widget.__init__(self, master, 'canvas', cnf, kw) |
| 1664 | 1020 def addtag(self, *args): |
| 1021 self._do('addtag', args) | |
|
4115
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1022 def addtag_above(self, newtag, tagOrId): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1023 self.addtag(newtag, 'above', tagOrId) |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1024 def addtag_all(self, newtag): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1025 self.addtag(newtag, 'all') |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1026 def addtag_below(self, newtag, tagOrId): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1027 self.addtag(newtag, 'below', tagOrId) |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1028 def addtag_closest(self, newtag, x, y, halo=None, start=None): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1029 self.addtag(newtag, 'closest', x, y, halo, start) |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1030 def addtag_enclosed(self, newtag, x1, y1, x2, y2): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1031 self.addtag(newtag, 'enclosed', x1, y1, x2, y2) |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1032 def addtag_overlapping(self, newtag, x1, y1, x2, y2): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1033 self.addtag(newtag, 'overlapping', x1, y1, x2, y2) |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1034 def addtag_withtag(self, newtag, tagOrId): |
|
23589c016cb9
Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents:
4103
diff
changeset
|
1035 self.addtag(newtag, 'withtag', tagOrId) |
| 1664 | 1036 def bbox(self, *args): |
| 1675 | 1037 return self._getints(self._do('bbox', args)) or None |
|
1768
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
1038 def tag_unbind(self, tagOrId, sequence): |
|
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
1039 self.tk.call(self._w, 'bind', tagOrId, sequence, '') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1040 def tag_bind(self, tagOrId, sequence=None, func=None, add=None): |
|
3756
82bb7d2a6b31
fix canvas bind commands
Guido van Rossum <guido@python.org>
parents:
3569
diff
changeset
|
1041 return self._bind((self._w, 'bind', tagOrId), |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1042 sequence, func, add) |
| 1664 | 1043 def canvasx(self, screenx, gridspacing=None): |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1044 return self.tk.getdouble(self.tk.call( |
| 1664 | 1045 self._w, 'canvasx', screenx, gridspacing)) |
| 1046 def canvasy(self, screeny, gridspacing=None): | |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1047 return self.tk.getdouble(self.tk.call( |
| 1664 | 1048 self._w, 'canvasy', screeny, gridspacing)) |
| 1049 def coords(self, *args): | |
|
3826
9831e0fc01de
Two independent changes:
Guido van Rossum <guido@python.org>
parents:
3783
diff
changeset
|
1050 return map(self.tk.getdouble, |
|
3876
0638fdc23eec
Add missing close parenthesis.
Guido van Rossum <guido@python.org>
parents:
3826
diff
changeset
|
1051 self.tk.splitlist(self._do('coords', args))) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1052 def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={}) |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
1053 args = _flatten(args) |
| 1664 | 1054 cnf = args[-1] |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
1055 if type(cnf) in (DictionaryType, TupleType): |
| 1664 | 1056 args = args[:-1] |
| 1057 else: | |
| 1058 cnf = {} | |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
1059 return self.tk.getint(apply( |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
1060 self.tk.call, |
|
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
1061 (self._w, 'create', itemType) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1062 + args + self._options(cnf, kw))) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1063 def create_arc(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1064 return self._create('arc', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1065 def create_bitmap(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1066 return self._create('bitmap', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1067 def create_image(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1068 return self._create('image', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1069 def create_line(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1070 return self._create('line', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1071 def create_oval(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1072 return self._create('oval', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1073 def create_polygon(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1074 return self._create('polygon', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1075 def create_rectangle(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1076 return self._create('rectangle', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1077 def create_text(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1078 return self._create('text', args, kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1079 def create_window(self, *args, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1080 return self._create('window', args, kw) |
| 1664 | 1081 def dchars(self, *args): |
| 1082 self._do('dchars', args) | |
| 1083 def delete(self, *args): | |
| 1084 self._do('delete', args) | |
| 1085 def dtag(self, *args): | |
| 1086 self._do('dtag', args) | |
| 1087 def find(self, *args): | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1088 return self._getints(self._do('find', args)) or () |
| 1675 | 1089 def find_above(self, tagOrId): |
| 1090 return self.find('above', tagOrId) | |
| 1091 def find_all(self): | |
| 1092 return self.find('all') | |
| 1093 def find_below(self, tagOrId): | |
| 1094 return self.find('below', tagOrId) | |
| 1095 def find_closest(self, x, y, halo=None, start=None): | |
| 1096 return self.find('closest', x, y, halo, start) | |
| 1097 def find_enclosed(self, x1, y1, x2, y2): | |
| 1098 return self.find('enclosed', x1, y1, x2, y2) | |
| 1099 def find_overlapping(self, x1, y1, x2, y2): | |
| 1100 return self.find('overlapping', x1, y1, x2, y2) | |
| 1101 def find_withtag(self, tagOrId): | |
| 1102 return self.find('withtag', tagOrId) | |
| 1664 | 1103 def focus(self, *args): |
| 1104 return self._do('focus', args) | |
| 1105 def gettags(self, *args): | |
| 1106 return self.tk.splitlist(self._do('gettags', args)) | |
| 1107 def icursor(self, *args): | |
| 1108 self._do('icursor', args) | |
| 1109 def index(self, *args): | |
| 1110 return self.tk.getint(self._do('index', args)) | |
| 1111 def insert(self, *args): | |
| 1112 self._do('insert', args) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1113 def itemcget(self, tagOrId, option): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1114 return self._do('itemcget', (tagOrId, '-'+option)) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1115 def itemconfig(self, tagOrId, cnf=None, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1116 if cnf is None and not kw: |
| 1675 | 1117 cnf = {} |
| 1118 for x in self.tk.split( | |
| 1119 self._do('itemconfigure', (tagOrId))): | |
| 1120 cnf[x[0][1:]] = (x[0][1:],) + x[1:] | |
| 1121 return cnf | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1122 if type(cnf) == StringType and not kw: |
| 1675 | 1123 x = self.tk.split(self._do('itemconfigure', |
| 1124 (tagOrId, '-'+cnf,))) | |
| 1125 return (x[0][1:],) + x[1:] | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1126 self._do('itemconfigure', (tagOrId,) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1127 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1128 itemconfigure = itemconfig |
| 1664 | 1129 def lower(self, *args): |
| 1130 self._do('lower', args) | |
| 1131 def move(self, *args): | |
| 1132 self._do('move', args) | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1133 def postscript(self, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1134 return self._do('postscript', self._options(cnf, kw)) |
| 1664 | 1135 def tkraise(self, *args): |
| 1136 self._do('raise', args) | |
|
1666
73dd2a979857
Added getvar, getint, lower, tkraise==lift to Misc class
Guido van Rossum <guido@python.org>
parents:
1664
diff
changeset
|
1137 lift = tkraise |
| 1664 | 1138 def scale(self, *args): |
| 1139 self._do('scale', args) | |
| 1140 def scan_mark(self, x, y): | |
| 1141 self.tk.call(self._w, 'scan', 'mark', x, y) | |
| 1142 def scan_dragto(self, x, y): | |
| 1143 self.tk.call(self._w, 'scan', 'dragto', x, y) | |
| 1144 def select_adjust(self, tagOrId, index): | |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
1145 self.tk.call(self._w, 'select', 'adjust', tagOrId, index) |
| 1664 | 1146 def select_clear(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1147 self.tk.call(self._w, 'select', 'clear') |
| 1664 | 1148 def select_from(self, tagOrId, index): |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1149 self.tk.call(self._w, 'select', 'set', tagOrId, index) |
| 1664 | 1150 def select_item(self): |
| 1151 self.tk.call(self._w, 'select', 'item') | |
| 1152 def select_to(self, tagOrId, index): | |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
1153 self.tk.call(self._w, 'select', 'to', tagOrId, index) |
| 1664 | 1154 def type(self, tagOrId): |
|
1674
a948b44ad4a1
* Tkinter.py: some tidying up.
Guido van Rossum <guido@python.org>
parents:
1672
diff
changeset
|
1155 return self.tk.call(self._w, 'type', tagOrId) or None |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1156 def xview(self, *args): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1157 if not args: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1158 return self._getdoubles(self.tk.call(self._w, 'xview')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1159 apply(self.tk.call, (self._w, 'xview')+args) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1160 def yview(self, *args): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1161 if not args: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1162 return self._getdoubles(self.tk.call(self._w, 'yview')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1163 apply(self.tk.call, (self._w, 'yview')+args) |
| 1664 | 1164 |
| 1165 class Checkbutton(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1166 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1167 Widget.__init__(self, master, 'checkbutton', cnf, kw) |
| 1664 | 1168 def deselect(self): |
| 1169 self.tk.call(self._w, 'deselect') | |
| 1170 def flash(self): | |
| 1171 self.tk.call(self._w, 'flash') | |
| 1172 def invoke(self): | |
| 1173 self.tk.call(self._w, 'invoke') | |
| 1174 def select(self): | |
| 1175 self.tk.call(self._w, 'select') | |
| 1176 def toggle(self): | |
| 1177 self.tk.call(self._w, 'toggle') | |
| 1178 | |
| 1179 class Entry(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1180 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1181 Widget.__init__(self, master, 'entry', cnf, kw) |
| 1664 | 1182 def delete(self, first, last=None): |
| 1183 self.tk.call(self._w, 'delete', first, last) | |
| 1184 def get(self): | |
| 1185 return self.tk.call(self._w, 'get') | |
| 1186 def icursor(self, index): | |
| 1187 self.tk.call(self._w, 'icursor', index) | |
| 1188 def index(self, index): | |
| 1189 return self.tk.getint(self.tk.call( | |
| 1190 self._w, 'index', index)) | |
| 1191 def insert(self, index, string): | |
| 1192 self.tk.call(self._w, 'insert', index, string) | |
| 1193 def scan_mark(self, x): | |
| 1194 self.tk.call(self._w, 'scan', 'mark', x) | |
| 1195 def scan_dragto(self, x): | |
| 1196 self.tk.call(self._w, 'scan', 'dragto', x) | |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1197 def selection_adjust(self, index): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1198 self.tk.call(self._w, 'selection', 'adjust', index) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1199 select_adjust = selection_adjust |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1200 def selection_clear(self): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1201 self.tk.call(self._w, 'selection', 'clear') |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1202 select_clear = selection_clear |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1203 def selection_from(self, index): |
|
4219
9bcfb034b963
Fixed Entry.select_from() to acually call the "select from" widget
Guido van Rossum <guido@python.org>
parents:
4212
diff
changeset
|
1204 self.tk.call(self._w, 'selection', 'from', index) |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1205 select_from = selection_from |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1206 def selection_present(self): |
|
2968
521306679e34
added select_present and select_range to Entry widget
Guido van Rossum <guido@python.org>
parents:
2885
diff
changeset
|
1207 return self.tk.getboolean( |
|
3569
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1208 self.tk.call(self._w, 'selection', 'present')) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1209 select_present = selection_present |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1210 def selection_range(self, start, end): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1211 self.tk.call(self._w, 'selection', 'range', start, end) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1212 select_range = selection_range |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1213 def selection_to(self, index): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1214 self.tk.call(self._w, 'selection', 'to', index) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1215 select_to = selection_to |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1216 def xview(self, index): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1217 self.tk.call(self._w, 'xview', index) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1218 def xview_moveto(self, fraction): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1219 self.tk.call(self._w, 'xview', 'moveto', fraction) |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1220 def xview_scroll(self, number, what): |
|
922c00165f76
more changes copied from Grail
Guido van Rossum <guido@python.org>
parents:
3556
diff
changeset
|
1221 self.tk.call(self._w, 'xview', 'scroll', number, what) |
| 1664 | 1222 |
| 1223 class Frame(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1224 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1225 cnf = _cnfmerge((cnf, kw)) |
| 1664 | 1226 extra = () |
|
4922
2dec36345665
(Tkinter.py): Add support for Frame(w, class_="classname") as an alternative
Fred Drake <fdrake@acm.org>
parents:
4833
diff
changeset
|
1227 if cnf.has_key('class_'): |
|
2dec36345665
(Tkinter.py): Add support for Frame(w, class_="classname") as an alternative
Fred Drake <fdrake@acm.org>
parents:
4833
diff
changeset
|
1228 extra = ('-class', cnf['class_']) |
|
2dec36345665
(Tkinter.py): Add support for Frame(w, class_="classname") as an alternative
Fred Drake <fdrake@acm.org>
parents:
4833
diff
changeset
|
1229 del cnf['class_'] |
|
2dec36345665
(Tkinter.py): Add support for Frame(w, class_="classname") as an alternative
Fred Drake <fdrake@acm.org>
parents:
4833
diff
changeset
|
1230 elif cnf.has_key('class'): |
| 1664 | 1231 extra = ('-class', cnf['class']) |
| 1232 del cnf['class'] | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1233 Widget.__init__(self, master, 'frame', cnf, {}, extra) |
| 1664 | 1234 |
| 1235 class Label(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1236 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1237 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
|
1238 |
| 1664 | 1239 class Listbox(Widget): |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1240 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1241 Widget.__init__(self, master, 'listbox', cnf, kw) |
|
3203
46df672c7c27
add Listbox.activate()
Guido van Rossum <guido@python.org>
parents:
3180
diff
changeset
|
1242 def activate(self, index): |
|
46df672c7c27
add Listbox.activate()
Guido van Rossum <guido@python.org>
parents:
3180
diff
changeset
|
1243 self.tk.call(self._w, 'activate', index) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1244 def bbox(self, *args): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1245 return self._getints(self._do('bbox', args)) or None |
| 1664 | 1246 def curselection(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1247 # XXX Ought to apply self._getints()... |
| 1664 | 1248 return self.tk.splitlist(self.tk.call( |
| 1249 self._w, 'curselection')) | |
| 1250 def delete(self, first, last=None): | |
| 1251 self.tk.call(self._w, 'delete', first, last) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1252 def get(self, first, last=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1253 if last: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1254 return self.tk.splitlist(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1255 self._w, 'get', first, last)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1256 else: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1257 return self.tk.call(self._w, 'get', first) |
| 1664 | 1258 def insert(self, index, *elements): |
| 1259 apply(self.tk.call, | |
| 1260 (self._w, 'insert', index) + elements) | |
| 1261 def nearest(self, y): | |
| 1262 return self.tk.getint(self.tk.call( | |
| 1263 self._w, 'nearest', y)) | |
| 1264 def scan_mark(self, x, y): | |
| 1265 self.tk.call(self._w, 'scan', 'mark', x, y) | |
| 1266 def scan_dragto(self, x, y): | |
| 1267 self.tk.call(self._w, 'scan', 'dragto', x, y) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1268 def see(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1269 self.tk.call(self._w, 'see', index) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1270 def index(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1271 i = self.tk.call(self._w, 'index', index) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1272 if i == 'none': return None |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1273 return self.tk.getint(i) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1274 def select_anchor(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1275 self.tk.call(self._w, 'selection', 'anchor', index) |
|
5096
30c10b222953
Gave the Listbox selection methods their correct (longer) names.
Guido van Rossum <guido@python.org>
parents:
5026
diff
changeset
|
1276 selection_anchor = select_anchor |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1277 def select_clear(self, first, last=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1278 self.tk.call(self._w, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1279 'selection', 'clear', first, last) |
|
5096
30c10b222953
Gave the Listbox selection methods their correct (longer) names.
Guido van Rossum <guido@python.org>
parents:
5026
diff
changeset
|
1280 selection_clear = select_clear |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1281 def select_includes(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1282 return self.tk.getboolean(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1283 self._w, 'selection', 'includes', index)) |
|
5096
30c10b222953
Gave the Listbox selection methods their correct (longer) names.
Guido van Rossum <guido@python.org>
parents:
5026
diff
changeset
|
1284 selection_includes = select_includes |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1285 def select_set(self, first, last=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1286 self.tk.call(self._w, 'selection', 'set', first, last) |
|
5096
30c10b222953
Gave the Listbox selection methods their correct (longer) names.
Guido van Rossum <guido@python.org>
parents:
5026
diff
changeset
|
1287 selection_set = select_set |
| 1664 | 1288 def size(self): |
| 1289 return self.tk.getint(self.tk.call(self._w, 'size')) | |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1290 def xview(self, *what): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1291 if not what: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1292 return self._getdoubles(self.tk.call(self._w, 'xview')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1293 apply(self.tk.call, (self._w, 'xview')+what) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1294 def yview(self, *what): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1295 if not what: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1296 return self._getdoubles(self.tk.call(self._w, 'yview')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1297 apply(self.tk.call, (self._w, 'yview')+what) |
| 1664 | 1298 |
| 1299 class Menu(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1300 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1301 Widget.__init__(self, master, 'menu', cnf, kw) |
| 1664 | 1302 def tk_bindForTraversal(self): |
|
4255
64704d36b198
simpler version of the previous fix
Guido van Rossum <guido@python.org>
parents:
4254
diff
changeset
|
1303 pass # obsolete since Tk 4.0 |
| 1664 | 1304 def tk_mbPost(self): |
| 1305 self.tk.call('tk_mbPost', self._w) | |
| 1306 def tk_mbUnpost(self): | |
| 1307 self.tk.call('tk_mbUnpost') | |
| 1308 def tk_traverseToMenu(self, char): | |
| 1309 self.tk.call('tk_traverseToMenu', self._w, char) | |
| 1310 def tk_traverseWithinMenu(self, char): | |
| 1311 self.tk.call('tk_traverseWithinMenu', self._w, char) | |
| 1312 def tk_getMenuButtons(self): | |
| 1313 return self.tk.call('tk_getMenuButtons', self._w) | |
| 1314 def tk_nextMenu(self, count): | |
| 1315 self.tk.call('tk_nextMenu', count) | |
| 1316 def tk_nextMenuEntry(self, count): | |
| 1317 self.tk.call('tk_nextMenuEntry', count) | |
| 1318 def tk_invokeMenu(self): | |
| 1319 self.tk.call('tk_invokeMenu', self._w) | |
| 1320 def tk_firstMenu(self): | |
| 1321 self.tk.call('tk_firstMenu', self._w) | |
| 1322 def tk_mbButtonDown(self): | |
| 1323 self.tk.call('tk_mbButtonDown', self._w) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1324 def tk_popup(self, x, y, entry=""): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1325 self.tk.call('tk_popup', self._w, x, y, entry) |
| 1664 | 1326 def activate(self, index): |
| 1327 self.tk.call(self._w, 'activate', index) | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1328 def add(self, itemType, cnf={}, **kw): |
| 1664 | 1329 apply(self.tk.call, (self._w, 'add', itemType) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1330 + self._options(cnf, kw)) |
|
3180
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1331 def add_cascade(self, cnf={}, **kw): |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1332 self.add('cascade', cnf or kw) |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1333 def add_checkbutton(self, cnf={}, **kw): |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1334 self.add('checkbutton', cnf or kw) |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1335 def add_command(self, cnf={}, **kw): |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1336 self.add('command', cnf or kw) |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1337 def add_radiobutton(self, cnf={}, **kw): |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1338 self.add('radiobutton', cnf or kw) |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1339 def add_separator(self, cnf={}, **kw): |
|
a42012c188fd
fix Menu.add_command etc.
Guido van Rossum <guido@python.org>
parents:
3151
diff
changeset
|
1340 self.add('separator', cnf or kw) |
|
4212
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1341 def insert(self, index, itemType, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1342 apply(self.tk.call, (self._w, 'insert', index, itemType) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1343 + self._options(cnf, kw)) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1344 def insert_cascade(self, index, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1345 self.insert(index, 'cascade', cnf or kw) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1346 def insert_checkbutton(self, index, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1347 self.insert(index, 'checkbutton', cnf or kw) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1348 def insert_command(self, index, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1349 self.insert(index, 'command', cnf or kw) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1350 def insert_radiobutton(self, index, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1351 self.insert(index, 'radiobutton', cnf or kw) |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1352 def insert_separator(self, index, cnf={}, **kw): |
|
d7018bc5584e
Added Menu.insert*() methods [Fred]
Guido van Rossum <guido@python.org>
parents:
4211
diff
changeset
|
1353 self.insert(index, 'separator', cnf or kw) |
| 1664 | 1354 def delete(self, index1, index2=None): |
| 1355 self.tk.call(self._w, 'delete', index1, index2) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1356 def entryconfig(self, index, cnf=None, **kw): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1357 if cnf is None and not kw: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1358 cnf = {} |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1359 for x in self.tk.split(apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1360 (self._w, 'entryconfigure', index))): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1361 cnf[x[0][1:]] = (x[0][1:],) + x[1:] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1362 return cnf |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1363 if type(cnf) == StringType and not kw: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1364 x = self.tk.split(apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1365 (self._w, 'entryconfigure', index, '-'+cnf))) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1366 return (x[0][1:],) + x[1:] |
| 1664 | 1367 apply(self.tk.call, (self._w, 'entryconfigure', index) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1368 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1369 entryconfigure = entryconfig |
| 1664 | 1370 def index(self, index): |
| 1689 | 1371 i = self.tk.call(self._w, 'index', index) |
| 1372 if i == 'none': return None | |
| 1373 return self.tk.getint(i) | |
| 1664 | 1374 def invoke(self, index): |
| 1375 return self.tk.call(self._w, 'invoke', index) | |
| 1376 def post(self, x, y): | |
| 1377 self.tk.call(self._w, 'post', x, y) | |
| 1378 def unpost(self): | |
| 1379 self.tk.call(self._w, 'unpost') | |
| 1380 def yposition(self, index): | |
| 1381 return self.tk.getint(self.tk.call( | |
| 1382 self._w, 'yposition', index)) | |
| 1383 | |
| 1384 class Menubutton(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1385 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1386 Widget.__init__(self, master, 'menubutton', cnf, kw) |
| 1664 | 1387 |
| 1388 class Message(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1389 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1390 Widget.__init__(self, master, 'message', cnf, kw) |
| 1664 | 1391 |
| 1392 class Radiobutton(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1393 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1394 Widget.__init__(self, master, 'radiobutton', cnf, kw) |
| 1664 | 1395 def deselect(self): |
| 1396 self.tk.call(self._w, 'deselect') | |
| 1397 def flash(self): | |
| 1398 self.tk.call(self._w, 'flash') | |
| 1399 def invoke(self): | |
| 1400 self.tk.call(self._w, 'invoke') | |
| 1401 def select(self): | |
| 1402 self.tk.call(self._w, 'select') | |
| 1403 | |
| 1404 class Scale(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1405 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1406 Widget.__init__(self, master, 'scale', cnf, kw) |
| 1664 | 1407 def get(self): |
|
4457
ab60c5585d1b
Added support for floating point resolution to Scale.get().
Guido van Rossum <guido@python.org>
parents:
4429
diff
changeset
|
1408 value = self.tk.call(self._w, 'get') |
|
ab60c5585d1b
Added support for floating point resolution to Scale.get().
Guido van Rossum <guido@python.org>
parents:
4429
diff
changeset
|
1409 try: |
|
ab60c5585d1b
Added support for floating point resolution to Scale.get().
Guido van Rossum <guido@python.org>
parents:
4429
diff
changeset
|
1410 return self.tk.getint(value) |
|
ab60c5585d1b
Added support for floating point resolution to Scale.get().
Guido van Rossum <guido@python.org>
parents:
4429
diff
changeset
|
1411 except TclError: |
|
ab60c5585d1b
Added support for floating point resolution to Scale.get().
Guido van Rossum <guido@python.org>
parents:
4429
diff
changeset
|
1412 return self.tk.getdouble(value) |
| 1664 | 1413 def set(self, value): |
| 1414 self.tk.call(self._w, 'set', value) | |
| 1415 | |
| 1416 class Scrollbar(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1417 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1418 Widget.__init__(self, master, 'scrollbar', cnf, kw) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1419 def activate(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1420 self.tk.call(self._w, 'activate', index) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1421 def delta(self, deltax, deltay): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1422 return self.getdouble(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1423 self._w, 'delta', deltax, deltay)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1424 def fraction(self, x, y): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1425 return self.getdouble(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1426 self._w, 'fraction', x, y)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1427 def identify(self, x, y): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1428 return self.tk.call(self._w, 'identify', x, y) |
| 1664 | 1429 def get(self): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1430 return self._getdoubles(self.tk.call(self._w, 'get')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1431 def set(self, *args): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1432 apply(self.tk.call, (self._w, 'set')+args) |
| 1664 | 1433 |
| 1434 class Text(Widget): | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1435 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1436 Widget.__init__(self, master, 'text', cnf, kw) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1437 def bbox(self, *args): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1438 return self._getints(self._do('bbox', args)) or None |
| 1664 | 1439 def tk_textSelectTo(self, index): |
| 1440 self.tk.call('tk_textSelectTo', self._w, index) | |
| 1441 def tk_textBackspace(self): | |
| 1442 self.tk.call('tk_textBackspace', self._w) | |
| 1443 def tk_textIndexCloser(self, a, b, c): | |
| 1444 self.tk.call('tk_textIndexCloser', self._w, a, b, c) | |
| 1445 def tk_textResetAnchor(self, index): | |
| 1446 self.tk.call('tk_textResetAnchor', self._w, index) | |
| 1447 def compare(self, index1, op, index2): | |
| 1448 return self.tk.getboolean(self.tk.call( | |
| 1449 self._w, 'compare', index1, op, index2)) | |
| 1450 def debug(self, boolean=None): | |
| 1451 return self.tk.getboolean(self.tk.call( | |
| 1452 self._w, 'debug', boolean)) | |
| 1453 def delete(self, index1, index2=None): | |
| 1454 self.tk.call(self._w, 'delete', index1, index2) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1455 def dlineinfo(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1456 return self._getints(self.tk.call(self._w, 'dlineinfo', index)) |
| 1664 | 1457 def get(self, index1, index2=None): |
| 1458 return self.tk.call(self._w, 'get', index1, index2) | |
| 1459 def index(self, index): | |
| 1460 return self.tk.call(self._w, 'index', index) | |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1461 def insert(self, index, chars, *args): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1462 apply(self.tk.call, (self._w, 'insert', index, chars)+args) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1463 def mark_gravity(self, markName, direction=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1464 return apply(self.tk.call, |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1465 (self._w, 'mark', 'gravity', markName, direction)) |
| 1664 | 1466 def mark_names(self): |
| 1467 return self.tk.splitlist(self.tk.call( | |
| 1468 self._w, 'mark', 'names')) | |
| 1469 def mark_set(self, markName, index): | |
| 1470 self.tk.call(self._w, 'mark', 'set', markName, index) | |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1471 def mark_unset(self, *markNames): |
| 1664 | 1472 apply(self.tk.call, (self._w, 'mark', 'unset') + markNames) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1473 def scan_mark(self, x, y): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1474 self.tk.call(self._w, 'scan', 'mark', x, y) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1475 def scan_dragto(self, x, y): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1476 self.tk.call(self._w, 'scan', 'dragto', x, y) |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1477 def search(self, pattern, index, stopindex=None, |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1478 forwards=None, backwards=None, exact=None, |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1479 regexp=None, nocase=None, count=None): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1480 args = [self._w, 'search'] |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1481 if forwards: args.append('-forwards') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1482 if backwards: args.append('-backwards') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1483 if exact: args.append('-exact') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1484 if regexp: args.append('-regexp') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1485 if nocase: args.append('-nocase') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1486 if count: args.append('-count'); args.append(count) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1487 if pattern[0] == '-': args.append('--') |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1488 args.append(pattern) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1489 args.append(index) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1490 if stopindex: args.append(stopindex) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1491 return apply(self.tk.call, tuple(args)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1492 def see(self, index): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1493 self.tk.call(self._w, 'see', index) |
| 1664 | 1494 def tag_add(self, tagName, index1, index2=None): |
| 1495 self.tk.call( | |
| 1496 self._w, 'tag', 'add', tagName, index1, index2) | |
|
1768
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
1497 def tag_unbind(self, tagName, sequence): |
|
68812b763e0e
Add Widget.unbind and {Canvas,Text}.tag_unbind.
Guido van Rossum <guido@python.org>
parents:
1726
diff
changeset
|
1498 self.tk.call(self._w, 'tag', 'bind', tagName, sequence, '') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1499 def tag_bind(self, tagName, sequence, func, add=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1500 return self._bind((self._w, 'tag', 'bind', tagName), |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1501 sequence, func, add) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1502 def tag_cget(self, tagName, option): |
|
4533
62cef7e896b6
Don't require leading '-' on option name to Text.tag_cget
Guido van Rossum <guido@python.org>
parents:
4488
diff
changeset
|
1503 if option[:1] != '-': |
|
62cef7e896b6
Don't require leading '-' on option name to Text.tag_cget
Guido van Rossum <guido@python.org>
parents:
4488
diff
changeset
|
1504 option = '-' + option |
|
62cef7e896b6
Don't require leading '-' on option name to Text.tag_cget
Guido van Rossum <guido@python.org>
parents:
4488
diff
changeset
|
1505 if option[-1:] == '_': |
|
62cef7e896b6
Don't require leading '-' on option name to Text.tag_cget
Guido van Rossum <guido@python.org>
parents:
4488
diff
changeset
|
1506 option = option[:-1] |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1507 return self.tk.call(self._w, 'tag', 'cget', tagName, option) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1508 def tag_config(self, tagName, cnf={}, **kw): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1509 if type(cnf) == StringType: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1510 x = self.tk.split(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1511 self._w, 'tag', 'configure', tagName, '-'+cnf)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1512 return (x[0][1:],) + x[1:] |
| 1664 | 1513 apply(self.tk.call, |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1514 (self._w, 'tag', 'configure', tagName) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1515 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1516 tag_configure = tag_config |
|
1703
ba957aa42241
Tue Jul 5 13:22:45 1994 (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1700
diff
changeset
|
1517 def tag_delete(self, *tagNames): |
|
1707
6f81b13fd6ac
Remove garbage '+ ' and reformat tag_delete function budy
Guido van Rossum <guido@python.org>
parents:
1703
diff
changeset
|
1518 apply(self.tk.call, (self._w, 'tag', 'delete') + tagNames) |
| 1664 | 1519 def tag_lower(self, tagName, belowThis=None): |
|
1714
db0eaef42cb9
Added _exit and register as Tcl command exit. Micro lay-out fix.
Guido van Rossum <guido@python.org>
parents:
1709
diff
changeset
|
1520 self.tk.call(self._w, 'tag', 'lower', tagName, belowThis) |
| 1664 | 1521 def tag_names(self, index=None): |
| 1522 return self.tk.splitlist( | |
| 1523 self.tk.call(self._w, 'tag', 'names', index)) | |
| 1524 def tag_nextrange(self, tagName, index1, index2=None): | |
| 1525 return self.tk.splitlist(self.tk.call( | |
|
2585
7042aee6409e
fix typo in tag_nextrange
Guido van Rossum <guido@python.org>
parents:
2577
diff
changeset
|
1526 self._w, 'tag', 'nextrange', tagName, index1, index2)) |
| 1664 | 1527 def tag_raise(self, tagName, aboveThis=None): |
| 1528 self.tk.call( | |
| 1529 self._w, 'tag', 'raise', tagName, aboveThis) | |
| 1530 def tag_ranges(self, tagName): | |
| 1531 return self.tk.splitlist(self.tk.call( | |
| 1532 self._w, 'tag', 'ranges', tagName)) | |
| 1533 def tag_remove(self, tagName, index1, index2=None): | |
| 1534 self.tk.call( | |
|
1709
375b8b863126
tag_remove: add tagName to tk call
Guido van Rossum <guido@python.org>
parents:
1707
diff
changeset
|
1535 self._w, 'tag', 'remove', tagName, index1, index2) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1536 def window_cget(self, index, option): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1537 return self.tk.call(self._w, 'window', 'cget', index, option) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1538 def window_config(self, index, cnf={}, **kw): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1539 if type(cnf) == StringType: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1540 x = self.tk.split(self.tk.call( |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1541 self._w, 'window', 'configure', |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1542 index, '-'+cnf)) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1543 return (x[0][1:],) + x[1:] |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1544 apply(self.tk.call, |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1545 (self._w, 'window', 'configure', index) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1546 + self._options(cnf, kw)) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1547 window_configure = window_config |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1548 def window_create(self, index, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1549 apply(self.tk.call, |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1550 (self._w, 'window', 'create', index) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1551 + self._options(cnf, kw)) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1552 def window_names(self): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1553 return self.tk.splitlist( |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1554 self.tk.call(self._w, 'window', 'names')) |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1555 def xview(self, *what): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1556 if not what: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1557 return self._getdoubles(self.tk.call(self._w, 'xview')) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1558 apply(self.tk.call, (self._w, 'xview')+what) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1559 def yview(self, *what): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1560 if not what: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1561 return self._getdoubles(self.tk.call(self._w, 'yview')) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1562 apply(self.tk.call, (self._w, 'yview')+what) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1563 def yview_pickplace(self, *what): |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1564 apply(self.tk.call, (self._w, 'yview', '-pickplace')+what) |
| 1664 | 1565 |
|
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
|
1566 class _setit: |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1567 def __init__(self, var, value): |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1568 self.__value = value |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1569 self.__var = var |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1570 def __call__(self, *args): |
|
4429
34eeb61f1028
(Tkinter.py): Fixed bug in re-implementation of OptionMenu.
Fred Drake <fdrake@acm.org>
parents:
4428
diff
changeset
|
1571 self.__var.set(self.__value) |
|
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
|
1572 |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1573 class OptionMenu(Menubutton): |
|
3067
6ec820db2ffa
added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents:
2968
diff
changeset
|
1574 def __init__(self, master, variable, value, *values): |
|
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
|
1575 kw = {"borderwidth": 2, "textvariable": variable, |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1576 "indicatoron": 1, "relief": RAISED, "anchor": "c", |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1577 "highlightthickness": 2} |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1578 Widget.__init__(self, master, "menubutton", kw) |
|
3067
6ec820db2ffa
added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents:
2968
diff
changeset
|
1579 self.widgetName = 'tk_optionMenu' |
|
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
|
1580 menu = self.__menu = Menu(self, name="menu", tearoff=0) |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1581 self.menuname = menu._w |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1582 menu.add_command(label=value, command=_setit(variable, value)) |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1583 for v in values: |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1584 menu.add_command(label=v, command=_setit(variable, v)) |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1585 self["menu"] = menu |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1586 |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1587 def __getitem__(self, name): |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1588 if name == 'menu': |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1589 return self.__menu |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1590 return Widget.__getitem__(self, name) |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1591 |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1592 def destroy(self): |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1593 Menubutton.destroy(self) |
|
938be7a3106f
(Fred Drake:) Re-wrote the OptionMenu class to allow access to a real
Guido van Rossum <guido@python.org>
parents:
4358
diff
changeset
|
1594 self.__menu = None |
|
3067
6ec820db2ffa
added OptionMenu class (tk_optionMenu interface)
Guido van Rossum <guido@python.org>
parents:
2968
diff
changeset
|
1595 |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1596 class Image: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1597 def __init__(self, imgtype, name=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1598 self.name = None |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1599 master = _default_root |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1600 if not master: raise RuntimeError, 'Too early to create image' |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1601 self.tk = master.tk |
|
4560
b217da3f9b54
Turn leading minus sign into underscore for image widget name -- the
Guido van Rossum <guido@python.org>
parents:
4533
diff
changeset
|
1602 if not name: |
|
b217da3f9b54
Turn leading minus sign into underscore for image widget name -- the
Guido van Rossum <guido@python.org>
parents:
4533
diff
changeset
|
1603 name = `id(self)` |
|
b217da3f9b54
Turn leading minus sign into underscore for image widget name -- the
Guido van Rossum <guido@python.org>
parents:
4533
diff
changeset
|
1604 # The following is needed for systems where id(x) |
|
b217da3f9b54
Turn leading minus sign into underscore for image widget name -- the
Guido van Rossum <guido@python.org>
parents:
4533
diff
changeset
|
1605 # can return a negative number, such as Linux/m68k: |
|
b217da3f9b54
Turn leading minus sign into underscore for image widget name -- the
Guido van Rossum <guido@python.org>
parents:
4533
diff
changeset
|
1606 if name[0] == '-': name = '_' + name[1:] |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1607 if kw and cnf: cnf = _cnfmerge((cnf, kw)) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1608 elif kw: cnf = kw |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1609 options = () |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1610 for k, v in cnf.items(): |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1611 if callable(v): |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1612 v = self._register(v) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1613 options = options + ('-'+k, v) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1614 apply(self.tk.call, |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1615 ('image', 'create', imgtype, name,) + options) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1616 self.name = name |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1617 def __str__(self): return self.name |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1618 def __del__(self): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1619 if self.name: |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1620 self.tk.call('image', 'delete', self.name) |
|
3107
3dc9ff3abf36
added getitem/setitem to Image class; changed call wrapping (again)
Guido van Rossum <guido@python.org>
parents:
3071
diff
changeset
|
1621 def __setitem__(self, key, value): |
|
3dc9ff3abf36
added getitem/setitem to Image class; changed call wrapping (again)
Guido van Rossum <guido@python.org>
parents:
3071
diff
changeset
|
1622 self.tk.call(self.name, 'configure', '-'+key, value) |
|
3dc9ff3abf36
added getitem/setitem to Image class; changed call wrapping (again)
Guido van Rossum <guido@python.org>
parents:
3071
diff
changeset
|
1623 def __getitem__(self, key): |
|
3dc9ff3abf36
added getitem/setitem to Image class; changed call wrapping (again)
Guido van Rossum <guido@python.org>
parents:
3071
diff
changeset
|
1624 return self.tk.call(self.name, 'configure', '-'+key) |
|
4833
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1625 def config(self, **kw): |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1626 res = () |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1627 for k, v in _cnfmerge(kw).items(): |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1628 if v is not None: |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1629 if k[-1] == '_': k = k[:-1] |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1630 if callable(v): |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1631 v = self._register(v) |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1632 res = res + ('-'+k, v) |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1633 apply(self.tk.call, (self.name, 'config') + res) |
|
339d0c49f0b5
Added config(ure) method to Image class.
Guido van Rossum <guido@python.org>
parents:
4832
diff
changeset
|
1634 configure = config |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1635 def height(self): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1636 return self.tk.getint( |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1637 self.tk.call('image', 'height', self.name)) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1638 def type(self): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1639 return self.tk.call('image', 'type', self.name) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1640 def width(self): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1641 return self.tk.getint( |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1642 self.tk.call('image', 'width', self.name)) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1643 |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1644 class PhotoImage(Image): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1645 def __init__(self, name=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1646 apply(Image.__init__, (self, 'photo', name, cnf), kw) |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1647 def blank(self): |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1648 self.tk.call(self.name, 'blank') |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1649 def cget(self, option): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1650 return self.tk.call(self.name, 'cget', '-' + option) |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1651 # XXX config |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1652 def __getitem__(self, key): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1653 return self.tk.call(self.name, 'cget', '-' + key) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1654 def copy(self): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1655 destImage = PhotoImage() |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1656 self.tk.call(destImage, 'copy', self.name) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1657 return destImage |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1658 def zoom(self,x,y=''): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1659 destImage = PhotoImage() |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1660 if y=='': y=x |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1661 self.tk.call(destImage, 'copy', self.name, '-zoom',x,y) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1662 return destImage |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1663 def subsample(self,x,y=''): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1664 destImage = PhotoImage() |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1665 if y=='': y=x |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1666 self.tk.call(destImage, 'copy', self.name, '-subsample',x,y) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1667 return destImage |
|
3137
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1668 def get(self, x, y): |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1669 return self.tk.call(self.name, 'get', x, y) |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1670 def put(self, data, to=None): |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1671 args = (self.name, 'put', data) |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1672 if to: |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1673 args = args + to |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1674 apply(self.tk.call, args) |
|
adcc916b7616
new after options; text.search; new image methods
Guido van Rossum <guido@python.org>
parents:
3107
diff
changeset
|
1675 # XXX read |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1676 def write(self, filename, format=None, from_coords=None): |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1677 args = (self.name, 'write', filename) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1678 if format: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1679 args = args + ('-format', format) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1680 if from_coords: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1681 args = args + ('-from',) + tuple(from_coords) |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1682 apply(self.tk.call, args) |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1683 |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1684 class BitmapImage(Image): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1685 def __init__(self, name=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1686 apply(Image.__init__, (self, 'bitmap', name, cnf), kw) |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1687 |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1688 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
|
1689 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
|
1690 |
|
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
|
1691 ###################################################################### |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
1692 # 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
|
1693 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
1694 class Studbutton(Button): |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1695 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1696 Widget.__init__(self, master, 'studbutton', cnf, kw) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1697 self.bind('<Any-Enter>', self.tkButtonEnter) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1698 self.bind('<Any-Leave>', self.tkButtonLeave) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1699 self.bind('<1>', self.tkButtonDown) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1700 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
|
1701 |
|
bb61816e1dab
Sun Jun 26 02:19:01 1994 Steen Lumholt (lumholt@login.dkuug.dk)
Guido van Rossum <guido@python.org>
parents:
1687
diff
changeset
|
1702 class Tributton(Button): |
|
2884
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1703 def __init__(self, master=None, cnf={}, **kw): |
|
e006ed88b4aa
keyword arguments; redid Photo image class; other goodies
Guido van Rossum <guido@python.org>
parents:
2830
diff
changeset
|
1704 Widget.__init__(self, master, 'tributton', cnf, kw) |
|
2830
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1705 self.bind('<Any-Enter>', self.tkButtonEnter) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1706 self.bind('<Any-Leave>', self.tkButtonLeave) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1707 self.bind('<1>', self.tkButtonDown) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1708 self.bind('<ButtonRelease-1>', self.tkButtonUp) |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1709 self['fg'] = self['bg'] |
|
bd79cd768ff8
Tk 4.0 and Tcl 7.4 are now standard
Guido van Rossum <guido@python.org>
parents:
2585
diff
changeset
|
1710 self['activebackground'] = self['bg'] |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1711 |
|
4103
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1712 ###################################################################### |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1713 # Test: |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1714 |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1715 def _test(): |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1716 root = Tk() |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1717 label = Label(root, text="Proof-of-existence test for Tk") |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1718 label.pack() |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1719 test = Button(root, text="Click me!", |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1720 command=lambda root=root: root.test.config( |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1721 text="[%s]" % root.test['text'])) |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1722 test.pack() |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1723 root.test = test |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1724 quit = Button(root, text="QUIT", command=root.destroy) |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1725 quit.pack() |
|
5454
0f6c96f48e1b
Add root.tkraise() to the _test() program so the window doesn't hide
Guido van Rossum <guido@python.org>
parents:
5400
diff
changeset
|
1726 root.tkraise() |
|
4103
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1727 root.mainloop() |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1728 |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1729 if __name__ == '__main__': |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1730 _test() |
|
a5a82666977b
Added a small test program.
Guido van Rossum <guido@python.org>
parents:
3952
diff
changeset
|
1731 |
|
3551
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1732 |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1733 # Emacs cruft |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1734 # Local Variables: |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1735 # py-indent-offset: 8 |
|
e8a2a5e4c7b0
Resync with Grail's Tkinter.py.
Guido van Rossum <guido@python.org>
parents:
3246
diff
changeset
|
1736 # End: |
