how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter tkinter tkinter

how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter


Add some logging to the code to see which parts are executed when. Multithreaded code is always hard to debug (because things happen while the debugger waits for you). Logging will give you a report of what happened when and that will allow you to track down unexpected behavior.$

In this case, I see two problems:

except: continue

will silently ignore any problems in the frame capture loop. So if something goes wrong, no image will be pushed to the queue. But that should cause queue.get() to throw an Empty exception.

The second problem is that you install update_all() twice. So you will have one process/loop which adds one image per N milliseconds to the queue but two callbacks in the main event loop that try to get an image. That could cause Python to lock up.

Again, use logging to see when processes are started, when images are put into the queue and taken from it and how many callbacks are registered to process images in the queue.

[EDIT] If the original code works, then use a different approach:

Instead of installing a second callback with after() set a flag. When the flag is set, change the colorspace. Otherwise, leave it alone. When the button is clicked, toggle the flag.