[Tkinter-discuss] GUI response
klappnase at web.de
Thu Sep 1 12:12:22 CEST 2011
Thus spoketh Martin B <spooky.ln at tbs-software.com>
unto us on Thu, 1 Sep 2011 11:18:10 +0200:
> Hi all,
> I want to know is my solution is 'clean'.
> I need good gui response if cpu is very busy. in this example cpu is
> compute my photo images on to low res.
> in next step i need compute md5 sums for each image etc.
> Is it good solution write all gui class as Thread or better way is
> write only critical cpu code into thread like md5 checksums, resizing
> in this example i want use slider if cpu is computing, which is work.
> thanks for your comments.
One thing you should *never* do is to try to handle the gui from a child
thread. The Tk gui should always be run from the main program thread and
communication between the gui and child threads can be done through a
lock like a threading.RLock() or a threading.Condition() ; these allow
you to safely update some variables from within the child thread and then
query this variables' values from the gui thread (typically with an after
The odd thing about gui and threads is, that it might *seem* to work when
you touch your gui from the child thread, but weird, unreproducable
things may happen.
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
"We have the right to survive!"
"Not by killing others."
-- Deela and Kirk, "Wink of An Eye", stardate 5710.5
More information about the Tkinter-discuss