views:

33

answers:

2

Hello everyone,

I'm having trouble getting my custom events to fire. My regular events work fine, but I guess I'm doing something wrong. Here is the relevant code:

    evt = pygame.event.Event(gui.INFOEVENT, {'time':time,'freq':freq,'db':db})
    print "POSTING", evt
    pygame.event.post(evt)

   .... Later ....

    for event in pygame.event.get():
        print "GOT", event
        if event.type == pygame.QUIT:
            sys.exit()
        dispatcher.dispatch(event) 

gui.INFOEVENT = 101 by the way. The POSTING print statement fires, but the GOT one never shows my event.

Thanks!

A: 

It seems to work when I changed the code from:

INFOEVENT = 101

to:

INFOEVENT = pygame.USEREVENT+x

where x is some positive integer.

SapphireSun
A: 

From http://www.pygame.org/docs/ref/event.html

All events have a type identifier. This event type is in between the values of NOEVENT and NUMEVENTS. All user defined events can have the value of USEREVENT or higher. It is recommended make sure your event id's follow this system.

My thought is that your event ID is to high.

thebwt