cdw100100
cdw100100

Reputation: 322

How to hide a python Command Prompt window

I am working on a program where the user types how old they are. Which is a raw_input string. Once they hit the enter button. So after the user gives me their input. I want the program to go away and run in the background. And if possible I would like to know how to do this in Windows & Linux systems.

hi = raw_input("How old are you? ")

Upvotes: 2

Views: 2336

Answers (1)

tmr232
tmr232

Reputation: 1201

On Windows, you can use:

import ctypes
ctypes.windll.kernel32.FreeConsole()

Given that you started it by a double-click and not from the console.

For a better solution, I would suggest running the script using pythonw.exe and using a GUI library (tkinter or something fancier) to display a dialog box instead.

Upvotes: 3

Related Questions