[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Why does pygame get so high CPU usage?



Psymaster wrote:
while 1:
    for event in pygame.event.get(QUIT):
        sys.exit()
    pygame.event.pump()
what about:

while 1:
    if pygame.event.wait().type == QUIT:
        sys.exit()


wait() is definitely the way to go. You may want to disable all the
event types that you are not interested in also:

##
import pygame
from pygame.locals import QUIT

pygame.display.set_mode((300, 200))

pygame.event.set_allowed(None)
pygame.event.set_allowed(QUIT)

while 1:
x = pygame.event.wait()
print x
if x.type == QUIT:
break
##

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail