Esempio n. 1
0
 def add_entry(self, title="No title", action=None):
     b_sprite = Sprite(
                     self.w.textures["wall_stone"],
                     x=self.w.width / 2,
                     y=self.w.height / 2 - (32 * len(self.entries)),
                     batch=self.w.batches["mm_buttons"],
                     group=self.w.ui_group
                 )
     # b_sprite.width, b_sprite.height = 3, 1
     x, y = b_sprite.x, b_sprite.y
     b_sprite.rectangle = create_rectangle(x, y, 128, 32)
     b_sprite.action = action
     b_sprite.label = text.Label(
         title, font_name='Soft Elegance',
         font_size=14,
         x=x, y=y,
         anchor_x="center", anchor_y="center"
     )
     self.entries.append(b_sprite)
Esempio n. 2
0
    def addEntry(self, title="No title", action=None, top=False):
        h = self.but_h
        w = self.but_w
        x = self.w.width / 2
        y = (
            self.w.height / 2 - (h * len(self.entries)) +
            self.spacing
        )
        if title == "New Game":
            btn_texture = self.w.textures["button_green_jagged"]
        elif title == "Exit":
            btn_texture = self.w.textures["button_red"]
        else:
            btn_texture = self.w.textures["button_brown"]
        b_sprite = Sprite(
                        btn_texture,
                        x=x,
                        y=y,
                        batch=self.w.batches["mm_buttons"],
                        group=self.w.ui_group,
                    )
        b_sprite.opacity = 150
        # b_sprite.width, b_sprite.height = 3, 1
        b_sprite.rectangle = create_rectangle(x, y, w, h)
        b_sprite.action = action
        b_sprite.label = text.Label(
            title, font_name='Visitor TT1 BRK',
            font_size=self.font_size,
            color=self.font_clr,
            x=x, y=y,
            batch=self.w.batches["mm_labels"],
            anchor_x="center", anchor_y="center"
        )
        b_sprite.label.oldfontsize = b_sprite.label.font_size
        b_sprite.orig_size = self.but_w, self.but_h
        b_sprite.bw, b_sprite.bh = b_sprite.orig_size

        if top:
            self.entries.insert(0, b_sprite)
            self.updateOffset()
        else:
            self.entries.append(b_sprite)
            self.updateOffset()