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

Re: [pygame] raw_input() and pygame.event.get()



On Monday 11 December 2006 14:53, Mike Wyatt wrote:
> How can I prevent key presses performed during a call to raw_input()
> from being added to pygame's event queue?  I've tried calling
> pygame.event.clear() after the call to raw_input(), but KEYDOWN events
> are still processed by pygame.event.get() once the PyGame window gets
> focus back from the console window.  I've also tried calling
> set_blocking(KEYDOWN)/set_blocking(None) and
> set_blocking(KEYDOWN)/set_allowed(None), but that results in no events
> being processed by pygame.event.get()

May I ask why you're using raw_input *and* pygame's event queue?

Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> from pygame.locals import *
>>> screen = pygame.display.set_mode((200, 200))
>>> input = ''
>>> while 1:
...     event = pygame.event.poll()
...     if event.type == KEYDOWN:
...         if event.unicode == '\r': break
...         input += event.unicode
...
>>> print input
sdfdjhfd
>>>