annotate Lib/tkinter/Canvas.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 376822c65810
children c7e99ab627f3
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)
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
46 def config(self, cnf={}, **kw):
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
47 return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 def coords(self, pts = ()):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 flat = ()
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 for x, y in pts: flat = flat + (x, y)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 return apply(self.canvas.coords, (self.id,) + flat)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 def dchars(self, first, last=None):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 self.canvas.dchars(self.id, first, last)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 def dtag(self, ttd):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 self.canvas.dtag(self.id, ttd)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 def focus(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 self.canvas.focus(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 def gettags(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 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
60 def icursor(self, index):
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
61 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
62 def index(self, index):
ae178f150403 Bug fixes in index&icursor suggested by Nils Fischbeck.
Guido van Rossum <guido@python.org>
parents: 4222
diff changeset
63 return self.canvas.index(self.id, index)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 def insert(self, beforethis, string):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 self.canvas.insert(self.id, beforethis, string)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 def lower(self, belowthis=None):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 self.canvas.lower(self.id, belowthis)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 def move(self, xamount, yamount):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 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
70 def tkraise(self, abovethis=None):
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
71 self.canvas.tkraise(self.id, abovethis)
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
72 raise_ = tkraise # BW compat
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 def scale(self, xorigin, yorigin, xscale, yscale):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 self.canvas.scale(self.id, xorigin, yorigin, xscale, yscale)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 def type(self):
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 return self.canvas.type(self.id)
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
77
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 class Arc(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
79 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
80 apply(CanvasItem.__init__, (self, canvas, 'arc') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
81
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 class Bitmap(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
83 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
84 apply(CanvasItem.__init__, (self, canvas, 'bitmap') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
3644
017d3356a5ed made it work again with changed Tkinter
Guido van Rossum <guido@python.org>
parents: 3363
diff changeset
86 class ImageItem(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
87 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
88 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
89
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 class Line(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
91 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
92 apply(CanvasItem.__init__, (self, canvas, 'line') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
93
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
94 class Oval(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
95 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
96 apply(CanvasItem.__init__, (self, canvas, 'oval') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
97
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 class Polygon(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
99 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
100 apply(CanvasItem.__init__, (self, canvas, 'polygon') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
101
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 class Rectangle(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
103 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
104 apply(CanvasItem.__init__, (self, canvas, 'rectangle') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
105
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
106 # XXX "Text" is taken by the Text widget...
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
107 class CanvasText(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
108 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
109 apply(CanvasItem.__init__, (self, canvas, 'text') + args, kw)
1664
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
110
a09efb135de5 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 class Window(CanvasItem):
4115
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
112 def __init__(self, canvas, *args, **kw):
23589c016cb9 Changes for Canvas by Fred
Guido van Rossum <guido@python.org>
parents: 3951
diff changeset
113 apply(CanvasItem.__init__, (self, canvas, 'window') + args, kw)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
114
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
115 class Group:
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
116 def __init__(self, canvas, tag=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
117 if not tag:
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
118 tag = 'Group%d' % id(self)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
119 self.tag = self.id = tag
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
120 self.canvas = canvas
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
121 self.canvas.dtag(self.tag)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
122 def str(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
123 return self.tag
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
124 __str__ = str
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
125 def _do(self, cmd, *args):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
126 return self.canvas._do(cmd, (self.tag,) + _flatten(args))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
127 def addtag_above(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
128 self._do('addtag', 'above', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
129 def addtag_all(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
130 self._do('addtag', 'all')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
131 def addtag_below(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
132 self._do('addtag', 'below', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
133 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
134 self._do('addtag', 'closest', x, y, halo, start)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
135 def addtag_enclosed(self, x1, y1, x2, y2):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
136 self._do('addtag', 'enclosed', x1, y1, x2, y2)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
137 def addtag_overlapping(self, x1, y1, x2, y2):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
138 self._do('addtag', 'overlapping', x1, y1, x2, y2)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
139 def addtag_withtag(self, tagOrId):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
140 self._do('addtag', 'withtag', tagOrId)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
141 def bbox(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
142 return self._getints(self._do('bbox'))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
143 def bind(self, sequence=None, command=None): # XXX args?
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
144 return self._do('bind', sequence, command)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
145 def coords(self, *pts):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
146 return self._do('coords', pts)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
147 def dchars(self, first, last=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
148 self._do('dchars', first, last)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
149 def delete(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
150 self._do('delete')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
151 def dtag(self, tagToDelete=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
152 self._do('dtag', tagToDelete)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
153 def focus(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
154 self._do('focus')
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
155 def gettags(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
156 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
157 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
158 return self._do('icursor', index)
1695
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
159 def index(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
160 return self.canvas.tk.getint(self._do('index', index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
161 def insert(self, beforeThis, string):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
162 self._do('insert', beforeThis, string)
4222
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
163 def config(self, cnf={}, **kw):
1d1f0c647e77 Change to allow keyword args for Group,
Guido van Rossum <guido@python.org>
parents: 4115
diff changeset
164 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
165 def lower(self, belowThis=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
166 self._do('lower', belowThis)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
167 def move(self, xAmount, yAmount):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
168 self._do('move', xAmount, yAmount)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
169 def tkraise(self, aboveThis=None):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
170 self._do('raise', aboveThis)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
171 lift = tkraise
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
172 def scale(self, xOrigin, yOrigin, xScale, yScale):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
173 self._do('scale', xOrigin, yOrigin, xScale, yScale)
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
174 def select_adjust(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
175 self.canvas._do('select', ('adjust', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
176 def select_from(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
177 self.canvas._do('select', ('from', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
178 def select_to(self, index):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
179 self.canvas._do('select', ('to', self.tag, index))
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
180 def type(self):
c50127809179 Lots of new stuff
Guido van Rossum <guido@python.org>
parents: 1673
diff changeset
181 return self._do('type')