Schütze
Schütze

Reputation: 1084

Subprocess.check_call() does not open a window

I have a piece of code which uses subprocess.check_call() to call a Python script. It runs all good, however, it does not show the GUI window that the script shows when it runs standalone. Somehow subprocess.check_call() does not respect any GUI threads I guess.

Here are the two lines that are relevant:

command = [self.python3, self.execution_dir + '/' + "script.py", "-i" + self.received_img_path]
subprocess.check_call(command, env={'PYTHONPATH': local_pythonpath })

Is there a way to make the function also open the GUI windows? Or is there another function for that in Python?

Upvotes: 0

Views: 231

Answers (1)

Frank Podborski
Frank Podborski

Reputation: 116

subprocess.check_call() is not supposed to spawn a separate GUI window (see the docs). To spawn a GUI window you need to explicitly run a program with a GUI like gnome-terminal and use its arguments to control the program. So e.g.

import subprocess
command = [self.python3, self.execution_dir + '/' + "script.py", "-i" + self.received_img_path]
subprocess.check_call(['gnome-terminal', '-e', ' '.join(command)],
                      env={'PYTHONPATH': local_pythonpath })

will spawn a GUI terminal and run your command.

Upvotes: 2

Related Questions