Skip to main content

A simple library for creating different interactive menus

Project description

ASCII-Menus

ASCII_Menus is a simple library for creating different interactive menus

🚀 Features

  • Simple and legible menus: Menus with options in cell format, title and displayed through the terminal.
  • Custom size menu: Customizable size based on the number of options required, both in rows and columns.
  • Custom size options: Customize the number of characters per option.
  • Support for multiple pages of options
  • Simple Scroll-Bar system
  • Two interaction modes: Dynamic <--> Static.
  • With Cursor

🛠 Installation

 $ pip install ASCII-Menus

📖 Quick Start

Generate basic menu and show it

from ASCII_Menus import Menu

options_list = [
    "test", "....", "menu",
    "test", "....", "menu",
    "test", "....", "menu",
    "test", "....", "menu"
]

test_menu = Menu("test_menu", 3, 4, 5, options_list)
test_menu.show_frame_menu()
+-------------------------+
|        test_menu        |
|-------------------------|
|                         |
| > test    ....    menu  |
|                         |
|   test    ....    menu  |
|                         |
|   test    ....    menu  |
|                         |
|   test    ....    menu  |
+-------------------------+

Move cursor

...
input_user = MOVE_DOWN
test_menu.control_menu(input_user)
+-------------------------+
|        test_menu        |
|-------------------------|
|                         |
|   test    ....    menu  |
|                         |
| > test    ....    menu  |
|                         |
|   test    ....    menu  |
|                         |
|   test    ....    menu  |
+-------------------------+

Select option

Returns a str containing the option name, if the option contained a function, executes them.

...
input_user = OK_BUTTON
name_option = test_menu.control_menu(input_user)
print(name_option)
"test"

🌎 Real-World Examples

A short application example

from os import system
from src.ASCII_Menus import Menu

# Create the options
TEST_LIST = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']
# To generate the Menu called "test_menu"
TEST_MENU = Menu("test_menu", 2, 3, 10, TEST_LIST)

# Functions you want to add to the menu
def f_01(x: int, y: int):...    
def f_02(x: int, y: int):...
def f_03(x: int, y: int):...
def f_04(x: int, y: int):...
def f_05(x: int, y: int):...    
def f_06(x: int, y: int):...    
def f_07(x: int, y: int):...
def f_08(x: int, y: int):...
def f_09(x: int, y: int):...
def f_10(x: int, y: int):...
def f_11(x: int, y: int):...
def f_12(x: int, y: int):...


def main():
    # List to be able to incorporate a function by positional order to each menu option
    functions_list = [
        (f_01, {"x": 1,"y": 10}),
        (f_02, {"x": 2,"y": 11}),
        (f_03, {"x": 3,"y": 12}),
        (f_04, {"x": 4,"y": 13}),
        (f_05, {"x": 5,"y": 14}),
        (f_06, {"x": 6, "y": 15}),
        (f_07, {"x": 7, "y": 16}),
        (f_08, {"x": 8, "y": 17}),
        (f_09, {"x": 9, "y": 18}),
        (f_10, {"x": 10, "y": 19}),
        (f_11, {"x": 11, "y": 20}),
        (f_12, {"x": 12, "y": 21}),
    ]

    # Adds all the functions to menu
    TEST_MENU.add_function_to_menu(functions_list)

    # Shows the first frame
    TEST_MENU.show_frame_menu()

    while True:
        # Catches the user input
        input_u = input("...")
        # Clean the terminal
        system("cls")
        # Checks if the input generates a valid action and executes it
        TEST_MENU.control_menu(input_u)
        # Shows the frame changed
        TEST_MENU.show_frame_menu()
        

if __name__ == "__main__":
    main()

📄 License

This project is licensed under the MIT License.

📬 Contact

For any inquiries, reach out to me via:

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

ascii_menus-1.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

ascii_menus-1.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file ascii_menus-1.0.0.tar.gz.

File metadata

  • Download URL: ascii_menus-1.0.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for ascii_menus-1.0.0.tar.gz
Algorithm Hash digest
SHA256 afc2ef2e79c8eb30b6d33adb97e78c421c967036e187a9104f2bd9c2b9e1aec2
MD5 8a716fd129b6b64a54f66cfada773ad4
BLAKE2b-256 3ac57300f543f6e8c2ea8a889c697b0fd9dbbfb18139cae0e774c126b2a12b97

See more details on using hashes here.

File details

Details for the file ascii_menus-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ascii_menus-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for ascii_menus-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 553d51ba107640adb73de5a78e76afd11b24002ec08bbd00b67e2e1730a9221f
MD5 bfa0f7b49cc06931d15d385b6d71e9cb
BLAKE2b-256 6def229d98e4a7eea8fb39c376794b89b13d31dd67e862dd84fea1b332f1b737

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