Welcome to the help page of mtTkinter! mtTkinter is a thread-safe wrapper
around Tkinter
in Python. This module is only useful for
Python 2.x installations, as in Python 3 Tkinter is compiled with a flag
that ensures thread-safety. This module was written by Allen B. Taylor,
and is only redistributed by me for anyone who finds it useful.
You can install mtTkinter in two ways. If you are on Python 2.7, you can
install the PyPI-package by executing pip install mttkinter
,
this is the preferred method. This will automatically download and install
mtTkinter, and you can then import the module as follows:
from mttkinter import mtTkinter as tk
If you are using the legacy Python 2.6 or an even older version, you can
copy the mtTkinter.py
directly into %PYTHON%/Libs/lib-tk
in order to import it as follows:
import mtTkinter as tk
Support for Python 2.6 or lower is not tested and is not guaranteed.
Because mtTkinter.py
contains the following import from
Tkinter import *
, you can use every Tkinter widget and variable
just as you normally would. Only changing the import to mtTkinter is
enough to make your application work with a thread-safe UI. The mtTkinter
Tk
-class, which is really the only modified class in the
whole module, uses a Queue.Queue
object to take event calls.
The modified Tk
-class has two additional keyword arguments:
mtDebug
, specifies the amount of debug output you want
to see on stdout
. It defaults to 0
, which
disables the debug printing, but you can set it up to 9
,
with each level in between increasing the amount of debug messages.mtCheckPeriod
, the amount of milliseconds between
checks for out-of-thread events waiting in the Queue
.
Decreasing will improve GUI responsiveness, but will also consume more
CPU-power. This value defaults to 10
.Currently, this module is not under active development. You can fork the
repository if you want, under the LGPL License and either redistribute it
yourself or, if you want your additions to be added to the PyPI package mttkinter
,
you can create a Pull Request to get your changes into the master branch
of this repository.