Tkinter - One Canvas to Rule Them All?
Dave Harris
dpharris76 at msn.com
Tue May 25 08:42:26 EDT 2004
Fredrik Lundh wrote:
>
>>Dave Harris wrote:
>>
>>I derived two Frame classes and created a Canvas in each. I was extremely
>>surprised when frame1.canvas.delete('all') erased the image in
>>frame2.canvas!
>>
>>I deduce from this behavior that there is a single database behind the
>>scenes for the Canvas implementation.
>nope. that's not how the canvas work, in any Tkinter version I've ever
>used.
<snip>
>reminds me a little of all those "here's something I don't understand, so
>it has
>to be a bug in Python" posts we're seeing these days...
Thanks for the gentle reminder. And thanks to Peter Otten for requesting an
example.
When I culled the code down to a one page example, the behavior described
above did not occur. Then I went back to my code, restored the
delete('all'), and the behavior did not occur. Hmm.
Working back through my changes I found that I had cloned the two Frame
classes, including a clearAll() function, that contained (you're way ahead
of me, I know), delete('all'). Where I got mystified is that at some point
in time, I removed the clearAll() from one class because I wanted the
graphic elements in that canvas to be preserved. The fact that deletion by
tag seemed to work was that the change was made at the same time clearAll()
disappeared.
So, a retraction...Tkinter.Canvas works as advertised, and only a fool makes
a deduction on a single incident.
Foolishly,
Dave Harris
More information about the Python-list
mailing list