collective behaviour of canvas in Tkinter
Doug Hellmann
doughellmann at home.com
Fri Mar 3 10:54:39 EST 2000
T.Rafie at ALCATEL.de wrote:
>
> If one wants to move a single canvas item, say item, on a base canvas
> base one can move it
> using base.move(item, stepx, stepy) . I want to shift a collection
> of items (item1,item2,...) by
> the same amount (stepx,stepy). The only solution i found was using a
> loop over all items
> (or alternatively use map one time). But it became very slow for a
> large collection - a few thousend.
> Is there a possibility to bind them together, acting as a collective
> (as one could imagine that
> all letters in a text-canvas-item are bound together and the
> text-canvas can be moved as
> one picture)?
You've got exactly the right idea. Take a look at lib-tk/Canvas.py and
the Group class defined there. You can specify that canvas objects
belong to a group, and then treat the group as though it were a single
object for moving, etc.
Doug
More information about the Python-list
mailing list