Scrollable Tkinter widget not threadsafe?
Peter Abel
p-abel at t-online.de
Sat Jun 21 15:00:25 EDT 2003
abli <abli at freemail.hu> wrote in message news:<3ef0af9e at andromeda.datanet.hu>...
> The exception you get is
>
> RuntimeError: Calling Tcl from different appartment
>
> You have to do all calls to tkinter from one thread.
> In the example you give, you create the widget, then start a new thread
> which enters mainloop. This means that you try to use two threads to
> communicate with Tkinter, which causes the exception.
> By moving all tkinter calls, i.e. the lines
> root=Tkinter.Tk()
> FrameScollTest (root).pack(fill='both',expand=True)
> into show_widget(), it runs fine.
>
> Of course, this has nothing to do with the type of widget you want to use,
> a Tkinter.Label behaves the same way.
>
> Abel Daniel
Thanks very much Daniel,
it works as you described.
I had no RuntimeError, only a TK-Window with nothing that
didn't respond. But I think this behavior depends of the
platform, os-version etc.
What remains unclear for me is that I should start a thread
already with the line:
root=Tkinter.Tk()
Until now I believed entering threading with
root.mainloop()
because this worked this way, but only without Scrollbars.
Regards
Peter
More information about the Python-list
mailing list