Am trying to make a game using easygui but the only way to shut is to shut python down completely because the X button won't work. How do I get it to shut the game?
Asked
Active
Viewed 300 times
3 Answers
0
A method I like to use is this at the end of the script:
raw_input("Press enter to exit...")
When Python runs a program, it brings up the black Command Prompt and then runs the program. To exit the command prompt when the program is done is always done by pressing the ENTER key.
This will only work in the end of the code. It can also work in any part of the code where the game ends.

Rushy Panchal
- 16,979
- 16
- 61
- 94
0
I am not an expert in Python myself, but after your code is written...just use this:
import sys
sys.exit(0)
Besides, python has got a built-in exit command. Personally I only use exit to shut down python. have a read: http://docs.python.org/2/library/sys.html#sys.exit

Surya Teja Karra
- 541
- 1
- 6
- 19
0
Just try
print "Game Ended"
"""This area should be for what happens after game ends."""
It should close the easygui window when clicked, but keep the program running.
Hope this works!

Bob
- 1
- 1
- 3
-
When you click a button on the easygui window, it closes itand prints 'Game Ended' on the interactive shell. – Bob Feb 05 '13 at 21:43