-1

I'm looking for a way to launch a compiled processing sketch from a function in python. It would just be a button programed with pygame (having a UI is very important.

can you launch an external file from within python?

1
  • why not use subprocess.Popen ? Commented Nov 8, 2016 at 6:35

2 Answers 2

1

If you have your compiled jar you can use subprocess as show here:

import subprocess
subprocess.call(['java', '-jar', 'my-sketch.jar'])
Sign up to request clarification or add additional context in comments.

Comments

1

In order to launch an extern command using Python3 (or Python2), you can use one of those methods:

Example: i will call the bash function ls -l :

Method1:

>>> from subprocess import call
>>> call(["ls","-l"]

Method2:

>>> from os import system
>>> system("ls -l")

Bonus:

If you want to retrieve the output of the extern command you called, use this method:

Bonus method:

>>> output = subprocess.Popen("ls -l", shell = True, stdout=subprocess.PIPE)
>>> output

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.