Trouble running script in spawed window #8979
-
Environment:
I have a import sys
from os import path
from pathlib import Path
from subprocess import call
from platform import system
from tkinter import messagebox
from app.l_app import App
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "--terminal":
meipass = Path(getattr(sys, "_MEIPASS")).resolve()
if not meipass:
messagebox.showwarning("Error", "_MEIPASS attribute is not set!")
sys.exit(1)
else:
script_path = path.join(meipass, "manager.py")
update_table_path(path.join(meipass, "tools", "table.json"))
# Use remaining args to pass to manager.py.
sys.argv = [script_path] + sys.argv[2:]
try:
call("clear" if system() == "Darwin" else "cls")
exec(open(script_path).read())
except FileNotFoundError:
messagebox.showwarning("Error", f"Script file '{script_path}' not found!")
sys.exit(1)
else:
App().run() This works fine on macOS (M2). A terminal is spawned and |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
That call("clear" if system() == "Darwin" else "cls") because
Using |
Beta Was this translation helpful? Give feedback.
-
Note that it's |
Beta Was this translation helpful? Give feedback.
That
FileNotFoundError
is probably raised bybecause
cls
is not a program on Windows, but a shell command: