0

I am working on a python editor/ide and I have been using os.startfile(file_path) to run the files but because this is like starting them using python.exe the console closes as soon as the file finishes running or it runs into an error.

I am looking for a method of running python files that has them behaving normally (like ran with idle/visual studio code), but the console output still being visible after it finishes running or crashes so I can see the error messages and the print() output.

This method can't hold up the python script that started it so that the tkinter interface I am using doesn't freeze.

2
  • if you want the console to keep open and tkinter not freeze, open the console in a separate thread than the one used by tkinter and put an input() at the end of the code executed by the console, so it doesn't automatically close when finished. Commented Feb 26, 2024 at 9:44
  • 2
    os.startfile() is absolutely inappropriate to run a Python file. It opens the file with the default application, which for security reasons should not be the Python interpreter directly. Check the subprocess module to run programms or make the code you are calling a function and run it in a thread. Commented Feb 26, 2024 at 9:52

0

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.