By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

QuickTimeTcl and Python/Tkinter crash

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mickel Grönroos <mi****@csc.fi> wrote in message news:<ma*************************************@pyth on.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/tk...d-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.
Jul 18 '05 #2

P: n/a
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, 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


Jul 18 '05 #3

P: n/a
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.

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

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.