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

test_menu = Menu("test_menu", 3, 4, 5,
                 [
                     "test", ":", "menu",
                     "test", ":", "menu",
                     "test", ":", "menu",
                     "test", ":", "menu",
                 ])
test_menu.menu_crafter()
+-------------------------+
|        test_menu        |
|-------------------------|
|                         |
| > test    :       menu  |
|                         |
|   test    :       menu  |
|                         |
|   test    :       menu  |
|                         |
|   test    :       menu  |
+-------------------------+

Move cursor

...
test_menu.change_coordinate_cursor("s")
test_menu.menu_crafter()
+-------------------------+
|        test_menu        |
|-------------------------|
|                         |
|   test    :       menu  |
|                         |
| > test    :       menu  |
|                         |
|   test    :       menu  |
|                         |
|   test    :       menu  |
+-------------------------+

Select option

...
input_user = input()

if input_user.lower() == "q":
    test_menu.select_option()

Returns a tuple containing the cursor coordinates and the name option string.

([0, 1, 0], "test")

🌎 Real-World Examples

A short application example

from ASCII_Menus import Menu
import readchar

# Create your menu
TEST_MENU = Menu("test_menu", 3, 4, 5,
                 [
                     "test", ":", "menu",
                     "test", ":", "menu",
                     "test", ":", "menu",
                     "test", ":", "menu",
                 ])

SELECT_KEY = "q"
TEST_OPTION = "test"

def options_test():
    pass

def main():
    while True:
        input_user = readchar.readchar()
        select_option = ""
        # If you select the option
        if input_user.lower() == SELECT_KEY:
            select_option = TEST_MENU.select_option()[1]
        
        # Ejecute function associated with the menu
        if select_option == TEST_OPTION:
            options_test()
        
        # Show menu and update cursor coordinates.
        TEST_MENU.menu_crafter()
        TEST_MENU.change_coordinate_cursor(input_user)
        

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-0.1.0.tar.gz (9.9 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-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ascii_menus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a736b0fd1bdb73e34b1adf95904f0d43701f89762a5d0688da8298aab76fe1c1
MD5 a3f2869041347399c3bb03aa3b826c32
BLAKE2b-256 2646fe092a75a96a6909ef486e0b6c09167ee9c478e50fff44fb0f8e2e78d27c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ascii_menus-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa1d3ee48c836409abe254afd63aa4b268562cf18732fb89aa8b51a9f0bf3344
MD5 82bf7f016d875cd6dcfa20478b3d1584
BLAKE2b-256 00e7a70a21f69c80e27153d9d0a2dd7c78f6f7d13e42f58e1b8af9d1b144e935

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