Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiprocessing to coordinate Tkinter with Pygame #2

Open
godisreal opened this issue Jun 5, 2020 · 0 comments
Open

Use multiprocessing to coordinate Tkinter with Pygame #2

godisreal opened this issue Jun 5, 2020 · 0 comments

Comments

@godisreal
Copy link
Owner

I am trying to use multiprocessing to coordinate Tkinter with Pygame. Here GUI is created by Tkinter as the father process. When users start the simulation, GUI creates a son process of pygame and GUI process is suspended. After pygame exits, GUI process is free to run again, and users can set up another simulation and then start another simulation run.

In other words, there is one token to coordinate two processes. When the son process of pygame is created, the token is automatically given to pygame. When pygame process is closed by users, the token is returned to father process of Tkinter.

One problem is that I found I do not have to use .join() in multiprocessing after the pygame process terminates. The whole program runs more smoothly if I do not use .join() in multiprocessing and I do not know why. I will keep exploring this topic.

    def startSim(self):
        self.currentSimu = simulation()
        self.currentSimu.select_file(self.fname_EVAC, self.fname_FDS, "non-gui")
        #self.textInformation.insert(END, "Start Simulation Now!")
        self.setStatusStr("Simulation starts!  GUI window is not effective when Pygame screen is displayed!")
        self.updateCtrlParam()
        self.currentSimu.preprocessGeom()
        self.currentSimu.preprocessAgent()
        sunpro1 = mp.Process(target=show_simu(self.currentSimu))  # Pygame starts here      
        sunpro1.start()
        #sunpro1.join()
        self.setStatusStr("Simulation not yet started!")
        self.currentSimu.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant