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

Re: [pygame] Creating unique userevent ids?



Hi Rene,

You can find the rapidly changing current version of the code in CVS at http://uncpythontools.cvs.sourceforge.net/uncpythontools/CV/ under pygame_cam.py. You'll need CVtypes of course. It appears to work for me on Ubuntu, Windows, and Mac OS X.

I've just hacked together an object for the pgu gui kit. If that interests you I can create another project for it in CVS.

I'm working as hard as I can to get stuff ready for a trip to Asheville week after next so I don't have much time to discuss it now but I'd be very pleased to talk to anyone interested about how best to provide such capabilities to the pygame community.

gb

René Dudfield wrote:
hi,

that's probably a good idea :)

The upcomming SDL 1.3 has a new method for doing better user events...
until then, it's probably good to do something like Ian suggests -
except maybe start way higher.  Perhaps have some functions for
getting events?  That way your code would be more abstracted for
working with later changes.  eg.  FRAME_READY =
webcam.get_event("FRAME_READY") etc.


ps. do you have a url for your code repository?  I've also been
thinking about starting a webcam module probably based of VidCapture,
and opencv.  I think webcam support would be good for the next release
of pygame, that is version 1.9.  Same with wiimote support.

I think if we include new code with pygame that requires new events,
we would increment USEREVENT, and hopefully that won't break much user
code.

That could be another approach that you take, increment USEREVENT
yourself at init time, and require your init code before USEREVENT
usage.


On Tue, Feb 26, 2008 at 7:40 AM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
I really have no idea what I'm talking about.  :)
If I have separate modules that must use the same set of integers to do
something, (like my solution for wxPython menu bindings), I go like this:
module number + number
          1            +    1       = 11
          2            +    52     = 252
          1            +    31     = 131
...and so on.  This ensures that the bandwidth for each module remains
reserved.  All of the numbers beginning in 1 belong to module 1, like 11,
110, and 1100, all the ones to 2 begin with 2, like 21, 210, and 2100.  You
could add this value to pygame.USEREVENT for each submodule.

I've never used pygame.USEREVENT, so I have no idea what I'm talking about.
This might totally work, or be completely in the wrong direction.  I
apologise in the case of the latter. :)
HTH
Ian
--
There are 10 kinds of people;
those who understand binary and those who don't.
Without order nothing can exist - without chaos nothing can evolve.