示例#1
0
文件: button.py 项目: jtrain/supapowa
    def __init__(self, pos, containers, obj=None, 
                    padding=(10,10), num_pics=(1,1)):
        txt = None
        img = None
        if '.' in obj:
            img = obj
        else:
            txt = obj

        pygame.sprite.Sprite.__init__(self, containers)

        self.pos = pos
        self.containers = containers
        
        self.img_index = 0 #currently indexed image
        self.num_images = num_pics[0]*num_pics[1]

        if txt:
            self.text = small_font(txt, TEXT_COL)
        else:
            self.text = None

        if img:
            self.icons = load_img(img, num_pics)
        else:
            self.icons = None


        self.current_state = BUTTON_OFF
        self.colours = { BUTTON_OFF: BUTTON_INNER_BASE, \
                            BUTTON_ON: BUTTON_INNER_HOVER}
        self.shown = False
        self.pad = padding
        self.redraw()
        self.kill()
示例#2
0
文件: menu.py 项目: jtrain/supapowa
    def init(self, text, closename, **kws):
        # request some space from the parent.
        self.txt_surface = small_font(text or 'default', TEXT_COL,
                width=20)

        self.surface = self.parent.reserve(child=self,
                        topleft=(500, 100), size=self.txt_surface.get_size())

        self.controller.register(closename, self.on_close)