Jan-04-2021, 06:01 PM
(This post was last modified: Jan-04-2021, 07:15 PM by deanhystad.)
When you start a process the process loads the module (at least in Windows). This runs "window = Tk()" for each process. Protect the tkinter code behind the if __name__ == '__main__'. I think in Linux/Unix processes are spawned using "fork" and it inherits knowledge about the module instead of having to reload the code. I think you program would run differently under Linux or on a Mac. The code below should work everywhere.
from multiprocessing import Process from tkinter import * def f1(): print(1) def f2(): print(2) def main(): p1 = Process(target=f1) p1.start() p2 = Process(target=f2) p2.start() p1.join() p2.join() if __name__ == '__main__': window = Tk() main() window.mainloop()