Skip to main content

Extends the Rich library with interactive layouts and tables, allowing seamless navigation and interaction via keyboard shortcuts

Project description

PyPI version

Rich Interactive

Extends the Rich python library with interactive layouts and tables, allowing seamless navigation and interaction via keyboard shortcuts

Installation

pip install rich_interactive

or using poetry

poetry add rich_interactive

Interactive Tables

You can create interactive tables that can be easily navigated, and you can switch the selection to any of the rows.

from rich import print
from rich.style import Style
from rich_interactive.interactive_table import InteractiveTable as Table

table = Table(
    selected_row=2,
    rotate_selection=True,
    selected_row_style=Style(bgcolor="red"),
)
table.add_column("#")
table.add_column("Column 1")

for row in range(3):
    table.add_row(f"{row}", f"Row {row}")

print("Initial table")
print(table)

table.move_selection_down()

print("Table after moving selection down")
print(table)

Interactive Layouts

You can create interactive layouts that can be easily navigated, and you can switch the selection to any of the children.

from rich.console import Console
from rich.text import Text

from rich_interactive.interactive_panel import InteractivePanel as Panel
from rich_interactive.interactive_layout import InteractiveLayout as Layout


console = Console(width=60, height=15)

layout = Layout()
layout.split(
    Layout(name="header", size=5),
    Layout(name="main", size=5),
    Layout(name="footer", size=5),
)

for child in layout.children:
    child.update(Panel(Text(child.name, style="yellow")))

print("Initial layout:")
print(layout)

layout.switch_selection()

print("After switching selection:")
print(layout)

Future plans

My personal goal, is to prepare a good quality package, which would enable easy navigation with keyboard, like this:

(Disclaimer: functionality shown in this gif is still in PoC stage, and it is not production ready yet)

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

rich_interactive-0.6.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

rich_interactive-0.6.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file rich_interactive-0.6.0.tar.gz.

File metadata

  • Download URL: rich_interactive-0.6.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Darwin/23.4.0

File hashes

Hashes for rich_interactive-0.6.0.tar.gz
Algorithm Hash digest
SHA256 54884e061849aea1190aa6e83a154e73ab48ad17594b4f848f5fa1de388ae10c
MD5 7c0e822d9ed8bfd90da1b6dc5ce7e0fe
BLAKE2b-256 6d5b3344f245f81276faa4ebdd5354d1eeccb74e7b46b6d32be22e3dd72d30f4

See more details on using hashes here.

File details

Details for the file rich_interactive-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rich_interactive-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb725ecf1b43f549f22c9db0fafa095698a9683717e29fae07d62df5503feeeb
MD5 543bcc134f5888e192bb21346ff8253d
BLAKE2b-256 9672422a533c46dbfbc569ae63d73b72f74ea87c1ac31f1008d37519eeef905b

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