Skip to main content

A simple console menu

Project description

Simple Consol Menu

this module allows you to create simple console menu.

links

Source
Documentation
Bug Report
PyPi

Installation

pip install simple-console-menu

Usage

from simple_console_menu import Menu

Example

SimpleConsoleMenu


The first menu is the SimpleConsoleMenu.
You can use it by first importing the right file:

from simple_console_menu import Menu

And if you want to use it you can do this:

menu = Menu.simple_console_menu(menu_name: str, menu_items: list[str], input_question: str, menu_size: int = 76, auto_add_quit: bool = False, only_return_number: bool = True, allowed_characters: list[str] | str | None = None, accepted_quit_characters: str = '', return_menu_item: bool = False)

With these parameters : menu_name - Required : name of the menu (Str)
menu_items - Required : menu items ["item 1","item 2"] (List)
input_question - Optional : Question input (Str)
menu_size - Optional : Size of the menu (Int)
auto_add_quit - Optional : automatically add a quit option (Bool)
only_return_number - Optional : only numbers are allowed to return (Bool)
allowed_characters - Optional : specifier which character(s) are allowed if only_return_number is False, separated with ';' (str)
accepted_quit_characters - Optional : specifier which character is allowed if only_return_number is False for quit (str)
return_menu_item - Optional : return the menu item instead of the number (Bool)

full example:

from simple_console_menu import Menu

menuNumber = Menu.SimpleConsoleMenu('menu', ["item1","item2","item3","item4","item5"], "Number:", 76, True)

if menuNumber == 1:
    print('item1')
elif menuNumber == 2:
    print('item2')
elif menuNumber == 3:
    print('item3')
elif menuNumber == 4:
    print('item4')
elif menuNumber == 5:
    print('item5')

And this wil display

----------------------------------- menu -----------------------------------
1. item1
2. item2
3. item3
4. item4
5. item5
6. Quit
----------------------------------------------------------------------------
Number:1
item1

There is also SimpleConsoleMenuBlock which works the same as SimpleConsoleMenu but looks like this:

╭────────────────────────────────── menu ──────────────────────────────────╮
│1. item1                                                             │
│2. item2                                                             │
│3. item3                                                             │
│4. item4                                                             │
│5. item5                                                             │
│6. Quit                                                              │
╰──────────────────────────────────────────────────────────────────────────╯
Number:

it looks correct in the python console

You can also use the menu class like this:

from simple_console_menu import Menu

example_menu = Menu.menu("Menu", ["item 1", "item 2", "item 3"])
example_menu.display()
user_input = example_menu.get_user_input()
print(user_input)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_console_menu-1.0.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_console_menu-1.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file simple_console_menu-1.0.2.tar.gz.

File metadata

  • Download URL: simple_console_menu-1.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for simple_console_menu-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bc56836335a2952d2642f1ab8cc923dbe0778e1ce6f502ed2a2d44033b809ab1
MD5 4b55b30dce0ffa46f48c065abedc177a
BLAKE2b-256 d68432d4b0e461b3054d297037f5e49ef3b5f475e2e5ddd2daa7c9dbd7efe11c

See more details on using hashes here.

File details

Details for the file simple_console_menu-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_console_menu-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 76352a1fe228d2a633a4c765a8e240505e961e9f3a2284fae6027a262b3792c9
MD5 397be3b73c151ed5823eb7edac0cce3d
BLAKE2b-256 04d437866895fe214181d0daca64fb37a127405006046a7d9318f1c2bb1514ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page