In a nutshell: I want to start a Python (GUI) app in a venv on windows by double-clicking on a start.cmd file. Everything now works, except: I can't get the CMD terminal window disconnected (running in a separate process) from the Python application.
i.e., the CMD window does everything as expected, but then doesn't close. When I close the CMD window manually, it kills the python app. I thought the command START /B ""
was supposed to be the same as app &
on linux/mac, but apparently not.
As a simplified example, create and save this simple hello_world.py to emulate:
from tkinter import *
root = Tk()
a = Label(root, text="Hello World")
a.pack()
root.mainloop()
Then copy the below into a Start.cmd file and double-click. With this simple setup, i get the behavior: CMD doesn't close, and if i manually terminate the python gui dies too (i.e., running as subprocess, not independent).
cd /D "%~dp0"
echo Setup Python Virtual Environment
echo (this might take a minute the first time)
python -m venv ./env
echo Start Application... success is being able to close CMD window, and have hello_world survive.
START /b "" .\env\Scripts\activate &&hello_world.py
I solved this on the Mac/linux versions in 3 seconds with one character: &
After several hours, Windows is just not working.
Appreciate any thought... thanks!