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)
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)]
def test_clear(self): display.clear()