[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] event.wait and userevents
hello,
i made a litte app with pygame. i had troubles with the event loop using
pygame.event.wait and userevents, triggered by
pygame.time.set_timer(pygame.USEREVENT, 1000)
the following code didn't work. it looks like during pygame.event.wait()
userevents aren't processed internally. as long as no other event got
triggered, the loop blocked.
...
for event in [ pygame.event.wait() ] + pygame.event.get( ):
# event handling code
wehn i replace it with
...
for event in get_events():
#event handling code
def get_events()
while True:
evs = pygame.event.get()
if len(evs) > 0:
return evs
pygame.time.wait(100)
pygame.event.pump()
it works as expected.
i'm a bit irritated by this behavior. i think pygame.event.wait should
either call pygame.event.pump periodically or the pygame.time.set_timer
should call pygame.event.pump after adding an event. if there are
reasons for this it would be nice if the documentation for
pygame.event.wait notes this behavior.
maybe i also got something completely wrong and my problem is somewhere
else, im new to python and pygame :-) in either case i'd be happy if
someone can give me a short feedback on this.
thanks
chrigi