Skip to content

Instantly share code, notes, and snippets.

@driscollis
Created November 11, 2024 15:37
TestNodes {
align: center middle;
}
#datatable {
height: 50%;
}
#remote_button, #tab-help-button {
background: green;
align: center middle;
}
#button-row {
align: center middle;
}
from textual.app import App, ComposeResult
from textual.containers import Center, Horizontal, Vertical
from textual.widgets import Button, DataTable, Footer
class Test(App):
CSS_PATH = "datatable_test.tcss"
def compose(self) -> ComposeResult:
"""
Create the user interface
"""
yield Vertical(
DataTable(id="datatable"),
Center(
Horizontal(
Button("Remote Desktop", variant="primary", id="remote_button"),
Button("Report Issue", variant="error", id="report_button"),
id="button-row"
)
),
id="main_tab"
)
yield Footer()
def on_mount(self) -> None:
ROWS = [("No Data Found", "", ""), ("Press CTRL+L to load CSV file", "", "")]
table = self.query_one(DataTable)
table.add_columns(*ROWS[0])
table.add_rows(ROWS[1:])
app = Test()
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment