0

I have a python3 code below:

import multiprocessing as pr
from multiprocessing.managers import BaseManager
import tkinter as tk

def func(root):
    root.mainloop()

BaseManager.register('Tk', tk.Tk)
manager = BaseManager()
manager.start()
inst = manager.Tk()

# print('dd',inst)

process = pr.Process(target=func,args=[inst])
process.start()
process.join()

In the above code, I have created a shared Tk object and I invoked its mainloop method from another process. But it's not working.

It should create a window. What wrong is going on?

I need help !!!

Abdul_Kuddus
  • 23
  • 1
  • 7
  • https://stackoverflow.com/questions/63414254/tkinter-gui-i-o-threading-when-to-use-queues-when-events/63416839#63416839 – Thingamabobs Sep 06 '20 at 07:21

1 Answers1

2

You can't share tkinter objects between processes. Tkinter is a wrapper around an embedded tcl/tk interpreter, and that embedded tcl/tk interpreter cannot span more than one thread or process.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685