Added a small check for empty menu item lists (which make no sense)
This commit is contained in:
parent
10562d6410
commit
974229f4b2
@ -51,10 +51,14 @@ class lcdMenu:
|
||||
|
||||
|
||||
def show_selection(self):
|
||||
# a check:
|
||||
# if you scrolling vertically, I found no elegant way to hide the name (there just need's to be something up there!)
|
||||
# some checks:
|
||||
# 1. if you scrolling vertically, I found no elegant way to hide the name (there just need's to be something up there!)
|
||||
if self.scroll_direction and self.hide_menu_name:
|
||||
raise TypeError("Hiding the menu name whilst having the scroll direction set to horizontal!")
|
||||
# 2. if there are no menu items to display...
|
||||
if len(self.menu_items) == 0:
|
||||
raise TypeError("Can't show empty menus! Maybe you forgot calling self.setup() after initializing me?")
|
||||
|
||||
|
||||
# get some often used values into local variables
|
||||
selection_name = self.menu_items[self.current_selection][0]
|
||||
|
@ -22,4 +22,4 @@ menuItems = [("first item", first_callback),
|
||||
("third item", third_cb)]
|
||||
menu = lcdMenu(LCD, {"prev_btn":prev_btn, "next_btn": next_btn, "ok_btn": ok_btn}, menuItems, scroll_direction=False, cycle=False, hide_menu_name=True, name="Fullscreen!")
|
||||
|
||||
menu.run()
|
||||
menu.run()
|
||||
|
Loading…
Reference in New Issue
Block a user