[Tkinter-discuss] Proposal for thread-safe Tkinter

Guilherme Polo ggpolo at gmail.com
Fri Oct 24 21:45:39 CEST 2008


On Fri, Oct 24, 2008 at 5:31 PM, Allen Taylor
<Allen.Taylor at mdacorporation.com> wrote:
> Hi Guilherme,
> The versions of Python and Tk used are the default packages installed on
> Linux (Ubuntu 6.06 LTS). I don't know whether the default install is
> compiled with --enable-threads or not. So, mtTkinter seems to be handy if
> you want to use the default installed packages?
> Allen
>

To check for --enable-threads try this:

import Tkinter
Tkinter.Tk().getvar("tcl_platform(threaded)")

You will either get 1, or a TclError.

Also, I though you said latest tcl/tk versions but clearly tcl/tk
packages in Ubuntu 6.06 are not the latest.
But they also won't make a difference if you didn't recompile python
with these packages, I'm just telling this because right now Ubuntu
includes tcl/tk 8.5 but distributes python-tk compiled against tcl/tk
8.4.

Maybe you could include one example where this new module makes a
difference ? We could be talking about different things. For instance,
this:

import Tkinter

def test(text_widget):
    text_widget.config(text='abcdef')

def try_it(text_widget):
    threading.Thread(target=test, args=(text_widget, )).start()

lbl = Tkinter.Label()
lbl.pack()
lbl.after(10, lambda: try_it(lbl))

lbl.mainloop()

Would crash if tcl/tk were not compiled with --threads-enabled, but
then using your module it will run just fine.

-- 
-- Guilherme H. Polo Goncalves


More information about the Tkinter-discuss mailing list