Re: Tkinter: how to refresh a canvas without duplicates?

F

Fredrik Lundh

Stewart said:
I've got a Tkinter app that draws three histograms. At this point I am
simulating real data by drawing rectangles whose size is defined by random
numbers; in the future there would be real data coming from a server.

I want to redraw the rectangles every time I press the Again button. This works
for me, but I get an extra set of rectangles each time I press the Again button.
How to get rid of this effect?

the create methods add new objects to the canvas. if you want
to replace them, you can either get rid of the old objects (using
delete(id) or even delete(ALL)) or you can modify the objects in
place (itemconfig, coords).

more info here:

http://www.pythonware.com/library/tkinter/introduction/canvas.htm

(see "item specifiers" under "concepts", and the "methods" section)

if you need to rapidly redraw things in a Tkinter widget, the WCK is
often a lot more efficient:

http://www.effbot.org/zone/wck.htm

</F>
 
S

stewart

Fredrik said:
the create methods add new objects to the canvas. if you want
to replace them, you can either get rid of the old objects (using
delete(id) or even delete(ALL)) or you can modify the objects in
place (itemconfig, coords).

thanks, that did the trick!
if you need to rapidly redraw things in a Tkinter widget, the WCK is
often a lot more efficient:

http://www.effbot.org/zone/wck.htm

I've tried to install this, but when I run 'python setup.py install', it
complains that it "cannot find /usr/lib/python/2.3/config/Makefile". Why
would this be?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top