Files
textual/tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py
Rodrigo Girão Serrão 66a644845b Prevent reactive-watcher loop in Tabs / TabbedContent. (#2305)
* Add regression test for #2229.

* Fix potential reactive-watch loop.

* Simplify regression test.

Labels are cheaper to use and the final visual result of the test won't depend on the directory it runs from.

* Simplify solution.

Turns out I didn't need a descriptor. :(

* Fail on empty tab.
2023-04-18 11:48:33 +01:00

25 lines
712 B
Python

"""Regression test for https://github.com/Textualize/textual/issues/2229."""
from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Tabs, Label
class QuicklyChangeTabsApp(App[None]):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("one"):
yield Label("one")
with TabPane("two"):
yield Label("two")
with TabPane("three", id="three"):
yield Label("three")
def key_p(self) -> None:
self.query_one(Tabs).action_next_tab()
self.query_one(Tabs).action_next_tab()
app = QuicklyChangeTabsApp()
if __name__ == "__main__":
app.run()