Skip to main content

Basic text menu for console

Project description

Python text menu

Python module for interacting with the user through console, to install module from pip execute:

pip install python_text_menu

Simple use

from python_text_menu import print_menu, ask_option

options = ['Option 1', 'Option 2', 'Option 3']
print_menu(options)
choice = ask_option(len(options))

Output:

Menu:
[1] Option 1
[2] Option 2
[3] Option 3
[4] Exit
Select an option: 

Then you can create your own flow based on 'choice':

if choice == '1':
    # Do something
elif choice == '2':
    # Do something else
...

[!WARNING] Consider that ask_option() implements the built-in input() function and as such it locks the code flow

Customize

You can customize it by giving it a title, a separator and/or an input text:

options = ['Option 1', 'Option 2', 'Option 3']
choice = print_menu(options, title='New title', sep=''*20, input_text='Choose something...')

Output:

New title:
====================
[1] Option 1
[2] Option 2
[3] Option 3
[4] Exit
Choose something...

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

python_text_menu-0.0.5.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

python_text_menu-0.0.5-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file python_text_menu-0.0.5.tar.gz.

File metadata

  • Download URL: python_text_menu-0.0.5.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for python_text_menu-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e8f5e8539ca1f7a88e8edf648c68a6b3d3a8bced8043f27eed3547e9100acc4c
MD5 7808836e0893bc8d8218359c4ab44753
BLAKE2b-256 96fbc6d101a8b1282a424f7356609ecab71f434ff00663cb2c13d7c56ebbc8ee

See more details on using hashes here.

File details

Details for the file python_text_menu-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for python_text_menu-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ba1f988f011b88977d0d8437a234b600845bcb36d948c11b495d0fa4cbe4f156
MD5 6c06ef3c478f83dae11f2327429f4a12
BLAKE2b-256 fb9483d44711dcbee592ad94c2924a9129c50ea30af4ba8e8841e6cbee5cb80e

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