I'm making a multiplayer game on Python3. In my main menu screen, when the player clicks play I want the maingame subroutine to run, but also a completely separate file (Server.py) to run in another window parallel to it. Right now I have to open Server.py separately and then the main game file, but I want to be able to open both from the main menu.
I've tried this:
import os
import subprocess
If user_selection == "start":
command="Server1.py"
os.system(command)
subprocess.Popen(command)
main_game()
The command, os and subprocess parts are supposed to run the server1.py file (which it does). But then it proceeds to run main_game() in the same window so it stops the server and runs the game instead. I've tried using the subprocess command twice (one for server.py and other for main_game.py) but it didn't work. Is there a way when the player clicks "run game" form the main menu screen, the server file executes in a second window and the first window goes from the main menu to the main_game subroutine?
note: both files are in the same directory.
Thanks :)