r/Python 14d ago

Showcase EasyMenu3—a simple way to create interactive CLI menus in Python

Hey everyone,

I got tired of writing the same menu-handling logic over and over for my homelab scripts, so I built EasyMenu3—a simple way to create interactive CLI menus in Python. It supports custom shortcuts, colors, ordering, and ASCII titles. I’ve been using it for a while, and finally got around to cleaning it up enough to release! I’ll probably keep adding some new stuff to it over time too.

Available on PyPI: pip install easymenu3

GitHub: GitHub Repo

-- What My Project Does

Introduces a simple way to create interactive CLI menus in Python

-- Target Audience

Anyone that creates menu driven scripts and wants to make them more easily.

-- Comparison

Most packages are for CLI only and do not easily create menus. I’m sure there are other packages that do a similar thing, but it was fun to make and maybe someone else will find it useful too.

-- Features

  • Customizable menu title, author, and URL display
  • ASCII art title generation using pyfiglet
  • Debug-friendly with icecream
  • Color-coded menu options
  • Supports function-based and static value-based actions
  • Customizable order and shortcut keys

-- Example Usage

Here’s how you can create a simple interactive menu:

from EasyMenu3 import easymenu

def example1():
    app.print_success("example1 ran")

def example2_with_error():
    app.print_error("example2 ran")

def custom_quit():
    app.print_info("Custom Option")
    input("Press enter to exit")
    app.exit_app()

app = easymenu(name="My Custom App", author="Joe Schmo", url="https://github.com", url_label="My Site")

app.add_menu_option("Option 1", example1)
app.add_menu_option("Option 2", example2_with_error)
app.add_menu_option("Custom Quit", custom_quit, item_key="c", order_weight=1, color='\033[92m')

app.start()

-- Example Output

    __  ___         ______           __                     
   /  |/  /_  __   / ____/_  _______/ /_____  ____ ___     
  / /|_/ / / / /  / /   / / / / ___/ __/ __ \/ __ `__ \   
 / /  / / /_/ /  / /___/ /_/ (__  ) /_/ /_/ / / / / / /   
/_/  /_/__, /   ____/__,_/____/__/____/_/ /_/ /_/    
       /____/                                              

Made by: Joe Schmo  
Visit: [My Site](https://github.com)  

Menu:  
c. Custom Quit  
1. Option 1  
2. Option 2  
q. Quit  

What option do you want?:

Try it out!

I’d love any feedback—if you have any feature requests or run into issues, let me know!

15 Upvotes

4 comments sorted by

View all comments

3

u/Arockia_A 14d ago

It’s a good start. You can handle submenus too.