Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start external program from Python script in the foreground?

Tags:

python

import os
os.system("notepad macros.txt")

or

from subprocess import Popen
Popen(["notepad", "macros.txt"])

both start notepad in the background. How to start it in the foreground?

like image 220
DSblizzard Avatar asked Nov 13 '22 17:11

DSblizzard


1 Answers

You can try to use the start command, maybe the /MAX option will force notepad to be in foreground, otherwise if you can wait untill notepad shutdown, use the /WAIT option/

Popen(["start", "/MAX", "notepad", "macros.txt"], shell=True)
like image 127
Cédric Julien Avatar answered Mar 30 '23 01:03

Cédric Julien