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

[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.

Here's the hierarchy:

Widget
-->WidgetRect
---->ImageButton
---->TextButton
---->Container (also inherits UserDict for list of widgets)
loop()  (Handle events for widgets)
active_widget (container) (Find the widget that has focus inside a
container)
show_rect(surface, rect) (Draw a border around a rectangle, for debugging)

Widget contains the virtual functions draw() and redraw() to reload the
image, and the function attach_event() to allow a widget to see a
particular event when it has focus. WidgetRect contains the surface and
rectangle handling functionality. Container contains functionality to pass
the focus to the correct widget.

Is anyone else working on a similar project? Duplication of effort would be
wasteful. Also, should I post the code to the mailing list? It's only 5k.
And lastly, am I doing anything completely wrong here? Suggestions from
those that have more experience with pygame would be appreciated.
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org