Giter Site home page Giter Site logo

menuchoice's Introduction

menuchoice

Pepy Total Downlods GitHub repo size PyPi - Version

menuchoice is a terminal-based menu selector with different menu styles and features.

menuchoice-demo2

Usage

Creating a selection menu:

import menuchoice
menu = menuchoice.MenuSelector(items=[
    "Hip-hop",
    "Rock",
    "Pop",
    "Country",
    "EDM",
], title="Most Streamed Music USA", description="Select a genre of music.")

Tip

items can be given brief descriptions if they are type dictionary: {"option": "brief description"}

Arrow Selection

Arrow select will display an arrow which can be moved up/down with the arrow keys:

menu.arrow_select()

Output upon selection:

[(4, "EDM")]

Additionally, multiple options can be selected:

# no less than 2, no more than 3
menu.arrow_select(max_items=(2, 3))
# Adds an option to select all items
menu.arrow_select(allow_all=True)

Output:

[(4, "EDM"), (1, "Rock")]

Highlight Selecting

Highlight menus introduce the ability to have multiple pages (this is optional):

menu.highlight_select(pages=[[0, 1, 2], [3, 4]])

The above code will create two pages, the first page contains the first three options, the second contains the last two options.
To switch between these pages, use the left/right arrow keys.

The highlight menu can also disable options:

menu.highlight_select(disabled_items=[3])

This code above will prevent the user from selecting index 3 of the menus items (the fourth option).

Modifying Options

Menu selector items can have multiple options which can be navigated through with left/right arrow keys.

menu.modify_select(options=[(0, "second option", "third option")])

This will allow the user to use left/right arrow keys to navigate through 3 different options for a single item's line.

menuchoice's People

Contributors

xyzpw avatar

Watchers

 avatar

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.