-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (35 loc) · 1.24 KB
/
main.py
File metadata and controls
41 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#########################################
# USE auto-py-to-exe TO CREATE .exe file
# https://pypi.org/project/auto-py-to-exe/
#########################################
"""
File: main.py
Project: Foundation-CompApps
Purpose: Run everything from this file, including the GUI and the physics engine.(python main.py)
"""
import multiprocessing as mp
from src import gui
from src import physics
from src import simulation
import time
if __name__ == "__main__":
mp.freeze_support()
settings_queue = mp.Queue() # pipe for tkinter → pygame (gravity, mass values)
# Create processes for GUI and physics engine, sharing the queue
gui_process = mp.Process(target=gui.run_gui, args=(settings_queue,))
simulation_process = mp.Process(target=simulation.run_simulation, args=(settings_queue,))
# Start the processes
gui_process.start()
simulation_process.start()
#close both apps simultaniously
while True:
if not gui_process.is_alive():
simulation_process.terminate()
break
elif not simulation_process.is_alive():
gui_process.terminate()
break
time.sleep(0.1)
# Wait for both processes to finish
gui_process.join()
simulation_process.join()