acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_textarea_2.py (1470B)

      1 def ta_event_cb(e):
      2     code = e.get_code()
      3     ta = e.get_target()
      4     if code == lv.EVENT.CLICKED or code == lv.EVENT.FOCUSED:
      5         # Focus on the clicked text area
      6         if kb != None:
      7             kb.set_textarea(ta)
      8 
      9     elif code == lv.EVENT.READY:
     10         print("Ready, current text: " + ta.get_text())
     11 
     12 
     13 # Create the password box
     14 LV_HOR_RES = lv.scr_act().get_disp().driver.hor_res
     15 LV_VER_RES = lv.scr_act().get_disp().driver.ver_res
     16 
     17 pwd_ta = lv.textarea(lv.scr_act())
     18 pwd_ta.set_text("")
     19 pwd_ta.set_password_mode(True)
     20 pwd_ta.set_one_line(True)
     21 pwd_ta.set_width(LV_HOR_RES // 2 - 20)
     22 pwd_ta.set_pos(5, 20)
     23 pwd_ta.add_event_cb(ta_event_cb, lv.EVENT.ALL, None)
     24 
     25 # Create a label and position it above the text box
     26 pwd_label = lv.label(lv.scr_act())
     27 pwd_label.set_text("Password:")
     28 pwd_label.align_to(pwd_ta, lv.ALIGN.OUT_TOP_LEFT, 0, 0)
     29 
     30 # Create the one-line mode text area
     31 text_ta = lv.textarea(lv.scr_act())
     32 text_ta.set_width(LV_HOR_RES // 2 - 20)
     33 text_ta.set_one_line(True)
     34 text_ta.add_event_cb(ta_event_cb, lv.EVENT.ALL, None)
     35 text_ta.set_password_mode(False)
     36 
     37 text_ta.align(lv.ALIGN.TOP_RIGHT, -5, 20)
     38 
     39 # Create a label and position it above the text box
     40 oneline_label = lv.label(lv.scr_act())
     41 oneline_label.set_text("Text:")
     42 oneline_label.align_to(text_ta, lv.ALIGN.OUT_TOP_LEFT, 0, 0)
     43 
     44 # Create a keyboard
     45 kb = lv.keyboard(lv.scr_act())
     46 kb.set_size(LV_HOR_RES, LV_VER_RES // 2)
     47 
     48 kb.set_textarea(pwd_ta)  # Focus it on one of the text areas to start
     49