tkinter/tk memory questions

Chad Netzer cnetzer at mail.arc.nasa.gov
Tue Dec 3 22:12:39 EST 2002


On Tuesday 03 December 2002 18:07, Edward K. Ream wrote:

> On XP, expanding and contracting the outline causes memory allocated to my
> app (as reported by the XP task manager) to increase significantly, say 4
> meg per expansion.  Contraction might be expected to recycle bindings
> (bindings are allocated only for visible nodes) but does not.
[snip]

> # When creating bindings:
> self.canvas.tag_bind(id, "<1>", v.OnBoxClick)
> t.bind("<1>", v.OnHeadlineClick)

Aha! Here is the problem:  When you "bind" in Tkinter, python has to obtain 
an id from tcl (called a funcid), to use with unbind.  As a consequence (and 
assuming I'm not overstating things), bind ALWAYS returns an new id (from 
tcl), and it is THAT id that you have to save and use with unbind.

For an example (not with the canvas, but with bindings in general), look at 
the Pmw source, in PmwBalloon.py, and see how they implement 
binding/unbinding, etc.

-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
cnetzer at mail.arc.nasa.gov




More information about the Python-list mailing list