Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
25.16k stars 769 forks source link

TabbedContent visuals broken when animations are disabled #4814

Closed ihabunek closed 1 month ago

ihabunek commented 2 months ago

Consider the following program:

from textual.app import App
from textual.binding import Binding
from textual.widgets import Label, TabbedContent, TabPane

class ReproApp(App[None]):
    BINDINGS = [
        Binding("alt+w", "close_pane"),
    ]

    def __init__(self):
        super().__init__()
        self.animation_level = "none"

    def compose(self):
        with TabbedContent():
            yield TabPane("foo", Label("foo contents"))
            yield TabPane("bar", Label("bar contents"))
            yield TabPane("baz", Label("baz contents"))
            yield TabPane("qux", Label("qux contents"))

    def action_close_pane(self):
        tc = self.query_one(TabbedContent)
        if tc.active:
            tc.remove_pane(tc.active)

if __name__ == "__main__":
    app = ReproApp()
    app.run()

To reproduce:

  1. Run the above app
  2. Switch to the "baz" tab
  3. Press alt+w to close the pane

This causes the underline to be shown below the empty space after the third tab, instead under "qux" which is the newly focused tab.

Demo: https://asciinema.org/a/HiD6rbOigLtQbcPGva8F6Tdlu

If animations are set to full this does not happen.

Textual Diagnostics # Textual Diagnostics ## Versions | Name | Value | |---------|--------| | Textual | 0.74.0 | | Rich | 13.7.1 | ## Python | Name | Value | |----------------|----------------------------------------------| | Version | 3.12.4 | | Implementation | CPython | | Compiler | GCC 14.1.1 20240607 (Red Hat 14.1.1-5) | | Executable | /home/ihabunek/.virtualenvs/pgtui/bin/python | ## Operating System | Name | Value | |---------|-----------------------------------------------------| | System | Linux | | Release | 6.9.5-200.fc40.x86_64 | | Version | #1 SMP PREEMPT_DYNAMIC Sun Jun 16 15:47:09 UTC 2024 | ## Terminal | Name | Value | |----------------------|-------------| | Terminal Application | Kitty | | TERM | xterm-kitty | | COLORTERM | truecolor | | FORCE_COLOR | *Not set* | | NO_COLOR | *Not set* | ## Rich Console options | Name | Value | |----------------|----------------------| | size | width=104, height=40 | | legacy_windows | False | | min_width | 1 | | max_width | 104 | | is_terminal | False | | encoding | utf-8 | | max_height | 40 | | justify | None | | overflow | None | | no_wrap | False | | highlight | None | | markup | None | | height | None |
github-actions[bot] commented 1 month ago

Don't forget to star the repository!

Follow @textualizeio for Textual updates.