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
Variables.HIGHLIGHT = "\033[30;43m"
from colorama import Fore, Back
Variables.HIGHLIGHT = Back.RED + Fore.BLACK
Variables.DECORATOR = ["<", ">"]
Variables.DECORATOR = []
Variables.DECORATOR = ["> "]
def func1(text):
print(text)
def func2():
print("Hi !")
buttons = [dict(name="Button 1", function=func1, args=("Hello !")),
dict(name="Button 2", function=func2)]
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 *
def func1(text):
print(text)
def func2():
print("Hi !")
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),]
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)
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.