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

Re: [pygame] BUG : self-made pygame events don't work under Windows XP



Hi Gumm,

Thanks for your advices. For now I'm just using different UserEvents,
but I'll use your idea for new ones.

I've try to find why under Linux, event type higher than NUMEVENTS are
working, and not under windows, but I didn't manage to find why.

Anyway, thanks

Amarok

2010/1/26, B W <stabbingfinger@xxxxxxxxx>:
> Hi, Amaury.
>
> The docs recommend that event.type stay between NOEVENT and NUMEVENTS. So
> you are restricted to that range. Not sure if this is the cause of the
> inconsistencies you're seeing, but Pygame can be expected to work on any
> support platform if you follow the rules.
>
> Even though your choice of Event type is restricted, you can put virtually
> anything you want in your own events. This opens up a huge potential for
> customization.
>
> For example, you could use an attribute like "usertype" to store any number
> of user event  types. And you are not restricted in regards to its contents,
> or even a particular data type. And you can have any number of attributes.
>
> Here is one way to make your own event types.
>
> e = Event(USEREVENT, usertype='alist', userdata=[1,2,3,4])
> pygame.event.post(e)
> ...
> for e in pygame.event.get():
> if e.type == USEREVENT:
> if e.usertype == 'alist':
> print e.usertype, e.userdata
>
> Note tou probably do not want to use spaces in your dict keys, like you did
> in the example. If you do, you will need to use getattr() to access them.
>
> Hope this helps.
>
> Gumm
>
> On Mon, Jan 25, 2010 at 4:10 PM, Amaury Lepicard
> <amaury.lepicard@xxxxxxx>wrote:
>
>> program works well
>> qith the values 42 and 43. This may not be possible, isn't it?
>>
>