pythontkinterpython-multiprocessingmultiprocessing-manager

Share tkinter window object between python processes


Following is the scenario I am dealing with :

There is main process which launches a worker Process using Multiprocessing.Process. The worker process creates tkinter window for rendering. In case I wish to terminate rendering, I simply do process.terminate(). Although this programatically works, I see some artifacts on screen because window destruction is not properly done. My plan is to share the tkinter object with main process, thereby giving it ability to withdraw then destroy window.

I tried, Multiprocessing.Queue , Multiprocessing.Manager but none works because of following error :

TypeError: can't pickle _tkinter.tkapp objects

I think my assumptions are wrong. What is the appropriate python programming technique to achieve this ?


Solution

  • You cannot share tkinter objects between processes. Tkinter widgets depend on an embedded tcl interpreter, and that embedded interpreter cannot be shared between threads or processes.