Pygame Window Closing Automatically

im doing this :
http://www.learningpython.com/2006/0...game-part-one/
and when closing the program the window stays up and doesnt respond. i
tried adding this:
http://www.pygame.org/wiki/FrequentlyAskedQuestions
bu it doesnt work, or maybe im doing it wrong.
heres the code without the added tutorial exit:
import os, sys
import pygame
from pygame.locals import *
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
class PyManMain:
''The Main PyMan Class - This class handles the main
initialization and creating of the Game.''
def __init__(self, width=640,height=480):
''Initialize''
''Initialize PyGame''
pygame.init()
''Set the window Size''
self.width = width
self.height = height
''Create the Screen''
self.screen = pygame.display.set_mode((self.width
, self.height))
def MainLoop(self):
''This is the Main Loop of the Game''
while 1:
for event in pygame.event.get():
if event.type pygame.QUIT:
sys.exit()
class Snake(pygame.sprite.Sprite):
''This is our snake that will move around the screen''
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = load_image('snake.png',-1)
self.pellets = 0
if __name__ '__main__':
MainWindow = PyManMain()
MainWindow.MainLoop()

Want to learn coding games? Here is PyGame Tutorial for Beginners to teach you about games development in an easy and straightforward way. Learn building games using PyGame. I always use file explorer (used to be windows explorer). Anyhow, after opening the file explorer, it closes by itself after 30 minutes or so. Any solution of disabling it? I have Windows 10 Pro. This page shows Python examples of pygame.display.

Pygame Window Closing Automatically
[PyGame] Problem importing pygame / installing pygame

Pygame Window Closing Automatically

[PyGame] Problem importing pygame / installing pygame
Dec-16-2017, 02:29 AM (This post was last modified: Dec-16-2017, 04:49 PM by metulburr.)
Uh? I'm using Windows Vista, Python 3.4.3 and PyGame 1.9.2 (i think designed for 3.2 but im not sure)
I installed it to the directory listed in the error. Should I move it somewhere else?
Dec-16-2017, 04:23 AM
What was your method of installation for pygame?
it might be a 32/64 bit issue. Whatever your python is, pygame must be also. However python doestn have to be whatever your OS is either.
You cna also or install pygame through
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Recommended Tutorials: BBcode, Forum Rules and Instructions, How to ask smart questions, the Basics, Classes, Python Gotchas
Dec-16-2017, 04:08 PM (This post was last modified: Dec-16-2017, 04:08 PM by Klar.)
I got it from PyGame's website, the installer is named pygame-1.9.2a0.win32-py3.2.msi. I installed it, again, in the directory seen in the error. Also, for your pip install method, where should I enter it?
For your second alternate, what is a .whl file? Where would I put it? What would I open it with?
I am also using the AMD-64 version of Python 3.4.
EDIT: Now that I look over it, I think it is a 64/32 clash. I'll get another install.
Dec-16-2017, 04:53 PM (This post was last modified: Dec-16-2017, 04:53 PM by metulburr.)
Sorry i was on a tablet before, and typing on a tablet sucks compared to keyboard.
Quote:pygame-1.9.2a0.win32-py3.2.msi
win32 means 32 bit, py3.2 means for python3.2 version.
Quote:I am also using the AMD-64 version of Python 3.4.

Your using 64 bit python3.4 but your installing a 32 bit pygame for python3.2
First of all uninstall that pygame as it is the wrong version and wrong bittype
secondly before doing wheels, you can simply try to type this in your OS command prompt exactly like...
and try that first as pip is suppose to install the proper version for you.
If that fails...
To install a wheel
Which is in the command prompt of your operating system. IF you install python correctly, it will know what pip is
from here
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
if you using
Quote:I am also using the AMD-64 version of Python 3.4.

then you need the one entitled
pygame‑1.9.3‑cp34‑cp34m‑win_amd64.whl
then do
of if its in your downloads
or whatever the proper path to downloads is in windows
or for path
Recommended Tutorials: BBcode, Forum Rules and Instructions, How to ask smart questions, the Basics, Classes, Python Gotchas
Dec-16-2017, 05:48 PM (This post was last modified: Dec-16-2017, 05:48 PM by Klar.)
It works now! Thanks!

Pygame Window Closing Automatically Change

Possibly Related Threads…
ThreadAuthorRepliesViewsLast Post
Pygame freezes after certain timeGJG2415May-06-2021, 10:52 AM
Last Post: GJG
[PyGame] drawing images onto pygame windowdjwilson04951787Feb-22-2021, 05:39 PM
Last Post: nilamo
[PyGame] Pygame attribute errordjwilson04953462Feb-18-2021, 03:34 PM
Last Post: michael1789
Drawn line shift when that surface is copied to another in pygameLeo_Red4643Feb-11-2021, 06:33 AM
Last Post: Leo_Red
(HELP GREATLY APPRECIATED) New user- Huge Pygame Installation Problem!Jbomb1461Jan-12-2021, 07:32 PM
Last Post: MK_CodingSpace
Distributing Python/Pygame code with CX_Freezejfng752563Jan-11-2021, 10:23 PM
Last Post: snippsat
Error installing Pygame-Zerodpa20071777Dec-26-2020, 03:50 PM
Last Post: MK_CodingSpace
Help with pygame tutorialdjwilson049510973Dec-21-2020, 11:28 AM
Last Post: djwilson0495
PyGamekat_gamer8890Dec-15-2020, 09:38 PM
Last Post: kat_gamer
cant make a door automatically close a few seconds after i open it in pygamecooImanreebro2518Dec-15-2020, 08:40 PM
Last Post: michael1789
Users browsing this thread: 1 Guest(s)

Pygame Window Closes Immediately

Pygame