Skip to main content

No project description provided

Project description

Interactive Buttons Library

A Python library for creating interactive buttons with keyboard navigation.

Installation

You can install the Interactive Buttons library via pip:

pip install interactive_buttons

Usage

Here's an example of how to use the library to create interactive buttons with linear_buttons :

from interactive_buttons import *
from colorama import Fore, Back

# Change button color :
# Way 1 :
Variables.HIGHLIGHT = "\033[30;43m"  # Yellow background
# Way 2 :
from colorama import Fore, Back  # Needs to be installed by running the command `pip install colorama`
Variables.HIGHLIGHT = Back.RED + Fore.BLACK  # Red background and Black text

# Change decorator (in [button text] the square brackets are the decorators) :
# Way 1 :S
Variables.DECORATOR = ["<", ">"]  # [button text] -> <button text>
# Way 2 :
Variables.DECORATOR = []  # [button text] -> button text
# Way 3 :
Variables.DECORATOR = ["> "]  # [button text] ->  > button text

# Creating functions
def func1(text):
    print(text)

def func2():
    print("Hi !")

# Define button configurations as a list
buttons = [dict(name="Button 1", function=func1, args=("Hello !")),
           dict(name="Button 2", function=func2)]

# Create linear buttons and start the interactive interface
linear_buttons(buttons)

Output example

Example with column_buttons :

⚠️ WARNING : To use this function, you must not use an emulated terminal.

from interactive_buttons import *

# Creating functions
def func1(text):
    print(text)

def func2():
    print("Hi !")

# Define button configurations as a list
buttons = [dict(name="Button 1", function=func1, args=("Hello !")),
           dict(name="Button 2", function=func2),
           dict(name="Button 3", function=func1, args=("Hello2 !")),
           dict(name="Button 4", function=func2),]

# Create column buttons and start the interactive interface
column_buttons(buttons)

Output example

Example with matrix_buttons :

⚠️ WARNING : To use this function, you must not use an emulated terminal.

from interactive_buttons import *
from colorama import Fore, Back

Variables.SPACES += Variables.SPACES
Variables.HIGHLIGHT = Back.RED + Fore.BLACK

def say(message):
    print(message)
    return message
    

matrix = [
          [dict(name="Button A Line 1", function=say, args="A1"), dict(name="Button B Line 1", function=say, args="B1")],
          [dict(name="Button A Line 2", function=say, args="A2"), dict(name="Button B Line 2", function=say, args="B2")],
        ]

output = matrix_buttons(matrix)
print(output)  # You can now get the returned value of your function

Output example

Project Description

The Interactive Buttons library allows you to easily create interactive buttons for user interaction in your Python applications. It provides a simple and intuitive way to create a list of buttons, associate them with functions, and navigate through them using the keyboard. This library is particularly useful for creating text-based interactive menus and interfaces.

GitHub Repository

Check out the GitHub repository for the latest updates, issues, and contributions. Feel free to contribute to the project or report any issues you encounter.

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

interactive_buttons-3.5.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

interactive_buttons-3.5.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file interactive_buttons-3.5.0.tar.gz.

File metadata

  • Download URL: interactive_buttons-3.5.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for interactive_buttons-3.5.0.tar.gz
Algorithm Hash digest
SHA256 6718ed54ab84d47025eb32eba92b87857818156a036e4bf64a9daf190c12df5d
MD5 929e7d2e63c965f8596579c3a4eab04c
BLAKE2b-256 e5640c23c0968f4845ecd268e6b09b280abce6110ca050b5ffaaf2db2e328f78

See more details on using hashes here.

File details

Details for the file interactive_buttons-3.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for interactive_buttons-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14a81023750cd5a8eb893a45f9d83ed96ece830ad95bd1ec843e30c0b806902b
MD5 32f9917fc8361cde174bf7b31725525c
BLAKE2b-256 2699f3afe9f9732997f6eef86fe55371cf1670bbdfd24dff4c49450c3e649a1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page