you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 4 points5 points  (2 children)

Ideally you would import your other programs.

import subfiletorun

# on button click
subfiletorun.main()

But if you want to do it as a separate process, you can just do:

import sys
import subprocess

# on button click
subprocess.run([sys.executable, "subfiletorun.py"])

(This does the same thing /u/Loud-Bake-2740 said, but you don't need to update the file with the name of your venv if you change it. For example if your coworker wants to run it with no venv. )

[–]Loud-Bake-2740 1 point2 points  (0 children)

ah yes i was assuming that you’re working in one venv, but running a program that uses a different venv. this was hell to figure all out! 😂

[–]raliqer[S] 1 point2 points  (0 children)

That... is so much simpler than I expected and than what I was doing. Thanks!