-
This is my test code that shows a simple DataTable is not working in TabbedContent. from textual.app import App, ComposeResult
from textual.widgets import DataTable, TabbedContent, TabPane, Markdown
class UsersDataTable(DataTable):
def __init__(self):
super().__init__()
self.add_column("ID")
self.add_column("Name")
for id, name in [
('1', 'Alice'),
('2', 'Bob'),
]:
self.add_row(id, name)
class SuperAdminApp(App):
TITLE = "Super-admin TUI"
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
with TabbedContent(initial="users"):
with TabPane("Users", id="users"):
yield UsersDataTable() # This is not displayed
with TabPane("Other tab", id="other"):
yield Markdown("ok") # This works
yield UsersDataTable() # This works. I can also remove this and the above does not work.
if __name__ == '__main__':
app = SuperAdminApp()
app.run() |
Beta Was this translation helpful? Give feedback.
Answered by
Matteomt
Aug 24, 2023
Replies: 2 comments
-
You may find this previous similar discussion useful. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I suspected something about automatic height being zero, so I tried adding Now I changed it to |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Matteomt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suspected something about automatic height being zero, so I tried adding
self.styles.height = 30
inUsersDataTable
but it changed nothing.Now I changed it to
self.styles.height = '1fr'
and it solved my issue. Thanks @davep for the suggested discussion!