Skip to main content

A terminal-based menu system using blessed.

Project description

Starri

Starri is a simple Python library for creating terminal-based menus. It supports navigation with the arrow keys and submenus for a dynamic user experience.

Installation

You can install Starri with pip:

pip install starri

Usage

Here’s how to use Starri:

# Comments unnecessary, just for explanation

from starri import *

def main():
    starri(
        title = "Main Menu", # Shown at the top of the screen
        content = {
            spacer() # Blank line, cannot be selected
            text("Please Select an Option Below.") # Text, cannot be selected
            spacer() # Blank line, cannot be selected
            option("Option 1", option1()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
            option("Option 2", option2()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
            option("Option 3", option3()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
            option("Option 4", option4()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
            option("Option 5", option5()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
            option("Exit", exit()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
        }
    )

def option1():
    starri(
        title = "You Pressed Option 1!" # Shown at the top of the screen
        content = {
            option("Go Back", main()) # Basic option, can be selected. first arg is the text for the option, second arg is what it does if selected
        }
    )

def option2():
    starri(
        title = "You Pressed Option 2!" # Shown at the top of the screen
        content = {
            spacer() # Blank line, cannot be selected
            text("Example Confirmation?") # Text, cannot be selected
            spacer() # Blank line, cannot be selected
            sidebyside("Yes", dosomething(), "No", cancel()) # Two options, side by side. navigate betweeen the two by using the left and right arrow keys. horizontally centered by default, and spaced evenly.
        }
    )

def option3():
    starri(
        title = "You Pressed Option 3!" # Shown at the top of the screen
        content = {
            spacer() # Blank line, cannot be selected
            text("Checkboxes Example")  # Text, cannot be selected
            spacer() # Blank line, cannot be selected
            checkbox(
                "Checkbox 1", False, # First arg is the text for the checkbox, second arg is whether it is checked by default
                "Checkbox 2", False, # First arg is the text for the checkbox, second arg is whether it is checked by default
                "Checkbox 3", False, # First arg is the text for the checkbox, second arg is whether it is checked by default
                "Checkbox 4", False, # First arg is the text for the checkbox, second arg is whether it is checked by default
                "Checkbox 5", False, # First arg is the text for the checkbox, second arg is whether it is checked by default

                submitbutton("Submit", exampleactionaftercheckboxes()) # Text for the submit button

            )

        }
    )

def exampleactionaftercheckboxes():
    if box1:
        print("Checkbox 1 is checked!")
    if box2:
        print("Checkbox 2 is checked!")
    if box3:
        print("Checkbox 3 is checked!")
    if box4:
        print("Checkbox 4 is checked!")
    if box5:
        print("Checkbox 5 is checked!")

def option4():
    starri(
        title = "You Pressed Option 4!" # Shown at the top of the screen
        content = {
            spacer() # Blank line, cannot be selected
            text("Text Input Example") # Text, cannot be selected
            spacer() # Blank line, cannot be selected
            textinput("Enter some text:", exampleactionaftertextinput()) # Text input, first arg is the prompt, second arg is what to do with the input. second arg is called on enter when selected
        }
    )
    
if __name__ == "__main__":
    main()

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

starri-1.5.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

starri-1.5.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file starri-1.5.1.tar.gz.

File metadata

  • Download URL: starri-1.5.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for starri-1.5.1.tar.gz
Algorithm Hash digest
SHA256 c8ba26e61fb6f6128467b4b81175a8245494f0b1453853334ac2d5b31e0fc110
MD5 9cfc0f42ba29fc687f50f9af9b195209
BLAKE2b-256 d23d3c9ef9984a55d52ab5ae024ead73e4d7b5f8d5a1c51998c4da80b13034da

See more details on using hashes here.

File details

Details for the file starri-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: starri-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for starri-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a472c7b6c7fd735799e8d33c1ec574e69ef2f6cf243a664f32b2db854dd7c2bd
MD5 2bab0b97f5d4a7be7aed16de023b0288
BLAKE2b-256 61ca42a5b3d2712c76fbb49a40d4eaace5fc79cb02f20d87992b56cc4921b1a3

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