QuickTimeTcl and Python/Tkinter crash

Myles myles at geocities.com
Mon Mar 29 20:53:58 EST 2004


Mickel Grönroos <mickel at csc.fi> wrote in message news:<mailman.42.1080555269.20120.python-list at python.org>...

> All seems to work pretty fine until the
> Tkinter application is closed, when the Python interpreter crashes with an
> error of the following kind:
[...]
> I reckon the problem is that Python holds on to a reference to
> something inside QuickTimeTcl after the QuickTimeTcl movie widget has been
> destroyed.

Sounds possible. Tkinter does automatically maintain a widget tree, so
the Movie widget may not be getting destroyed properly.

> 1. Is there a way to force Python to get rid of references so the
> problem mentioned above could be avoided? (I.e. some sort of forced
> garbage collection?)

You might wish to try trapping the destroy event, and writing your own
exit routine that explicitly destroys the Movie object.

Reference: http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm
(towards the bottom, "Capturing destroy events")

Changes (not tried or tested) below:

> Here is the sample code I'm using. (To try it out, you need to download
> QuickTimeTcl and put it where Python can find it (e.g.
> "C:\\Python23\tcl").)
> 
> --------------------------
> 
> import Tkinter
> 
> class Movie(Tkinter.Widget):
>     def   init  (self, parent, cnf={}, **kw):
> 	parent.tk.eval('package require -exact QuickTimeTcl 3.1')
>         Tkinter.Widget.  init  (self, parent, 'movie', cnf, kw)


  def closing():
      m.destroy()  # will this work ? maybe "m = None" ?
      root.destroy()

> root = Tkinter.Tk()

  root.protocol("WM_DELETE_WINDOW", closing)

> m = Movie(root, file="toaster.mpeg")
> m.pack()
> root.mainloop()
> 
> ---------------------------

Regards, Myles.



More information about the Python-list mailing list