view mamba/widgets/base.py @ 38:047273a63054

Main menu says hello
author Stefano Rivera <stefano@rivera.za.net>
date Sun, 11 Sep 2011 14:57:11 +0200
parents 30d4f3e62bcf
children 3f44c30a1c39
line wrap: on
line source

import pygame


class Widget(object):

    def __init__(self, rect):
        if not isinstance(rect, pygame.Rect):
            rect = pygame.Rect(rect[0], rect[1], 0, 0)

    def event(self, event):
        "Override me"
        pass

    def draw(self, surface):
        "Override me"
        pass


class Container(object):

    def __init__(self):
        self.children = []

    def event(self, event):
        for child in self.children:
            # TODO mouse events
            child.event(event)

    def add(self, widget):
        self.children.append(widget)

    def draw(self, surface):
        for child in self.children:
            child.draw(surface)