-
Is it possible to have a TabbedContent with TabPanes inside, which are Views created by me to manage my data via controllers? Every time I move the code around and try to split it into views, I get a lot of errors. For example: def compose(self) -> ComposeResult:
yield TabbedContent(
TabPane(MainTableView(title="Library")),
TabPane(AddBookView(title="Add Book"))
)
/////////
from textual.app import App, ComposeResult
from textual.widgets import DataTable, Button
from textual.containers import Vertical
from textual.widgets import TabPane
class MainTableView(TabPane):
"""View for displaying the main table of books.""
def compose(self) -> ComposeResult:
yield Button("List") AttributeError: 'MainTableView' object has no attribute 'translate' |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @Salvodif, You are getting the There is no need to add an additional Something along the lines of this: from textual.app import App, ComposeResult
from textual.widgets import Button, Placeholder, TabbedContent, TabPane
class MainTableView(TabPane):
def compose(self) -> ComposeResult:
yield Button("List")
yield Placeholder("Your desired widgets to be placed here...")
class SandboxApp(App[None]):
CSS = """
MainTableView > Placeholder {
height: 1fr;
}
"""
def compose(self) -> ComposeResult:
with TabbedContent():
yield MainTableView("Library", Placeholder("Dynamic Widget Added"))
if __name__ == "__main__":
SandboxApp().run() If this doesn't help than a more detailed MRE will be required. |
Beta Was this translation helpful? Give feedback.
As mentioned before this:
Should be this:
Your init needs a tab title since that is where your
AttributeError
is coming from: