473,421 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

QuickTimeTcl and Python/Tkinter crash

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
3 2307
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Eric Brunel | last post by:
Hi all, I was creating a Tkinter widget in the style of the reversed tabs below Excel worksheets and I stepped in a serious problem: the code I made makes python crash with a seg fault, bus...
11
by: Leo | last post by:
hi there for somebody who wants tostart small/medium GUI apps with python: what's the best toolkit: tkinter, wxPython or what? stability, ease of use and portability between mac and windows...
0
by: SteveFerrigno | last post by:
Ok, firstly I’m really sorry if this is in the wrong place :( but anyway. I have created a program which I want to convert into a .exe so I use PY2EXE but even if I have saved the python file I...
1
by: John Chambers | last post by:
Sp my latest adventure is attempting to use python's Tkinter module on a few machines. On my PB (OSX 10.3.9), I got the following confusing results: /Users/jc: python Python 2.3 (#1, Sep 13...
14
by: Hendrik van Rooyen | last post by:
Hi, I get the following: hvr@LINUXBOXMicrocorp:~/Controller/libpython display.py UpdateStringProc should not be invoked for type font Aborted and I am back at the bash prompt - this is...
1
by: ShambhuHubli | last post by:
Hi ! I am developing front end for some application using Python Tkinter. And I am new to this GUI development. In my application, I have to create buttons other than square or rectangle. I want...
2
by: ShambhuHubli | last post by:
Hi all ! I am developing GUI in Python Tkinter for one application. In this I have created one Text box. And I need to insert the text inside the text box directly in to some paticular line...
2
by: Russell Blau | last post by:
I have some Tkinter programs that I run on two different machines. On Machine W, which runs Python 2.5.1 on Windows XP, these programs run fine. On Machine H, which runs Python 2.5.1 on Windows...
1
by: alivip | last post by:
How to brows and select a directory of file by using python TKinter like brows to find attachment in email but I can select not only file but whole directory any help
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.