-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to rename tabs (TabPane). #3901
Comments
To add to the above, this can pretty much be done right now with code like this: from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label
class TCRenameApp(App[None]):
BINDINGS = [
("space", "rename"),
]
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("One", id="one"):
yield Label("Press space to change my Tab's label")
with TabPane("Two", id="two"):
yield Label("This one won't rename")
def action_rename(self) -> None:
self.query_one(TabbedContent).get_tab("one").update("Renamed!")
if __name__ == "__main__":
TCRenameApp().run() but the to this: At its most basic level this could be an issue to ensure that the underline gets a refresh; but it could also be an issue for adding a @ggozad Thinking about it some more this morning, you can do what you want like this: from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label, Tabs
class TCRenameApp(App[None]):
BINDINGS = [
("space", "rename"),
]
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("One", id="one"):
yield Label("Press space to change my Tab's label")
with TabPane("Two", id="two"):
yield Label("This one won't rename")
def action_rename(self) -> None:
tabbed_content = self.query_one(TabbedContent)
tabbed_content.get_tab("one").update("Renamed!")
tabbed_content.query_one(Tabs).show("one")
if __name__ == "__main__":
TCRenameApp().run() that call to |
Oooh thank you @davep ! |
@ggozad My pleasure. I'm inclined to leave this open as I feel this is an obvious thing to want to do and it should probably have a very obvious API. Thanks for raising it. |
Let's add a more elegant API for this. |
In support of a better interface for Textualize#3901.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
In support of a better interface for #3901.
Currently this is not supported AFAIK. If one wants to change the title of a tab, they need to remove and add it again.
Fetching the
Tab
withinTabPane
and updating it doesn't fully work, for instance the underline does not adapt.The text was updated successfully, but these errors were encountered: