annotate Lib/lib-tk/Canvas.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents c7e99ab627f3
children 9c37ed8868b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # This module exports classes for the various canvas item types
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
3 from Tkinter import Canvas, _cnfmerge, _flatten
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
5
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 class CanvasItem:
3363
369b30f78d63 add keyword args to CanvasItem class __init__
Guido van Rossum <guido@python.org>
parents: 1695
diff changeset
7 def __init__(self, canvas, itemType, *args, **kw):
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 self.canvas = canvas
3363
369b30f78d63 add keyword args to CanvasItem class __init__
Guido van Rossum <guido@python.org>
parents: 1695
diff changeset
9 self.id = canvas._create(itemType, args, kw)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
10 if not hasattr(canvas, 'items'):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
11 canvas.items = {}
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
12 canvas.items[self.id] = self
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 def __str__(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 return str(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 def __repr__(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 return '<%s, id=%d>' % (self.__class__.__name__, self.id)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
17 def delete(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
18 del self.canvas.items[self.id]
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 self.canvas.delete(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 def __getitem__(self, key):
1673
344dd28da9c5 Reformatted using 8-space wide tabs
Guido van Rossum <guido@python.org>
parents: 1664
diff changeset
21 v = self.canvas.tk.split(self.canvas.tk.call(
344dd28da9c5 Reformatted using 8-space wide tabs
Guido van Rossum <guido@python.org>
parents: 1664
diff changeset
22 self.canvas._w, 'itemconfigure',
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
23 self.id, '-' + key))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 return v[4]
4337
376822c65810 (Canvas.py): Added definition of CanvasItem.cget() as suggested by
Fred Drake <fdrake@acm.org>
parents: 4276
diff changeset
25 cget = __getitem__
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 def __setitem__(self, key, value):
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
27 self.canvas.itemconfig(self.id, {key: value})
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 def keys(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 if not hasattr(self, '_keys'):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 self._keys = map(lambda x, tk=self.canvas.tk:
1673
344dd28da9c5 Reformatted using 8-space wide tabs
Guido van Rossum <guido@python.org>
parents: 1664
diff changeset
31 tk.splitlist(x)[0][1:],
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
32 self.canvas.tk.splitlist(
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
33 self.canvas._do(
1673
344dd28da9c5 Reformatted using 8-space wide tabs
Guido van Rossum <guido@python.org>
parents: 1664
diff changeset
34 'itemconfigure',
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
35 (self.id,))))
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
36 return self._keys
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 def has_key(self, key):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 return key in self.keys()
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 def addtag(self, tag, option='withtag'):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 self.canvas.addtag(tag, option, self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 def bbox(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 x1, y1, x2, y2 = self.canvas.bbox(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 return (x1, y1), (x2, y2)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 def bind(self, sequence=None, command=None):
3756
82bb7d2a6b31 fix canvas bind commands
Guido van Rossum <guido@python.org>
parents: 3644
diff changeset
45 return self.canvas.tag_bind(self.id, sequence, command)
4834
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
46 def unbind(self, sequence):
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
47 self.canvas.tag_bind(self.id, sequence, '')
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
48 def config(self, cnf={}, **kw):
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
49 return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 def coords(self, pts = ()):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 flat = ()
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 for x, y in pts: flat = flat + (x, y)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 return apply(self.canvas.coords, (self.id,) + flat)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 def dchars(self, first, last=None):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 self.canvas.dchars(self.id, first, last)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 def dtag(self, ttd):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 self.canvas.dtag(self.id, ttd)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 def focus(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 self.canvas.focus(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 def gettags(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 return self.canvas.gettags(self.id)
4276
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
62 def icursor(self, index):
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
63 self.canvas.icursor(self.id, index)
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
64 def index(self, index):
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
65 return self.canvas.index(self.id, index)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 def insert(self, beforethis, string):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 self.canvas.insert(self.id, beforethis, string)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 def lower(self, belowthis=None):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 self.canvas.lower(self.id, belowthis)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 def move(self, xamount, yamount):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 self.canvas.move(self.id, xamount, yamount)
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
72 def tkraise(self, abovethis=None):
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
73 self.canvas.tkraise(self.id, abovethis)
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
74 raise_ = tkraise # BW compat
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 def scale(self, xorigin, yorigin, xscale, yscale):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 self.canvas.scale(self.id, xorigin, yorigin, xscale, yscale)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 def type(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 return self.canvas.type(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 class Arc(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
81 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
82 apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
83
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 class Bitmap(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
85 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
86 apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
88 class ImageItem(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
89 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
90 apply(CanvasItem.__init__, (self, canvas, 'image') + args, kw)
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
91
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 class Line(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
93 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
94 apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
95
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 class Oval(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
97 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
98 apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 class Polygon(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
101 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
102 apply(CanvasItem.__init__, (self, canvas, 'polygon') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
103
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 class Rectangle(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
105 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
106 apply(CanvasItem.__init__, (self, canvas, 'rectangle') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
107
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
108 # XXX "Text" is taken by the Text widget...
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
109 class CanvasText(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
110 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
111 apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
112
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 class Window(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
114 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
115 apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
116
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
117 class Group:
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
118 def __init__(self, canvas, tag=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
119 if not tag:
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
120 tag = 'Group%d' % id(self)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
121 self.tag = self.id = tag
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
122 self.canvas = canvas
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
123 self.canvas.dtag(self.tag)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
124 def str(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
125 return self.tag
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
126 __str__ = str
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
127 def _do(self, cmd, *args):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
128 return self.canvas._do(cmd, (self.tag,) + _flatten(args))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
129 def addtag_above(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
130 self._do('addtag', 'above', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
131 def addtag_all(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
132 self._do('addtag', 'all')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
133 def addtag_below(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
134 self._do('addtag', 'below', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
135 def addtag_closest(self, x, y, halo=None, start=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
136 self._do('addtag', 'closest', x, y, halo, start)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
137 def addtag_enclosed(self, x1, y1, x2, y2):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
138 self._do('addtag', 'enclosed', x1, y1, x2, y2)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
139 def addtag_overlapping(self, x1, y1, x2, y2):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
140 self._do('addtag', 'overlapping', x1, y1, x2, y2)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
141 def addtag_withtag(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
142 self._do('addtag', 'withtag', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
143 def bbox(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
144 return self._getints(self._do('bbox'))
4834
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
145 def bind(self, sequence=None, command=None):
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
146 return self.canvas.tag_bind(self.id, sequence, command)
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
147 def unbind(self, sequence):
c7e99ab627f3 Fix bogus implementation of Group.bind().
Guido van Rossum <guido@python.org>
parents: 4337
diff changeset
148 self.canvas.tag_bind(self.id, sequence, '')
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
149 def coords(self, *pts):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
150 return self._do('coords', pts)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
151 def dchars(self, first, last=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
152 self._do('dchars', first, last)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
153 def delete(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
154 self._do('delete')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
155 def dtag(self, tagToDelete=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
156 self._do('dtag', tagToDelete)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
157 def focus(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
158 self._do('focus')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
159 def gettags(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
160 return self.canvas.tk.splitlist(self._do('gettags', self.tag))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
161 def icursor(self, index):
4276
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
162 return self._do('icursor', index)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
163 def index(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
164 return self.canvas.tk.getint(self._do('index', index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
165 def insert(self, beforeThis, string):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
166 self._do('insert', beforeThis, string)
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
167 def config(self, cnf={}, **kw):
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
168 return self.canvas.itemconfigure(self.tag, _cnfmerge((cnf,kw)))
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
169 def lower(self, belowThis=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
170 self._do('lower', belowThis)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
171 def move(self, xAmount, yAmount):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
172 self._do('move', xAmount, yAmount)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
173 def tkraise(self, aboveThis=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
174 self._do('raise', aboveThis)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
175 lift = tkraise
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
176 def scale(self, xOrigin, yOrigin, xScale, yScale):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
177 self._do('scale', xOrigin, yOrigin, xScale, yScale)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
178 def select_adjust(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
179 self.canvas._do('select', ('adjust', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
180 def select_from(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
181 self.canvas._do('select', ('from', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
182 def select_to(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
183 self.canvas._do('select', ('to', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
184 def type(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
185 return self._do('type')