Change tab title dynamically #6021
-
Hi everyone, is there a possibility to change a tab pane title dynamically? Since I would like to make a counter inside a title basically, showing amount of unread messages. I have tried doing it with a reactive attribute, but this does not work, and furthermore I could not find an appropriate function in order to do this. from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.widgets import TabbedContent, TabPane
from textual.widgets._header import Header
from textual.widgets._footer import Footer
class TestApp(App[str]):
tab1_title = reactive("Tab1")
def on_key(self, event):
self.tab1_title = str(event.key) + "_test"
def compose(self) -> ComposeResult:
yield Header(show_clock=True)
with TabbedContent(initial="tab1", id="tabbed-content"):
with TabPane(title=tab1_title, id="tab1"):
pass
yield Footer(show_command_palette=True)
if __name__ == "__main__":
app = TestApp()
message = app.run()
print(message if message else "") Environment: |
Beta Was this translation helpful? Give feedback.
Answered by
TomJGooding
Aug 6, 2025
Replies: 1 comment 1 reply
-
You can update the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dorianpercic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can update the
Tab.label
for the tab returned byTabbedContent.get_tab
.