diff --git a/__init__.py b/__init__.py index 2fe8546..5118832 100644 --- a/__init__.py +++ b/__init__.py @@ -51,15 +51,27 @@ 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!) if self.scroll_direction and self.hide_menu_name: raise TypeError("Hiding the menu name whilst having the scroll direction set to horizontal!") - # TODO: the real process - if self.scroll_direction: # if horizontal scrolling is activated - pass - else: # if vertical scrolling is activated - pass + # get some often used values into local variables + selection_name = self.menu_items[self.current_selection][0] + lw = self.lcd.num_columns + + # now show it off! + # Horizontal scrolling: + if self.scroll_direction: + self.lcd.move_to(0,0) + if self.lcd.num_lines == 4: + self.lcd.putstr(f"{self.fill_char*lw}{' '*lw*2}{self.fill_char*lw}") # fill the first and last line with 'fill_char's + self.lcd.move_to(0,1) # move to the second line for the starting message below (takes two lines) + self.lcd.putstr(f"[{self.name[0:lw-2].center(lw-2)}]") # the menu name (cannot be hidden in this mode) + self.lcd.putstr(f"<{selection_name[0:lw-2].center(lw-2)}>") # the current selected menu item's name + # Vertical scrolling: + else: + pass # TODO! print(self.current_selection) @@ -90,7 +102,7 @@ class lcdMenu: if self.lcd.num_lines == 4: self.lcd.putstr(f"{self.fill_char*lw}{' '*lw*2}{self.fill_char*lw}") # fill the first and last line with 'fill_char's self.lcd.move_to(0,1) # move to the second line for the starting message below (takes two lines) - self.lcd.putstr(f"[{selection[0][0:lw].center(lw-2)}]{self.start_execution_msg[0:lw].center(lw)}") + self.lcd.putstr(f"[{selection[0][0:lw-2].center(lw-2)}]{self.start_execution_msg[0:lw].center(lw)}") sleep(self.start_execution_wait) # wait some time before execution (so that the text can be read) # run the program