The stange behaviour of Tkinter.Canvas

John McMonagle jmcmonagle at velseis.com.au
Tue Mar 11 19:33:22 EDT 2008


James Yu wrote:
> I tried to update the rectangle on a canvas to get the visual effect of
> progressbar.
> It works all right if I delete the existing objects (rectangle and text)
> and create a new one.
> However, if I invoke canvas.itemconfig() to update the existing objects'
> options, gui just went nuts.
> I am more than happy to receive any help and advise.
>  

Snipped code

>         canv.itemconfig(rect, width=width*progress/100)              ##

The width option of a rectangle item does not change the rectangles
width, but changes the width of the rectangle perimiter line.

You need to modify the coordinates of the rectangle item:

canv.coords(rect, 0, 0, width*progress/100, height)

Regards,

John





More information about the Python-list mailing list