M5TabView
M5TabView is a widget that can be used to create tabbed views in the user interface.
UiFlow2 Example
tabview basic
Open the tabview_cores3_example.m5f2 project in UiFlow2.
This example creates a tabview.
UiFlow2 Code Block:
Example output:
None
MicroPython Example
tabview basic
This example creates a tabview.
MicroPython Code Block:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8import m5ui 9import lvgl as lv 10 11 12page0 = None 13tabview0 = None 14Tab1 = None 15Tab2 = None 16label1 = None 17label2 = None 18label3 = None 19 20 21def setup(): 22 global page0, tabview0, Tab1, Tab2, label1, label2, label3 23 24 M5.begin() 25 Widgets.setRotation(1) 26 m5ui.init() 27 page0 = m5ui.M5Page(bg_c=0xFFFFFF) 28 tabview0 = m5ui.M5TabView( 29 x=0, y=-2, w=320, h=240, bar_size=60, bar_pos=lv.DIR.TOP, parent=page0 30 ) 31 Tab1 = tabview0.add_tab("Tab1") 32 Tab2 = tabview0.add_tab("Tab2") 33 label1 = m5ui.M5Label("This is label1", x=0, y=0, parent=Tab1) 34 35 page0.screen_load() 36 label2 = m5ui.M5Label( 37 "Hello World", 38 x=0, 39 y=0, 40 text_c=0xFFCC00, 41 bg_c=0x99FF99, 42 bg_opa=255, 43 font=lv.font_montserrat_24, 44 parent=Tab1, 45 ) 46 label3 = m5ui.M5Label("hello M5", x=0, y=0, parent=Tab2) 47 label3.set_style_text_font(lv.font_montserrat_24, lv.PART.MAIN | lv.STATE.DEFAULT) 48 label3.set_text_color(0x6600CC, 255, 0) 49 label3.set_bg_color(0x33FF33, 255, 0) 50 51 52def loop(): 53 global page0, tabview0, Tab1, Tab2, label1, label2, label3 54 M5.update() 55 56 57if __name__ == "__main__": 58 try: 59 setup() 60 while True: 61 loop() 62 except (Exception, KeyboardInterrupt) as e: 63 try: 64 m5ui.deinit() 65 from utility import print_error_msg 66 67 print_error_msg(e) 68 except ImportError: 69 print("please update to latest firmware")
Example output:
None
API
M5TabView
- class m5ui.tabview.M5TabView(*args, **kwargs)
Bases:
tabviewCreate a TabView object.
- Parameters:
x (int) – The x position of the tab view.
y (int) – The y position of the tab view.
w (int) – The width of the tab view.
h (int) – The height of the tab view.
bar_size (int) – The size of the tab bar.
bar_pos (int) – The position of the tab bar.
parent (lv.obj) – The parent object to attach the tab view to. If not specified, the tab view will be attached to the default screen.
UiFlow2 Code Block:
None
MicroPython Code Block:
from m5ui import M5Label import lvgl as lv m5ui.init() tabview0 = m5ui.M5TabView(x=0, y=-2, w=320, h=240, bar_size=60, bar_pos=lv.DIR.TOP, parent=page0)
M5Label can be used in TabView. For specific usage, please refer to m5ui.M5Label Documentation.


