Hi all,
I’m struggling with the Textarea widget implemented into the Tabview widget.
The Textarea get displayed well inside the Tabview, but if i press any input, the screen freezes and REPL outputs:
File “lv_utils.py”, line 108, in task_handler
TypeError: function takes 1 positional arguments but 2 were given
I know that the class handover automatically “self” as argument which does indeed has now two arguments. - it’s just that the first one is implicit, from the point of view of the caller.
Is there any possible workaround known to get this working??
Here is the code snippet:
class Screen_Main(lv.obj):
def init(self, app, *args, **kwds):
self.app = app
super().init(*args, **kwds)
self.theme = AdvancedDemoTheme()
self.tabview = lv.tabview(self, lv.DIR.BOTTOM, 30)
self.screen_uebersicht = screen_uebersicht(self.app, self.tabview.add_tab(“Viev”))
self.screen_klima = screen_klima(self.app, self.tabview.add_tab(“Clima”))
self.screen_licht = screen_licht(self.app, self.tabview.add_tab(“Light”))
self.screen_settings = screen_settings(self.app, self.tabview.add_tab(“Settings”))
class screen_uebersicht:
def init(self, app, page):
self.app = app
self.page = page
self.test_events = []
self.page.set_flex_flow(lv.FLEX_FLOW.COLUMN)
self.page.set_flex_align(lv.FLEX_ALIGN.SPACE_EVENLY, lv.FLEX_ALIGN.CENTER, lv.FLEX_ALIGN.CENTER)
#Uhrzeit Licht 1
#
# Automatically format text like a clock. E.g. "12:34"
# Add the ':' automatically
#
# Create the text area
LV_HOR_RES = page.get_disp().driver.hor_res
LV_VER_RES = page.get_disp().driver.ver_res
self.ta = lv.textarea(page)
self.ta.add_event_cb(self.ta_event_cb, lv.EVENT.VALUE_CHANGED, None)
self.ta.set_accepted_chars("0123456789:")
self.ta.set_max_length(5)
self.ta.set_one_line(True)
self.ta.add_state(lv.STATE.FOCUSED)
# Create a keyboard
self.kb = lv.keyboard(page)
self.kb.set_size(LV_HOR_RES, LV_VER_RES // 2)
self.kb.set_mode(lv.keyboard.MODE.NUMBER)
self.kb.set_textarea(self.ta)
def ta_event_cb(e):
ta = e.get_target()
txt = ta.get_text()
# print(txt)
pos = ta.get_cursor_pos()
# print("cursor pos: ",pos)
# find position of ":" in text
colon_pos = txt.find(":")
# if there are more than 2 digits before the colon, remove the last one entered
if colon_pos == 3:
ta.del_char()
if colon_pos != -1:
# if there are more than 3 digits after the ":" remove the last one entered
rest = txt[colon_pos:]
if len(rest) > 3:
ta.del_char()
if len(txt) < 2:
return
if ":" in txt:
return
if txt[0] >= '0' and txt[0] <= '9' and \
txt[1] >= '0' and txt[1] <= '9':
if len(txt) == 2 or txt[2] != ':':
ta.set_cursor_pos(2)
ta.add_char(ord(':'))