diff --git a/__init__.py b/__init__.py index 57c11cd..0ab760e 100644 --- a/__init__.py +++ b/__init__.py @@ -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] diff --git a/example_simple.py b/example_simple.py index b182061..d1b2e32 100644 --- a/example_simple.py +++ b/example_simple.py @@ -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() \ No newline at end of file +menu.run()