We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
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
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
from textual.app import App, ComposeResult from textual.widgets import Footer, Label, Markdown, TabbedContent, TabPane,DataTable
from textual.binding import Binding
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), ]
NEWROWS =[ ("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): """An example of tabbed content."""
BINDINGS = [ ("l", "show_tab('exp_imp_Stats')", "exp_imp_Stats"), ("j", "show_tab('Online_Stats')", "OnlineStats"), ("p", "show_tab('Offline_Stats')", "OfflineStats"), ("e", "show_tab('Overall_Stats')", "OverallStats"), ("r","show_tab('rows')", "Rows"), Binding(key="q", action="quit", description="Quit the app"), Binding( key="question_mark", action="help", description="Show help screen", key_display="?", ), Binding(key="s", action="down", description="Scroll down", show=False), ] def compose(self) -> ComposeResult: """Compose app with tabbed content.""" yield Footer() # Add the TabbedContent widget with TabbedContent(initial="exp_imp_Stats"): with TabPane("Online Stats", id="ONLINESTAT"): # First tab ##TODO: yield Label("This is the online stats tab.") with TabPane("Offline Stats", id="OfflineStats"): yield Markdown("# Offline Stats") yield Label("This is the offline stats tab.") with TabPane("Export/Import Stats", id="exp_imp_Stats"): yield Markdown("# Export/ Import Stats") with TabPane("Overall_Stats", id="Overall_Stats"): yield Markdown("# Overall Stats") with TabPane("Rows", id="rows"): yield DataTable() def action_show_tab(self, tab: str) -> None: """Switch to a new tab.""" self.get_child_by_type(TabbedContent).active = tab def on_mount(self) -> None: table = self.query_one(DataTable) table.add_columns(*ROWS[0]) table.add_rows(ROWS[1:])
def tabbed_main(): app = TabbedApp() app.run()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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
from textual.app import App, ComposeResult
from textual.widgets import Footer, Label, Markdown, TabbedContent, TabPane,DataTable
from textual.binding import Binding
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),
]
NEWROWS =[
("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):
"""An example of tabbed content."""
def tabbed_main():
app = TabbedApp()
app.run()
The text was updated successfully, but these errors were encountered: