or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/textual@6.1.x
tile.json

tessl/pypi-textual

tessl install tessl/pypi-textual@6.1.0

Modern Text User Interface framework for building cross-platform terminal and web applications with Python

Agent Success

Agent success rate when using this tile

93%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.18x

Baseline

Agent success rate without this tile

79%

task.mdevals/scenario-8/

Status Card Widget

Build a customizable status card widget for a terminal application that displays status information with dynamic styling based on status type.

Requirements

Create a Python module that implements a status card widget with the following features:

Status Card Widget

The widget should display status information in a card format with:

  • A title at the top
  • A status message in the center
  • A status type indicator (success, warning, error, info)

Styling Requirements

The widget must support different visual styles based on the status type:

Success status:

  • Green border
  • Green text color for the title
  • Light background

Warning status:

  • Yellow/amber border
  • Yellow/amber text color for the title
  • Slightly darker background

Error status:

  • Red border
  • Red text color for the title
  • Dark background

Info status:

  • Blue border
  • Blue text color for the title
  • Default background

Dynamic Style Switching

The widget must be able to change its status type at runtime, with the styling updating automatically to reflect the new status.

Layout and Spacing

  • The card should have padding around the content
  • The border should be visible and styled
  • Text should be centered within the card
  • The card should have a fixed width of 40 cells and height of 8 cells

Implementation

@generates

API

from textual.app import App
from textual.widget import Widget

class StatusCard(Widget):
    """A customizable status card widget with dynamic styling."""

    def __init__(self, title: str, message: str, status: str = "info") -> None:
        """
        Initialize the status card.

        Args:
            title: The title text to display
            message: The status message to display
            status: The status type ("success", "warning", "error", or "info")
        """
        pass

    def set_status(self, status: str) -> None:
        """
        Change the status type, updating the styling accordingly.

        Args:
            status: The new status type ("success", "warning", "error", or "info")
        """
        pass

Test Cases

  • The card displays with green styling when status is "success" @test
  • The card displays with yellow styling when status is "warning" @test
  • The card displays with red styling when status is "error" @test
  • The card displays with blue styling when status is "info" @test
  • Calling set_status() changes the card's styling dynamically @test

Dependencies { .dependencies }

textual { .dependency }

Provides the TUI framework with CSS-like styling capabilities.