Skip to content

Bug with more than 5 items #4

@facuver

Description

@facuver

Hello, I am using you library and is working great now (Thanks) but I have to make a few changes to make it work.

  1. First one was that the menu was render side wise not vertical. Maybe this is only with my display library. To fix it I swap the variables in render().
    def _render_cursor(self):
        for l in range(0, self.lines):
            self.lcd.move_to(0, l)

and


  def _render_options(self):
        # Render the options:
        for l, option in enumerate(self.viewport):
            self.lcd.move_to(1, l)  # Move to the line

2)When I have more than 8 options the view chunk retrun was off. With this code is working for me (also no need of import math anymore):

    def _current_chunk(self):
        return int((self.focus -1) / (self.lines ))  # current chunk
  1. and finally I added the variable self.current with the menu object been render so I can control the sub menus more easily:
    def __init__(self, title, render_title=False):
        self.current = self
    def parent(self):
        if self.parent_menu:
            self.active = False
            self.parent_menu.current = self.parent_menu
            return self.parent_menu.start(self.lcd)

    def _choose_menu(self, submenu):
        self.active = False
        self.current = submenu

thanks for sharing the library. Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions