def create_density_controls(self, style): self.controls = lv.obj(self) self.controls.set_style(lv.style_transp_tight) self.controls.set_size(480, BTNSIZE) self.controls.set_y(740) plus = lv.btn(self.controls) lbl = lv.label(plus) lbl.set_text(lv.SYMBOL.PLUS) plus.set_size(BTNSIZE, BTNSIZE) plus.align(self.controls, lv.ALIGN.CENTER, 144, 0) plus.set_event_cb(self.on_plus) minus = lv.btn(self.controls) lbl = lv.label(minus) lbl.set_text(lv.SYMBOL.MINUS) minus.set_size(BTNSIZE, BTNSIZE) minus.align(self.controls, lv.ALIGN.CENTER, -144, 0) minus.set_event_cb(self.on_minus) lbl = lv.label(self.controls) lbl.set_text("QR code density") lbl.set_style(0, style) lbl.set_align(lv.label.ALIGN.CENTER) lbl.align(self.controls, lv.ALIGN.CENTER, 0, 0) self.controls.set_hidden(True)
def __init__(self, account, # account is the HDKey *args, # unknown args we will pass to the parent script_fn=script.p2wpkh, # how to calculate scriptpubkey network=NETWORKS["main"], # what network to use to get an address **kwargs # unknown kwargs we will pass to the parent ): super().__init__(*args, **kwargs) self.account = account self.script_fn = script_fn self.network = network self._index = 0 # create title self.title = lv.label(self) self.title.set_align(lv.label.ALIGN.CENTER) self.title.align(self, lv.ALIGN.IN_TOP_MID, 0, 50) # create qr code self.qr = QRCode(self) self.qr.set_size(400) self.qr.align(self.title,lv.ALIGN.OUT_BOTTOM_MID, 0, 20) self.lbl = lv.label(self) # create buttons self.next_btn = lv.btn(self) lbl = lv.label(self.next_btn) lbl.set_text("Next") self.next_btn.set_width(150) self.next_btn.set_event_cb(self.next_address) self.prev_btn = lv.btn(self) self.prev_btn.set_width(150) lbl = lv.label(self.prev_btn) lbl.set_text("Previous") self.prev_btn.set_event_cb(self.prev_address) # finally show first address self.show_address(self._index)
def __init__(self, account, *args, script_fn=script.p2wpkh, network=NETWORKS["main"], **kwargs): super().__init__(*args, **kwargs) self.account = account self.script_fn = script_fn self.network = network self._index = 0 # create title self.title = lv.label(self) self.title.set_align(lv.label.ALIGN.CENTER) self.title.align(self, lv.ALIGN.IN_TOP_MID, 0, 50) # create qr code self.qr = QRCode(self) self.qr.set_size(400) self.qr.align(self.title,lv.ALIGN.OUT_BOTTOM_MID, 0, 20) self.lbl = lv.label(self) # create buttons self.next_btn = lv.btn(self) lbl = lv.label(self.next_btn) lbl.set_text("Next") self.next_btn.set_width(150) self.next_btn.set_event_cb(self.next_address) self.prev_btn = lv.btn(self) self.prev_btn.set_width(150) lbl = lv.label(self.prev_btn) lbl.set_text("Previous") self.prev_btn.set_event_cb(self.prev_address) # finally show first address self.show_address(self._index)
def show_password_input(self): self.screen = lv.obj() self.wallet_paddword_screen_label = lv.label(self.screen) self.wallet_paddword_screen_label.set_text( " Enter your recovery\nphrase password (if any)") self.wallet_paddword_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -350) self.password_input = lv.ta(self.screen) self.password_input.set_one_line(True) self.password_input.set_text("") self.password_input.align(self.screen, lv.ALIGN.CENTER, 0, -275) self.password_back_button = lv.btn(self.screen) self.password_back_button.set_size(125, 60) self.password_back_button_label = lv.label(self.password_back_button) self.password_back_button_label.set_text("Back") self.password_back_button.align(self.screen, lv.ALIGN.CENTER, -100, -150) self.password_back_button.set_event_cb( self.handle_password_back_button) self.password_finish_button = lv.btn(self.screen) self.password_finish_button.set_size(150, 60) self.password_finish_button_label = lv.label( self.password_finish_button) self.password_finish_button_label.set_text("Finish") self.password_finish_button.align(self.screen, lv.ALIGN.CENTER, 100, -150) self.password_finish_button.set_event_cb( self.handle_password_finish_button) self.toggle_keyboard_button = lv.btn(self.screen) self.toggle_keyboard_button.set_size(230, 100) self.toggle_keyboard_button_label = lv.label( self.toggle_keyboard_button) self.toggle_keyboard_button_label.set_text( self.UPPER_CASE_KEYBOARD_SYMBOL) self.toggle_keyboard_button.align(self.screen, lv.ALIGN.CENTER, -118, 50) self.toggle_keyboard_button.set_event_cb( self.handle_toggle_password_keyboard_button) self.backspace_button = lv.btn(self.screen) self.backspace_button.set_size(230, 100) self.backspace_button_label = lv.label(self.backspace_button) self.backspace_button_label.set_text("Bksp") self.backspace_button.align(self.screen, lv.ALIGN.CENTER, 118, 50) self.backspace_button.set_event_cb( self.handle_password_backspace_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_height(300) self.keyboard.align(self.screen, lv.ALIGN.IN_BOTTOM_MID, 0, 0) self.keyboard.set_map(self.PASSWORD_KEYBOARD_MAP_LOWER_CASE) self.keyboard.set_ta(self.password_input) lv.scr_load(self.screen)
def show_set_password(self): self.screen = lv.obj() self.create_password_screen_label = lv.label(self.screen) self.create_password_screen_label.set_text("Set a password (optional)") self.create_password_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -360) self.password_input = lv.ta(self.screen) self.password_input.set_one_line(True) self.password_input.set_text("") self.password_input.align(self.screen, lv.ALIGN.CENTER, 0, -285) self.submit_password_button = lv.btn(self.screen) self.submit_password_button.set_size(125, 60) self.submit_password_button.align(self.screen, lv.ALIGN.CENTER, 0, -220) self.submit_password_button.set_event_cb( self.handle_submit_password_button) self.submit_password_button_label = lv.label( self.submit_password_button) self.submit_password_button_label.set_text("Set") self.password_tips_label = lv.label(self.screen) self.password_tips_label.set_text( "-Avoid common passwords\n" "-Use at least 11 characters\n" "-Use letters, numbers and\nspecial characters") self.password_tips_label.align(self.screen, lv.ALIGN.CENTER, 0, -90) self.toggle_keyboard_button = lv.btn(self.screen) self.toggle_keyboard_button.set_size(230, 100) self.toggle_keyboard_button_label = lv.label( self.toggle_keyboard_button) self.toggle_keyboard_button_label.set_text( self.UPPER_CASE_KEYBOARD_SYMBOL) self.toggle_keyboard_button.align(self.screen, lv.ALIGN.CENTER, -118, 50) self.toggle_keyboard_button.set_event_cb( self.handle_toggle_password_keyboard_button) self.backspace_button = lv.btn(self.screen) self.backspace_button.set_size(230, 100) self.backspace_button_label = lv.label(self.backspace_button) self.backspace_button_label.set_text("Bksp") self.backspace_button.align(self.screen, lv.ALIGN.CENTER, 118, 50) self.backspace_button.set_event_cb( self.handle_password_backspace_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_height(300) self.keyboard.align(self.screen, lv.ALIGN.IN_BOTTOM_MID, 0, 0) self.keyboard.set_map(self.PASSWORD_KEYBOARD_MAP_LOWER_CASE) self.keyboard.set_ta(self.password_input) lv.scr_load(self.screen)
def show_recovery_phrase(self): self.screen = lv.obj() self.recovery_phrase_header_label = lv.label(self.screen) recovery_phrase_word_index = self.recovery_phrase_page_number - 1 recovery_phrase_header_label_text = "Recovery phrase " \ "{page_number}/{total_pages}:".format( page_number=self.recovery_phrase_page_number, total_pages=len(self.recovery_phrase) ) self.recovery_phrase_header_label.set_text( recovery_phrase_header_label_text) self.recovery_phrase_header_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_word_label = lv.label(self.screen) self.recovery_phrase_word_label.set_text( self.recovery_phrase[recovery_phrase_word_index]) self.recovery_phrase_word_label.align(self.screen, lv.ALIGN.CENTER, 0, -150) if self.recovery_phrase_page_number != 1: self.prev_recovery_phrase_word_button = lv.btn(self.screen) self.prev_recovery_phrase_word_button.set_size(125, 60) self.prev_recovery_phrase_word_button_label = lv.label( self.prev_recovery_phrase_word_button) self.prev_recovery_phrase_word_button_label.set_text("Back") self.prev_recovery_phrase_word_button.align( self.screen, lv.ALIGN.CENTER, -100, 0) self.prev_recovery_phrase_word_button.set_event_cb( self.handle_previous_recovery_phrase_word_button) if self.recovery_phrase_page_number != len(self.recovery_phrase): self.next_recovery_phrase_word_button = lv.btn(self.screen) self.next_recovery_phrase_word_button.set_size(125, 60) self.next_recovery_phrase_word_button_label = lv.label( self.next_recovery_phrase_word_button) self.next_recovery_phrase_word_button_label.set_text("Next") self.next_recovery_phrase_word_button.align( self.screen, lv.ALIGN.CENTER, 100, 0) self.next_recovery_phrase_word_button.set_event_cb( self.handle_next_recovery_phrase_word_button) else: self.finish_recovery_phrase_button = lv.btn(self.screen) self.finish_recovery_phrase_button.set_size(150, 60) self.finish_recovery_phrase_button.align(self.screen, lv.ALIGN.CENTER, 100, 0) self.finish_recovery_phrase_button_label = lv.label( self.finish_recovery_phrase_button) self.finish_recovery_phrase_button_label.set_text("Finish") self.finish_recovery_phrase_button.set_event_cb( self.handle_finish_recovery_phrase_button) lv.scr_load(self.screen)
def show_phrase_input(self): self.phrase_input_length = 0 self.screen = lv.obj() self.recovery_phrase_length_screen_label = lv.label(self.screen) self.recovery_phrase_length_screen_label.set_text( "Recovery phrase word {page_number}/{recovery_phrase_target_length}" .format(page_number=len(self.recovery_phrase) + 1, recovery_phrase_target_length=self. recovery_phrase_target_length)) self.recovery_phrase_length_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -350) self.recovery_phrase_input = lv.ta(self.screen) self.recovery_phrase_input.set_one_line(True) self.recovery_phrase_input.set_text("") self.recovery_phrase_input.set_max_length(16) self.recovery_phrase_input.align(self.screen, lv.ALIGN.CENTER, 0, -275) self.recovery_phrase_input.set_event_cb( self.handle_recovery_phrase_input_change) # need to keep track of this for the autocomplete self.autocompleted = False self.phrase_input_length = 0 self.prev_recovery_phrase_word_button = lv.btn(self.screen) self.prev_recovery_phrase_word_button.set_size(125, 60) self.prev_recovery_phrase_word_button_label = lv.label( self.prev_recovery_phrase_word_button) self.prev_recovery_phrase_word_button_label.set_text("Back") self.prev_recovery_phrase_word_button.align(self.screen, lv.ALIGN.CENTER, -100, -150) self.prev_recovery_phrase_word_button.set_event_cb( self.handle_previous_recovery_phrase_word_button) self.next_recovery_phrase_word_button = lv.btn(self.screen) self.next_recovery_phrase_word_button.set_size(125, 60) self.next_recovery_phrase_word_button_label = lv.label( self.next_recovery_phrase_word_button) self.next_recovery_phrase_word_button_label.set_text("Next") self.next_recovery_phrase_word_button.align(self.screen, lv.ALIGN.CENTER, 100, -150) self.next_recovery_phrase_word_button.set_state(BUTTON_DISABLED_STATE) self.next_recovery_phrase_word_button.set_event_cb( self.handle_next_recovery_phrase_word_button) self.keyboard = lv.kb(self.screen) self.keyboard.set_map(self.RECOVERY_PHRASE_KEYBOARD_MAP) self.keyboard.set_ta(self.recovery_phrase_input) lv.scr_load(self.screen)
def __init__(self): self.obj_width = 120 self.obj_height = 150 # # Create an animation timeline # self.par = lv.scr_act() self.par.set_flex_flow(lv.FLEX_FLOW.ROW) self.par.set_flex_align(lv.FLEX_ALIGN.SPACE_AROUND, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER) self.btn_run = lv.btn(self.par) self.btn_run.add_event_cb(self.btn_run_event_handler, lv.EVENT.VALUE_CHANGED, None) self.btn_run.add_flag(lv.obj.FLAG.IGNORE_LAYOUT) self.btn_run.add_flag(lv.obj.FLAG.CHECKABLE) self.btn_run.align(lv.ALIGN.TOP_MID, -50, 20) self.label_run = lv.label(self.btn_run) self.label_run.set_text("Run") self.label_run.center() self.btn_del = lv.btn(self.par) self.btn_del.add_event_cb(self.btn_del_event_handler, lv.EVENT.CLICKED, None) self.btn_del.add_flag(lv.obj.FLAG.IGNORE_LAYOUT) self.btn_del.align(lv.ALIGN.TOP_MID, 50, 20) self.label_del = lv.label(self.btn_del) self.label_del.set_text("Stop") self.label_del.center() self.slider = lv.slider(self.par) self.slider.add_event_cb(self.slider_prg_event_handler, lv.EVENT.VALUE_CHANGED, None) self.slider.add_flag(lv.obj.FLAG.IGNORE_LAYOUT) self.slider.align(lv.ALIGN.BOTTOM_RIGHT, -20, -20) self.slider.set_range(0, 65535) self.obj1 = lv.obj(self.par) self.obj1.set_size(self.obj_width, self.obj_height) self.obj2 = lv.obj(self.par) self.obj2.set_size(self.obj_width, self.obj_height) self.obj3 = lv.obj(self.par) self.obj3.set_size(self.obj_width, self.obj_height) self.anim_timeline = None
def __init__(self): self.btn_cnt = 1 # # Create a list a with a floating button # list = lv.list(lv.scr_act()) list.set_size(280, 220) list.center() for btn_cnt in range(2): list.add_btn(lv.SYMBOL.AUDIO, "Track {:d}".format(btn_cnt)) float_btn = lv.btn(list) float_btn.set_size(50, 50) float_btn.add_flag(lv.obj.FLAG.FLOATING) float_btn.align(lv.ALIGN.BOTTOM_RIGHT, 0, -list.get_style_pad_right(lv.PART.MAIN)) float_btn.add_event_cb( lambda evt: self.float_btn_event_cb(evt, list), lv.EVENT.ALL, None) float_btn.set_style_radius(lv.RADIUS.CIRCLE, 0) float_btn.set_style_bg_img_src(lv.SYMBOL.PLUS, 0) float_btn.set_style_text_font(lv.theme_get_font_large(float_btn), 0)
def __init__(self, app, page): self.app = app self.page = page # slider self.slider = lv.slider(page) self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 20) self.slider_label = lv.label(page) self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0) self.slider.set_event_cb(self.on_slider_changed) self.on_slider_changed(None) # style selector self.styles = [ ("Plain", lv.style_plain), ("Plain color", lv.style_plain_color), ("Pretty", lv.style_pretty), ("Pretty color", lv.style_pretty_color), ] self.style_selector = lv.ddlist(page) self.style_selector.align(self.slider, lv.ALIGN.IN_BOTTOM_LEFT, 0, 40) self.style_selector.set_options("\n".join(x[0] for x in self.styles)) self.style_selector.set_event_cb(self.on_style_selector_changed) # counter button self.counter_btn = lv.btn(page) self.counter_btn.set_size(80, 80) self.counter_btn.align(self.style_selector, lv.ALIGN.OUT_RIGHT_TOP, 40, 0) self.counter_label = lv.label(self.counter_btn) self.counter_label.set_text("Count") self.counter_btn.set_event_cb(self.on_counter_btn) self.counter = 0
def __init__(self, page, screen): self.page = page self.screen = screen self.server = None self.wlan = network.WLAN(network.STA_IF) # use relative path on unix, absolute root else if hasattr(network, "UNIX"): self.config_file = "wifi.json" else: self.config_file = "/wifi.json" # read network config if possible self.config = self.read_wifi_config() # create dropdown, but disable it for now self.ssids = lv.dropdown(page) self.ssids.set_size(160, 32) self.ssids.align(page, lv.ALIGN.IN_TOP_MID, -20, 10) self.ssids.set_event_cb(self.on_ssid) # pre-populate list from stored wifi data if present if len(self.config["keys"]) > 0: ssids = list(self.config["keys"].keys()) self.networks = [{ "ssid": x, "open": not self.config["keys"][x] } for x in ssids] self.set_ssid_list(ssids) else: self.ssids.set_options("") self.ssids.set_text("No Networks") self.ssids.set_show_selected(False) self.ssids.set_click(False) # scan button self.scan_btn = lv.btn(page) self.scan_btn.set_size(32, 32) self.scan_btn.align(page, lv.ALIGN.IN_TOP_MID, 85, 10) self.scan_btn.set_event_cb(self.on_scan_btn) label = lv.label(self.scan_btn) label.set_text(lv.SYMBOL.REFRESH) # info/status label self.label = lv.label(page) self.label.set_long_mode(lv.label.LONG.BREAK) self.label.set_width(210) self.label.set_text("") self.label.set_align(lv.label.ALIGN.CENTER) self.label.align(page, lv.ALIGN.IN_TOP_MID, 0, 60) # enable wlan self.wlan.active(True) self.wlan.config(dhcp_hostname=self.config["name"]) # check if there is info about a last successfully # used network if "last" in self.config: print("Trying last network", self.config["last"], "...") self.connect(self.config["last"])
def __init__(self, parent, text=None, font_size=None, x=0, y=0, width=None, height=None, app=None, subject=None): self.lv_obj = lv.btn(parent) self.parent = parent self.x = x self.y = y self.width = width if width else parent.get_width() - 10 self.height = height if height else 25 self.lv_obj.set_size(self.width, self.height) self.lv_obj.set_pos(x, y) self.label = None if subject: self.subject = subject if text: self.set_text(text, font_size) if app: self.app_name = app
def show_recovery_phrase_warning(self): self.screen = lv.obj() self.recovery_phrase_header_label = lv.label(self.screen) self.recovery_phrase_header_label.set_text( "WRITE DOWN YOUR\nRECOVERY PHRASE!") self.recovery_phrase_header_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_instruction_label = lv.label(self.screen) self.recovery_phrase_instruction_label.set_text( "If you lose your wallet,\nyou can recover it on any\n computer " "ONLY with BOTH:\n\n1)Your recovery phrase\n2)Your password") self.recovery_phrase_instruction_label.align(self.screen, lv.ALIGN.CENTER, 0, -85) self.show_recovery_phrase_button = lv.btn(self.screen) self.show_recovery_phrase_button.set_size(400, 100) self.show_recovery_phrase_button.align(self.screen, lv.ALIGN.CENTER, 0, 150) self.show_recovery_phrase_button.set_event_cb( self.handle_show_recovery_phrase_button) self.show_recovery_phrase_button_label = lv.label( self.show_recovery_phrase_button) self.show_recovery_phrase_button_label.set_text("Show recovery phrase") lv.scr_load(self.screen)
def info_bottom_create(self, label_txt, btn_txt, btn_event_cb, delay): LV_DEMO_PRINTER_BTN_W = 200 LV_DEMO_PRINTER_BTN_H = 50 txt = lv.label(lv.scr_act(), None) txt.set_text(label_txt) self.theme.apply(txt, LV_DEMO_PRINTER_THEME_LABEL_WHITE) txt.align(None, lv.ALIGN.CENTER, 0, 100) btn = lv.btn(lv.scr_act(), None) self.theme.apply(btn, LV_DEMO_PRINTER_THEME_BTN_BORDER) btn.set_size(LV_DEMO_PRINTER_BTN_W, LV_DEMO_PRINTER_BTN_H) btn.align(txt, lv.ALIGN.OUT_BOTTOM_MID, 0, 60) btn.set_style_local_value_str(lv.btn.PART.MAIN, lv.STATE.DEFAULT, btn_txt) btn.set_style_local_value_font(lv.btn.PART.MAIN, lv.STATE.DEFAULT, self.theme.get_font_normal()) btn.set_event_cb(btn_event_cb) self.anim_in(txt, delay) delay += self.LV_DEMO_PRINTER_ANIM_DELAY self.anim_in(btn, delay) delay += self.LV_DEMO_PRINTER_ANIM_DELAY self.anim_in(btn, delay)
def add_back(self, event_cb): btn = lv.btn(lv.scr_act(), None) self.theme.apply(btn, LV_DEMO_PRINTER_THEME_BTN_BACK) btn.set_size(80, 80) btn.set_pos(30, 10) btn.set_event_cb(event_cb) return btn
def show_phrase_length_selection(self): self.screen = lv.obj() self.recovery_phrase_length_screen_label = lv.label(self.screen) self.recovery_phrase_length_screen_label.set_text( "How many words are in\n your recovery phrase?") self.recovery_phrase_length_screen_label.align(self.screen, lv.ALIGN.CENTER, 0, -300) self.recovery_phrase_length_roller = lv.roller(self.screen) recovery_phrase_length_options_str = "\n".join( str(phrase_length) for phrase_length in self.RECOVERY_PHRASE_LENGTHS) self.recovery_phrase_length_roller.set_options( recovery_phrase_length_options_str, 0) self.recovery_phrase_length_roller.set_fix_width(True) self.recovery_phrase_length_roller.set_selected(2, 0) self.recovery_phrase_length_roller.set_size(200, 200) self.recovery_phrase_length_roller.align(self.screen, lv.ALIGN.CENTER, 0, -75) self.recovery_phrase_length_roller.set_visible_row_count(5) self.confirm_phrase_length_button = lv.btn(self.screen) self.confirm_phrase_length_button.set_size(125, 60) self.confirm_phrase_length_button.align(self.screen, lv.ALIGN.CENTER, 0, 100) self.confirm_phrase_length_button.set_event_cb( self.handle_confirm_phrase_length_button) self.confirm_phrase_length_button_label = lv.label( self.confirm_phrase_length_button) self.confirm_phrase_length_button_label.set_text("Ok") lv.scr_load(self.screen)
def start_btn_init(self): """ Initialize the Start/Stop button on the screen """ this = self def start_btn_hander(obj, event): if event == lv.EVENT.CLICKED: if this.has_started: # Clicked to stop the process # popup to let user confirm the stop action this.popup_confirm_stop() else: # Clicked to start the process this.set_reflow_process_on(True) start_btn = lv.btn(self.main_scr) start_btn.set_size(140, 60) start_btn.set_event_cb(start_btn_hander) start_btn.align(self.timer_label, lv.ALIGN.IN_TOP_RIGHT, 190, 0) style_start = lv.style_t() lv.style_copy(style_start, lv.style_btn_rel) style_start.text.font = lv.font_roboto_28 start_label = lv.label(start_btn) start_label.set_text(lv.SYMBOL.PLAY + ' Start') start_label.set_style(lv.label.STYLE.MAIN, style_start) return start_btn, start_label
def __init__(self, page, screen): self.page = page self.screen = screen self.win = None # for fake run #self.fake_cmd = None #self.fake_task = lv.task_create(self.fake, 5000, lv.TASK_PRIO.MID, None); # create a task to check for commands from http_server self.http_task = lv.task_create(self.http_server_poll, 100, lv.TASK_PRIO.MID, None) # create a checkbox self.button = lv.checkbox(page) self.button.set_text("SD Card") self.button.align(page, lv.ALIGN.IN_TOP_LEFT, 16, 10) self.button.set_event_cb(self.event_handler) if not hasattr(machine, "SDCard"): self.button.set_disabled() # reload button self.reload_btn = lv.btn(page) self.reload_btn.set_size(32, 32) self.reload_btn.align(page, lv.ALIGN.IN_TOP_RIGHT, -12, 4) self.reload_btn.set_event_cb(self.on_reload_btn) lv.label(self.reload_btn).set_text(lv.SYMBOL.REFRESH) # List of Apps self.list = lv.list(page) self.list.set_size(216, 216) self.list.align(page, lv.ALIGN.IN_TOP_MID, 0, 38) self.reload()
def __init__(self, app, page): self.app = app self.page = page # slider self.slider = lv.slider(page) self.slider.set_width(160) self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 20) self.slider_label = lv.label(page) self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0) self.slider.set_event_cb(self.on_slider_changed) self.on_slider_changed(None) # style selector self.styles = [('Gray', ColorStyle(0xCCC)), ('Red', ColorStyle(0xF00)), ('Green', ColorStyle(0x0F0)), ('Blue', ColorStyle(0x00F))] self.style_selector = lv.dropdown(page) self.style_selector.add_style(self.style_selector.PART.MAIN, ShadowStyle()) self.style_selector.align(self.slider, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 40) self.style_selector.set_options('\n'.join(x[0] for x in self.styles)) self.style_selector.set_event_cb(self.on_style_selector_changed) # counter button self.counter_btn = lv.btn(page) self.counter_btn.set_size(80, 80) self.counter_btn.align(self.page, lv.ALIGN.IN_BOTTOM_MID, 0, -20) self.counter_label = lv.label(self.counter_btn) self.counter_label.set_text("Count") self.counter_btn.set_event_cb(self.on_counter_btn) self.counter = 0
def m2(): print("This is callback for M2") scr = lv.obj() lv.scr_load(scr) #make container con = lv.cont(scr) con.set_auto_realign(True) con.set_layout(lv.LAYOUT.CENTER) con.align(scr, lv.ALIGN.CENTER, 0, 0) con.set_fit(lv.FIT.TIGHT) #make label in container label = lv.label(con) label.set_text(""" This is the second screen""") ta = lv.textarea(con) kb = lv.keyboard(con) #kb.set_style_local_radius(0,0,0) kb.set_textarea(ta) btn = lv.btn(con) label = lv.label(btn) label.set_text("Skip la") btn.set_event_cb(lambda obj, event: m4() if event == lv.EVENT.CLICKED else None)
def __init__(self, app, page): self.app = app self.page = page # slider self.slider = lv.slider(page) self.slider.align(page, lv.ALIGN.IN_TOP_LEFT, 20, 20) self.slider_label = lv.label(page) self.slider_label.align(self.slider, lv.ALIGN.OUT_RIGHT_MID, 15, 0) self.slider.set_event_cb(self.on_slider_changed) self.on_slider_changed(None) # style selector self.styles = [('Plain', lv.style_plain), ('Plain color', lv.style_plain_color), ('Pretty', lv.style_pretty), ('Pretty color', lv.style_pretty_color)] self.style_selector = lv.ddlist(page) self.style_selector.align(self.slider, lv.ALIGN.IN_BOTTOM_LEFT, 0, 40) self.style_selector.set_options('\n'.join(x[0] for x in self.styles)) self.style_selector.set_event_cb(self.on_style_selector_changed) self.counter_btn = lv.btn(page) self.counter_btn.set_size(140, 100) self.counter_btn.align(self.page, lv.ALIGN.IN_TOP_RIGHT, -20, 20) self.counter_label = lv.label(self.counter_btn) self.counter_label.set_text('Count') self.counter_btn.set_event_cb(self.on_counter_btn) self.counter = 0
def create_scr1(self): scr1 = lv.obj() btn1 = lv.btn(scr1) btn1.align(scr1, lv.ALIGN.CENTER, 0, 0) label1 = lv.label(btn1) label1.set_text("Button 1") label1.set_size(20,20) return scr1
def __init__(self, address_function): super().__init__() self.address_function = address_function self._index = 0 # create buttons self.next_btn = lv.btn(self) lbl = lv.label(self.next_btn) lbl.set_text("Next") self.next_btn.set_width(150) self.next_btn.set_event_cb(on_release(self.next_address)) self.prev_btn = lv.btn(self) self.prev_btn.set_width(150) lbl = lv.label(self.prev_btn) lbl.set_text("Previous") self.prev_btn.set_event_cb(on_release(self.prev_address)) # finally show first address self.show_address(self._index)
def create_scr2(self): scr2 = lv.obj() btn2 = lv.btn(scr2) btn2.align(scr2, lv.ALIGN.CENTER, 0, 0) label2 = lv.label(btn2) label2.set_text("Button 2") label2.set_size(20,20) return scr2
def __init__(self): # # Extending the current theme # btn = lv.btn(lv.scr_act()) btn.align(lv.ALIGN.TOP_MID, 0, 20) label = lv.label(btn) label.set_text("Original theme") self.new_theme_init_and_set() btn = lv.btn(lv.scr_act()) btn.align(lv.ALIGN.BOTTOM_MID, 0, -20) label = lv.label(btn) label.set_text("New theme")
def create_playback_controls(self, style): self.playback = lv.obj(self) self.playback.set_style(lv.style_transp_tight) self.playback.set_size(480, BTNSIZE) self.playback.set_y(640) nextbtn = lv.btn(self.playback) lbl = lv.label(nextbtn) lbl.set_text(lv.SYMBOL.NEXT) nextbtn.set_size(BTNSIZE, BTNSIZE) nextbtn.align(self.playback, lv.ALIGN.CENTER, 144, 0) nextbtn.set_event_cb(self.on_next) prevbtn = lv.btn(self.playback) lbl = lv.label(prevbtn) lbl.set_text(lv.SYMBOL.PREV) prevbtn.set_size(BTNSIZE, BTNSIZE) prevbtn.align(self.playback, lv.ALIGN.CENTER, -144, 0) prevbtn.set_event_cb(self.on_prev) pausebtn = lv.btn(self.playback) self.pauselbl = lv.label(pausebtn) self.pauselbl.set_text(lv.SYMBOL.PAUSE) pausebtn.set_size(BTNSIZE, BTNSIZE) pausebtn.align(self.playback, lv.ALIGN.CENTER, 48, 0) pausebtn.set_event_cb(self.on_pause) stopbtn = lv.btn(self.playback) lbl = lv.label(stopbtn) lbl.set_text(lv.SYMBOL.STOP) stopbtn.set_size(BTNSIZE, BTNSIZE) stopbtn.align(self.playback, lv.ALIGN.CENTER, -48, 0) stopbtn.set_event_cb(self.on_stop) self.play = lv.btn(self) lbl = lv.label(self.play) lbl.set_text(lv.SYMBOL.PLAY) self.play.set_size(BTNSIZE, BTNSIZE) self.play.align(self, lv.ALIGN.IN_BOTTOM_MID, 0, -150) self.play.set_event_cb(self.on_play) self.play.set_hidden(False) self.playback.set_hidden(True)
def show_recovery_method_selection(self): self.screen = lv.obj() self.generate_new_wallet_button = lv.btn(self.screen) self.generate_new_wallet_button.set_size(350, 100) self.generate_new_wallet_button.align(lv.scr_act(), lv.ALIGN.CENTER, 0, -150) self.generate_new_wallet_label = lv.label( self.generate_new_wallet_button) self.generate_new_wallet_label.set_text("Generate New Wallet") self.generate_new_wallet_button.set_event_cb( self.handle_generate_new_wallet_button) self.recover_wallet_button = lv.btn(self.screen) self.recover_wallet_button.set_size(420, 100) self.recover_wallet_button.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 150) self.recover_wallet_label = lv.label(self.recover_wallet_button) self.recover_wallet_label.set_text("Recover Existing Wallet") self.recover_wallet_button.set_event_cb( self.handle_recover_wallet_button) lv.scr_load(self.screen)
def page_obj_init(self, par): self.anim_obj = lv.obj(par) self.anim_obj.set_size(30, 30) self.anim_obj.set_align(lv.ALIGN.TOP_LEFT) self.anim_obj.clear_flag(lv.obj.FLAG.SCROLLABLE) self.anim_obj.set_style_bg_color(lv.palette_main(lv.PALETTE.RED), lv.PART.MAIN) self.anim_obj.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, lv.GRID_ALIGN.START, 0, 1) self.p1_label = lv.label(par) self.p2_label = lv.label(par) self.p1_label.set_text("p1:0") self.p2_label.set_text("p2:0") self.p1_label.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, lv.GRID_ALIGN.START, 1, 1) self.p2_label.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, lv.GRID_ALIGN.START, 2, 1) self.p1_slider = lv.slider(par) self.p2_slider = lv.slider(par) self.p1_slider.set_range(0, 1024) self.p2_slider.set_range(0, 1024) self.p1_slider.set_style_pad_all(2, lv.PART.KNOB) self.p2_slider.set_style_pad_all(2, lv.PART.KNOB) self.p1_slider.add_event_cb(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None) self.p2_slider.add_event_cb(self.slider_event_cb, lv.EVENT.VALUE_CHANGED, None) self.p1_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1, lv.GRID_ALIGN.START, 1, 1) self.p2_slider.set_grid_cell(lv.GRID_ALIGN.STRETCH, 1, 1, lv.GRID_ALIGN.START, 2, 1) self.run_btn = lv.btn(par) self.run_btn.add_event_cb(self.run_btn_event_handler, lv.EVENT.CLICKED, None) btn_label = lv.label(self.run_btn) btn_label.set_text(lv.SYMBOL.PLAY) btn_label.center() self.run_btn.set_grid_cell(lv.GRID_ALIGN.STRETCH, 2, 1, lv.GRID_ALIGN.STRETCH, 1, 2) self.chart = lv.chart(par) self.chart.set_style_pad_all(0, lv.PART.MAIN) self.chart.set_style_size(0, lv.PART.INDICATOR) self.chart.set_type(lv.chart.TYPE.SCATTER) self.ser1 = self.chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y) self.chart.set_range(lv.chart.AXIS.PRIMARY_Y, 0, 1024) self.chart.set_range(lv.chart.AXIS.PRIMARY_X, 0, 1024) self.chart.set_point_count(CHART_POINTS_NUM) self.chart.set_grid_cell(lv.GRID_ALIGN.STRETCH, 0, 3, lv.GRID_ALIGN.STRETCH, 3, 1)
def __init__(self): scr = lv.obj() # Create style for the Arcs - Hour styleHour = lv.style_t() lv.style_copy(styleHour, lv.style_plain) styleHour.line.color = lv.color_make(119,158,203) # Arc color styleHour.line.width = 8 # Arc width # Create an Arc - Hour arcHour = lv.arc(scr) arcHour.set_style(lv.arc.STYLE.MAIN, styleHour) # Use the new style arcHour.set_angles(45, 0) arcHour.set_size(300, 300) arcHour.align(None, lv.ALIGN.CENTER, 0, 0) # Create style for the Arcs - Minute styleMin = lv.style_t() lv.style_copy(styleMin, lv.style_plain) styleMin.line.color = lv.color_make(124,252,0) # Arc color styleMin.line.width = 8 # Arc width # Create an Arc - Minute arcMin = lv.arc(scr) arcMin.set_style(lv.arc.STYLE.MAIN, styleMin) # Use the new style arcMin.set_angles(45, 0) arcMin.set_size(380, 380) arcMin.align(None, lv.ALIGN.CENTER, 0, 0) # Create style for the Arcs - Second styleSecond = lv.style_t() lv.style_copy(styleSecond, lv.style_plain) styleSecond.line.color = lv.color_make(250,128,114) # Arc color styleSecond.line.width = 8 # Arc width # Create an Arc - Minute arcSecond = lv.arc(scr) arcSecond.set_style(lv.arc.STYLE.MAIN, styleSecond) # Use the new style arcSecond.set_angles(45, 0) arcSecond.set_size(220, 220) arcSecond.align(None, lv.ALIGN.CENTER, 0, 0) def event_handler(obj, event): lv.obj_del(scr) from secondScreen import secondScreen btn1 = lv.btn(scr) btn1.set_event_cb(event_handler) btn1.align(None, lv.ALIGN.CENTER, 0, 0) label = lv.label(btn1) label.set_text("Button") lv.scr_load(scr)
def __init__(self, scr, *args, **kwargs): super().__init__(scr, *args, **kwargs) self.hint = lv.btn(scr) self.hint.set_size(50,60) self.hint_lbl = lv.label(self.hint) self.hint_lbl.set_text(" ") self.hint_lbl.set_style(0, styles["title"]) self.hint_lbl.set_size(50,60) self.hint.set_hidden(True) self.callback = None super().set_event_cb(self.cb)