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

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to