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