Code Monkey home page Code Monkey logo

quick-menu's Introduction

quick-menu

PyPI - Version PyPI - Python Version


This is a simple package to create text menus for use in console applications.

Usage

A menu can be created quickly that can call a function with or without a value. An exit item is automatically added to the menu.

Create a Quick Menu

from quick_menu.menu import Menu, MenuItem

def func(val=1):
    print("func1: val =", val)
    input("Press [Enter] to continue")

menu = Menu(
    "Simple Menu",
    menu_items=[
        MenuItem("1", "Func default", action=func),
        MenuItem("2", "Func with val=4", action=func, action_args={"val": 4}),
    ]
)

menu.run()

Output

============== Simple Menu =============
1: Func default
2: Func with val=4
X: Exit
========================================
>> 1
func1: val = 1
Press [Enter] to continue

============== Simple Menu =============
1: Func default
2: Func with val=4
X: Exit
========================================
>> 2
func1: val = 4
Press [Enter] to continue

Documentation

The documentation is made with Material for MkDocs and is hosted by GitHub Pages.

Installation

pip install quick-menu

License

quick-menu is distributed under the terms of the MIT license.

quick-menu's People

Contributors

yqbear avatar

Watchers

 avatar

quick-menu's Issues

Add tests for full coverage

Test trying to update a menu item from a choice that doesn't exist.
The test for an exit key in add is no longer valid since the code always ensures there is an exit key available at the end of an add.

Add an exit menu item if none is present

This should handle two issue.

  1. If no exit exists for a menu then add a default one. add(MenuItem("X", "Exit", is_exit=True))
  2. There can be only one. Each exit menu item added should replace an existing one.

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.