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

Re: [pygame] newbie: events and timing



Hi Christoph,

Why can't you do something like this:

buttons = []
button_times = []
while 1:
for event in get(BUTTONDOWN):
buttons.append( event.button )
button_times.append( time.time() )
lpt_value = get_lpt_value()
if lpt_value == triggered_lpt_value:
break

(Written in Pythonic pseudo code. -- I didn't bother to check the names of the functions, etc.)

On Wednesday, April 16, 2003, at 02:44 PM, Jan Ekholm wrote:

On Tue, 15 Apr 2003, Christoph Lehmann wrote:

Hi
I have some python code, where I wait in a loop for a trigger signal on
the lpt port.
during this waiting-loop: can I receive any mouse button events? are
they logged with some time-stamps, so that I can get, after I left my
waiting loop, the info, which mouse button has been pressed, and also at
what time.
Alternatively you can use a thread for the blocking wait and let the main
part of your application proceed as normal, at least chewing events. The
thread can post an USEREVENT to the event queue once it has done what it
was supposed to do.

Not everyone likes threads though, so if you receive any messages critical
to using threads you can safely ignore them as FUD. :)

--

He says gods like to see an atheist around. Gives them something to aim at.
-- Terry Pratchett, Small Gods