V8.3 How to hide lv_menu back button on subpages

Description

I’m trying to hide the back button when using the lv_menu on subpages.

What MCU/Processor/Board and compiler are you using?

LVGL Simulator with Linux and Micropython Online Simulator

What LVGL version are you using?

8.3

What do you want to achieve?

I want to achieve a menu that does not force subpages to use the current back button. Is this possible currently with the lv_menu widget and if not is there a better way to go about styling the back button for a subpage.

What have you tried so far?

I have tried using the root back button styling lv_menu_set_mode_root_back_btn(menu, LV_MENU_ROOT_BACK_BTN...) on subpages but it gives a runtime error because it isn’t the correct object type.

Code to reproduce

The following code runs in the online micropython simulator for convenience.

##### startup script #####

#!/opt/bin/lv_micropython -i

import lvgl as lv

import display_driver


##### main script #####

# Create a menu object
menu = lv.menu(lv.scr_act())
menu.set_mode_root_back_btn(lv.menu.ROOT_BACK_BTN.DISABLED)
menu.set_size(320, 240)
menu.center()

# Create a sub page
sub_page = lv.menu_page(menu, None)
cont = lv.menu_cont(sub_page)
label = lv.label(cont)
label.set_text("^ How do I get rid of this")

# Create a main page
main_page = lv.menu_page(menu, None)
cont = lv.menu_cont(main_page)
label = lv.label(cont)
label.set_text("Next (click me)")
menu.set_load_page_event(cont, sub_page)

menu.set_page(main_page)

Screenshot and/or video

Hi Jake,
you can set the size of the header to zero (height,width)
lv_obj_t *header = lv_menu_get_main_header(m_pMenu);
lv_obj_set_size(header, 0, 0);

The same should work with the back button,too…