Check current tab

Is there a way to get a tabs label/text? or just tab index?

Right now i’m using the following to get tab index:

tabview = lv.tabview(lv.scr_act(), lv.DIR.TOP, 50)

tab1 = tabview.add_tab("Tab 1")
tab2 = tabview.add_tab("Tab 2")
tab3 = tabview.add_tab("Tab 3")

def _event_tab_changed(e):
    code = e.get_code()
    obj = e.get_target()
    print("tab: %s" % str(tabview.get_tab_act()))
tabview.add_event_cb(_event_tab_changed, lv.EVENT.VALUE_CHANGED, None)

According to the docs, get_tab_act is the way to query what tab index was selected.
You can use the index get_tab_act returns:

  • To get the tab object itself by calling tabview.get_content().get_child(i)
  • To get the tab text by calling tabview.get_tab_btns().get_btn_text(i)

Here is an online example that shows both the tab text and manipulating selected tabs.

Hi @amirgon,
Thank you very much for the quick reply. This is exactly what I was looking for!