* Improving data table documentation * More info on DataTable * Add note on retrieving cursor coordinate * Add note on DataTable supporting more than just strings * Add note on cell styling and justifying - common question * Slight rewording * Explaining what "row labels" are. * Update docs/widgets/data_table.md Co-authored-by: Will McGugan <willmcgugan@gmail.com> * Update docs/widgets/data_table.md Co-authored-by: Will McGugan <willmcgugan@gmail.com> * Update docs/widgets/data_table.md Co-authored-by: Will McGugan <willmcgugan@gmail.com> * Update docs/widgets/data_table.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update docs/widgets/data_table.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update docs/widgets/data_table.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update docs/widgets/data_table.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Update docs/widgets/data_table.md Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com> * Improve data table fixed rows/columns docs * Update some examples --------- Co-authored-by: Will McGugan <willmcgugan@gmail.com> Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
25 lines
645 B
Python
25 lines
645 B
Python
from textual.app import App, ComposeResult
|
|
from textual.widgets import DataTable
|
|
|
|
|
|
class TableApp(App):
|
|
CSS = "DataTable {height: 1fr}"
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield DataTable()
|
|
|
|
def on_mount(self) -> None:
|
|
table = self.query_one(DataTable)
|
|
table.focus()
|
|
table.add_columns("A", "B", "C")
|
|
for number in range(1, 100):
|
|
table.add_row(str(number), str(number * 2), str(number * 3))
|
|
table.fixed_rows = 2
|
|
table.fixed_columns = 1
|
|
table.cursor_type = "row"
|
|
table.zebra_stripes = True
|
|
|
|
|
|
app = TableApp()
|
|
if __name__ == "__main__":
|
|
app.run()
|