micropython文本编辑器 界面
##### startup script #####
#!/opt/bin/lv_micropython -i
import lvgl as lv
import display_driver
##### main script #####
import fs_driver
fs_drv = lv.fs_drv_t()
fs_driver.fs_register(fs_drv, 'S')
font_simsun_st12 = lv.font_load("S:st12.font")
def event_handler(e):
code = e.get_code()
obj = e.get_target()
if code == lv.EVENT.CLICKED:
print("Button {:d} clicked".format(obj.get_child_id()))
win = lv.win(lv.scr_act(), 60)
win.add_title("A title")
btn1 = win.add_btn(lv.SYMBOL.FILE, 40)
btn1.add_event_cb(event_handler, lv.EVENT.ALL, None)
btn2=win.add_btn(lv.SYMBOL.SAVE, 40)
btn2.add_event_cb(event_handler, lv.EVENT.ALL, None)
btn3 = win.add_btn(lv.SYMBOL.CLOSE, 40)
btn3.add_event_cb(event_handler, lv.EVENT.ALL, None)
cont = win.get_content() # Content can be added here
cont.set_style_pad_all(lv.STATE.DEFAULT,0)
ta = lv.textarea(cont)
ta.set_width(cont.get_width())
ta.set_height(cont.get_height())
ta.set_style_text_font(font_simsun_st12, 0)
ta.set_text("""This is
a pretty
long text
to see how
the window
becomes
scrollable.
你好
We need
quite some text
and we will
even put
some more
text to be
sure it
overflows.
""")