Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QuickTimeTcl and Python/Tkinter crash

414 views
Skip to first unread message

Mickel Grönroos

unread,
Mar 29, 2004, 5:14:22 AM3/29/04
to pytho...@python.org
Hi everybody,

I'm using QuickTimeTcl (3.1) to be able to play movie files in my Tkinter
application (Python 2.3.2) on Windows 2000. I was planning to write a
simple wrapper class, QuickTimeMovie, that would wrap up the QuickTimeTcl
Tcl extension as a Python class. All seems to work pretty fine until the
Tkinter application is closed, when the Python interpreter crashes with an
error of the following kind:

The instruction at "0x6697c820" referenced memory at "0x01581f1c". The
memory could not be "written". Click on OK to terminate the program.

When running the "same" code in Tcl, I do not get this error.

I reckon the problem is that Python holds on to a reference to
something inside QuickTimeTcl after the QuickTimeTcl movie widget has been
destroyed.

My questions are then:

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?)

2. Am I totally off track, i.e. is there some logical explanation (and
straight-forward fix) to the error I am experiencing?

I wrote Mats Bengtsson (who maintains the QuickTimeTcl extension) about
this too, but I reckon the Python community might have a few tips and
tricks to share too.

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)

root = Tkinter.Tk()
m = Movie(root, file="toaster.mpeg")
m.pack()
root.mainloop()

---------------------------

Thanks in advance,

Mickel Grönroos

--
Mickel Grönroos, application specialist, linguistics, Research support, CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi

Myles

unread,
Mar 29, 2004, 8:53:58 PM3/29/04
to
Mickel Grönroos <mic...@csc.fi> wrote in message news:<mailman.42.10805552...@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.

Mickel Grönroos

unread,
Mar 30, 2004, 1:21:53 AM3/30/04
to Myles, pytho...@python.org
On Tue, 30 Mar 2004, Mickel Grönroos wrote:

> ("""The instruction at "0x6697c820" referenced memory at "0x01681f1c".


> The memory could not be "written". Click on OK to terminate the

> program""")

I might add that the error message that I get when Python crashes always
contains those same memory positions, i.e. it is allways an instruction at
"0x6697c820" that references memory at "0x01681f1c". This might not make a
difference though.

/Mickel G.

Mickel Grönroos

unread,
Mar 30, 2004, 1:12:47 AM3/30/04
to Myles, pytho...@python.org
On Tue, 29 Mar 2004, Myles wrote:

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

I'm afraid writing an explicit destroy method did not do the trick. I
still get the same error. ("""The instruction at "0x6697c820" referenced
memory at "0x01681f1c". The memory could not be "written". Click on OK to
terminate the program""")

Here is the latest code (that still causes the crash):

-------------------------------

import Tkinter

class Movie(Tkinter.Widget):
"""Wrapper class for QuickTimeTcl::movie."""


def __init__(self, parent, cnf={}, **kw):

"""Constructor. Parameters the same as here:
http://hem.fyristorg.com/matben/qt/htmldocs/movie.html"""


parent.tk.eval('package require -exact QuickTimeTcl 3.1')

Tkinter.Widget.__init__(self, parent, 'movie', cnf, kw)

def closing(m, r):
"""Test for destroying the movie and root window when clicking X."""
m.destroy()
m = None
r.destroy()

root = Tkinter.Tk()


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

root.protocol("WM_DELETE_WINDOW",
(lambda x=m, y=root: closing(x,y)))
root.mainloop()

## Tried the following too, but has not effect.
m = None
del m

----------------------------------

Any ideas what to try next!?

/Mickel G.

0 new messages