view gamelib/gui.py @ 49:373c57ab4140

Product -> Schematic.
author Jeremy Thurgood <firxen@gmail.com>
date Mon, 07 May 2012 21:24:23 +0200
parents d82d3e54a4ef
children 38f41d046c6f
line wrap: on
line source

from pygame import image

from gamelib import data
from gamelib.gui_base import Drawable, TextButton


class ImageDrawable(Drawable):

    def __init__(self, rect, image):
        super(ImageDrawable, self).__init__(rect)
        self.image = image

    def draw(self, surface):
        surface.blit(self.image, (self.rect[0], self.rect[1]))


class BigButton(TextButton):
    WIDTH = 128
    HEIGHT = 64
    BG_IMAGE_NORMAL = image.load(data.filepath('images/button_normal.png'))
    BG_IMAGE_DOWN = image.load(data.filepath('images/button_down.png'))

    def __init__(self, pos, text):
        rect1 = (0, 0, self.WIDTH, self.HEIGHT)
        n = ImageDrawable(rect1, self.BG_IMAGE_NORMAL)
        d = ImageDrawable(rect1, self.BG_IMAGE_DOWN)
        rect2 = (pos[0], pos[1], self.WIDTH, self.HEIGHT)
        super(BigButton, self).__init__(rect2, n, d, text)