[Tkinter-discuss] TclStackFree error

Sharalyn C. Christensen sharalyn at jcmanagement.net
Wed Feb 9 17:31:38 CET 2011


The following simple program crashes after about 20 seconds or so with
the following error:
 
TclStackFree: incorrect FreePtr. Call out of sequence?
 
It behaves the same under Python 2.6 and Python 2.7 under Window XP
service pack 2.
I have a hunch it has to do with Tk/Tcl's multithreading model.  I could
use some help here.
I did discover that if one removes the scrollbar code, this program runs
forever with out a hitch.
 
CODE:
import threading, ttk, time
from Tkinter import *
EVENT = '<<EVENT>>'
class Monitor(threading.Thread):
    def run(self):
        while True:
            text.event_generate(EVENT)
            time.sleep(.5)
def on_event(*args):
    text.insert(END, time.ctime()+'\n')
    text.see(END)
root = Tk()
text = Text(root)
vbar = ttk.Scrollbar(root, orient=VERTICAL)
vbar['command'] = text.yview
text['yscrollcommand'] = vbar.set
text.grid(column=0, row=0, sticky=NSEW)
vbar.grid(column=1, row=0, sticky=NS)
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
text.bind(EVENT, on_event)
worker = Monitor()
worker.start()
root.mainloop()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110209/362275f2/attachment.html>


More information about the Tkinter-discuss mailing list