multiple Datatable in TabbedPane: #4203
Unanswered
sarangdhonde
asked this question in
Q&A
Replies: 4 comments 1 reply
-
What is the actual problem you're seeing? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for your response
Issue is i dont know how do i put. Multiple datatable into tabbedpane , basicallly idea is to have datatable in each tab
But i struggling with on_mount. Method where u can obviously have single on_mount method , in this case how do we get this done
Any help is greatly appreciated
Thanks
…On 23 Feb 2024 at 11:03 PM +0530, Dave Pearson ***@***.***>, wrote:
What is the actual problem you're seeing?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Something like this? from textual.app import App, ComposeResult
from textual.widgets import DataTable, Footer, TabbedContent, TabPane
ROWS = [
("lane", "swimmer", "country", "time"),
(4, "Joseph Schooling", "Singapore", 50.39),
(2, "Michael Phelps", "United States", 51.14),
(5, "Chad le Clos", "South Africa", 51.14),
(6, "László Cseh", "Hungary", 51.14),
(3, "Li Zhuhao", "China", 51.26),
(8, "Mehdy Metella", "France", 51.58),
(7, "Tom Shields", "United States", 51.73),
(1, "Aleksandr Sadovnikov", "Russia", 51.84),
(10, "Darren Burns", "Scotland", 51.84),
]
class TabbedApp(App):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("Table #1"):
yield DataTable(id="table-1")
with TabPane("Table #2"):
yield DataTable(id="table-2")
with TabPane("Table #3"):
yield DataTable(id="table-3")
yield Footer()
def on_mount(self) -> None:
table_1 = self.query_one("#table-1", DataTable)
table_1.add_columns(*ROWS[0])
table_1.add_rows(ROWS[1:])
table_2 = self.query_one("#table-2", DataTable)
table_2.add_columns(*ROWS[0])
table_2.add_rows(ROWS[1:])
table_3 = self.query_one("#table-3", DataTable)
table_3.add_columns(*ROWS[0])
table_3.add_rows(ROWS[1:])
if __name__ == "__main__":
app = TabbedApp()
app.run() |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey Tom
Thanks for your help
I think i may have fixed the issue and the code you provided helped alot
You are guys are awesome
Thanks alot once again
…On 24 Feb 2024 at 7:16 AM +0530, TomJGooding ***@***.***>, wrote:
> Multiple datatable into tabbedpane , basicallly idea is to have datatable in each tab
> But i struggling with on_mount. Method where u can obviously have single on_mount method , in this case how do we get this done
Something like this?
from textual.app import App, ComposeResult
from textual.widgets import DataTable, Footer, TabbedContent, TabPane
ROWS = [
("lane", "swimmer", "country", "time"),
(4, "Joseph Schooling", "Singapore", 50.39),
(2, "Michael Phelps", "United States", 51.14),
(5, "Chad le Clos", "South Africa", 51.14),
(6, "László Cseh", "Hungary", 51.14),
(3, "Li Zhuhao", "China", 51.26),
(8, "Mehdy Metella", "France", 51.58),
(7, "Tom Shields", "United States", 51.73),
(1, "Aleksandr Sadovnikov", "Russia", 51.84),
(10, "Darren Burns", "Scotland", 51.84),
]
class TabbedApp(App):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("Table #1"):
yield DataTable(id="table-1")
with TabPane("Table #2"):
yield DataTable(id="table-2")
with TabPane("Table #3"):
yield DataTable(id="table-3")
yield Footer()
def on_mount(self) -> None:
table_1 = self.query_one("#table-1", DataTable)
table_1.add_columns(*ROWS[0])
table_1.add_rows(ROWS[1:])
table_2 = self.query_one("#table-2", DataTable)
table_2.add_columns(*ROWS[0])
table_2.add_rows(ROWS[1:])
table_3 = self.query_one("#table-3", DataTable)
table_3.add_columns(*ROWS[0])
table_3.add_rows(ROWS[1:])
if __name__ == "__main__":
app = TabbedApp()
app.run()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to create datatable into different tabbed panes in order to create a dashboard with Datatables
but cant seems to get it right
Beta Was this translation helpful? Give feedback.
All reactions