[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Widget set?



> I've been hacking a bit on a widget framework for a game (see
> rocket.sourceforge.net). This may be of interest to other people, but only
> if it is done right. Therefore, please share any suggestions you may have.

hi jacob.
at this point i'd say just make the GUI work for what you need it
to. (ie, don't be doing text widgets and whatnot if you don't need
them). i've written several simple widget sets in C and C++, so
here are a couple ideas.

keep in mind what type of game input your game uses. mouse?
keyboard? joystick? it sounds like you've already designed
in focus handling/passing, so it sounds like you are well
equipped to work with any of the three.

instead of having the widgets deal with pygame events directly,
have a translation layer that converts pygame events into more
direct GUI events. something like SPACE, ENTER, JOYSTICK1,
and LEFTMOUSEBUTTON all get translated into a PUSH event.
also something like TAB, JOYSTICKLEFT/RIGHT, gets translated
into a message to pass the focus, etc.

i wouldn't even bother with attach_event() style message
routing. it's just a messy leftover with C. especially if you
use the above message translations. instead of translating a
message into another message, you are really translating a 
message into a function name.

when you say there is a "loop" function to handle all the widgets,
does that mean it loops forever, or does it just handle a single
pass through the GUI logic code? instead of loop() you may want a
tick() or update() type function that is called from the game's
main loop. this will allow you to still keep the game running with
the GUI on top.

anyways, i gotta go now, but those are just some initial idea.
unfortunately i cannot recommend any other GUI's to use with pygame
right now. i have actually just got paragui tested with python and
windows (and it of course works with linux). while this GUI library
is certainly impressive, it may be a little overkill?

other than that there's nothing, so i'm guessing you'll need to
do a bit of wheel inventing. :[
anyways, keep it simple is my advice. only design what you need
and leave it at that. soemtimes the bigger your plans get for a
widget api, the harder it gets to do the simple stuff



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org