Coder Social home page Coder Social logo

upymenu's Issues

Bug with more than 5 items

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.

All menu items are not displayed

Good afternoon. I'm trying to implement a menu on the 2004 display. The code will be below. The problem is that when activated, the menu does not show the entire list of items on the screen, but only the last one. And also, instead of the cursor on the screen, the letters "SA". What could be the problem?
If the menu works fine, the next question is: how to fasten the execution of the interrupt function to it.
`called_back_main = False
called_back_sub = False

def action_callback_main():
global called_back_main
print ("Действие главного меню")
called_back_main = True
def action_callback_sub():
global called_back_sub
print ("Действие подменю")
called_back_sub = True

submenu = Menu("Submenu")
submenu_action_1 = MenuAction("Submenu Action", callback=action_callback_sub)
submenu_action_2 = MenuAction("Submenu Action 1", callback=action_callback_sub)
submenu.add_option(submenu_action_1)
submenu.add_option(submenu_action_2)

menu = Menu("Main menu")
menu_action_1 = MenuAction("Action_1", callback=action_callback_main)
menu_action_2 = MenuAction(" Action_2", callback=action_callback_main)
menu.add_option(submenu)
menu.add_option(menu_action_1)
menu.add_option(menu_action_2)
menu.add_option(MenuNoop(" Главное меню"))

current_menu = menu.start(lcd)`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.