コード例 #1
0
ファイル: num_pad.py プロジェクト: stopstopstop/emu
    def _generate_buttons(self):
        display.clear()  # we need to clear old buttons
        start = self.start + (ITEMS_PER_PAGE + 1) * self.page - self.page
        end = min(self.end, (ITEMS_PER_PAGE + 1) * (self.page + 1) - self.page)

        digits = list(range(start, end))
        self.buttons = [
            Button(digit_area(i), str(d)) for i, d in enumerate(digits)
        ]
        if len(digits) == ITEMS_PER_PAGE:
            more = Button(digit_area(PLUS_BUTTON_POSITION),
                          str(end) + "+",
                          style=ui.BTN_KEY_DARK)
            self.buttons.append(more)
            # move the tenth button to its proper place and make place for the back button
            self.buttons[BACK_BUTTON_POSITION].area = digit_area(
                BACK_BUTTON_POSITION + 1)

        back = Button(
            digit_area(BACK_BUTTON_POSITION),
            res.load(ui.ICON_BACK),
            style=ui.BTN_KEY_DARK,
        )
        if self.page == 0:
            back.disable()
        self.buttons.append(back)
コード例 #2
0
 def _generate_buttons(self):
     display.clear()  # we need to clear old buttons
     start = self.start + (ITEMS_PER_PAGE + 1) * self.page - self.page
     end = min(self.end, (ITEMS_PER_PAGE + 1) * (self.page + 1) - self.page)
     digits = list(range(start, end))
     if len(digits) == ITEMS_PER_PAGE:
         digits.append(str(end) + "+")
     self.buttons = [Button(digit_area(i), str(d)) for i, d in enumerate(digits)]
コード例 #3
0
 def test_clear(self):
     display.clear()