I am writing a bootstrap program that runs several individual programs simultaneously. Thus, I require each sub-program to have its own terminal window, in a manner that gives me the ability to start/stop each sub-program individually within the bootstrap.
I was able to do this on Windows using Popen and CREATE_NEW_CONSOLE (each sub-program has it's own .py file), however I am having trouble achieving this with Linux. I am using a Raspberry Pi and Python 2.7.9.
I have tried:
Subprogram = Popen([executable, 'Foo.py'], shell=True)
However this does not seem to create a new window.. and
os.system("python ./Foo.py")
Does not seem to create a new window nor allow me to terminate the process.
Other research has thus far proved unfruitful..
How can I do this? Many thanks in advance.
-
You could always use screen to launch them all in the same terminal windowBasic– Basic2016年05月27日 22:54:32 +00:00Commented May 27, 2016 at 22:54
2 Answers 2
I finally figured it out, but wanted to post the solution so others can find it in the future.
Subprogram = Popen(['lxterminal', '-e', 'python ./Foo.py'], stdout=PIPE)
The lxterminal is the Raspberry Pi's terminal name, -e is required, python ./Foo.py launches the python file, and stdout=PIPE displays the output on the new terminal window.
Running the above launches Foo.py in a new terminal window, and allows the user to terminate the Foo.py process if desired.
Comments
How about this?
os.system("gnome-terminal --disable-factory")
It forces it to open a new process.