Search code examples
pythontkintercmdvisible

Close cmd while Tk object remains


So I made a simple calculator in Python 3.7 and made a batch file to get it to run from the CMD. The thing is, after I run the batch file, I get a CMD window and then the Tk window, but the CMD window remains there and shuts my program down if I close it. Is there a way to hide the CMD window or just omit its apperance at all?

Here is how it looks, in case my description is bad:
Cmd window visible and active

The BATCH FILE reads:

Start "" "C:\Users\Username\AppData\Local\Programs\Python\Python37\draft.py"

Solution

  • You can use the pythonw executable, or rename your script to something.pyw.

    .pyw is a special extension for Python files on Windows which are associated with pythonw, the Python interpreter that does not pop up the console window at all.