File: data_table_add_row_auto_height.py

package info (click to toggle)
textual-fastdatatable 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,176 kB
  • sloc: python: 3,466; makefile: 29
file content (25 lines) | stat: -rw-r--r-- 770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from rich.panel import Panel
from rich.text import Text
from textual.app import App

from textual_fastdatatable import DataTable


class AutoHeightRowsApp(App[None]):
    def compose(self):
        table = DataTable()
        self.column = table.add_column("N")
        table.add_column("Column", width=10)
        table.add_row(3, "hey there", height=None)
        table.add_row(1, Text("hey there"), height=None)
        table.add_row(5, Text("long string", overflow="fold"), height=None)
        table.add_row(2, Panel.fit("Hello\nworld"), height=None)
        table.add_row(4, "1\n2\n3\n4\n5\n6\n7", height=None)
        yield table

    def key_s(self):
        self.query_one(DataTable).sort(self.column)


if __name__ == "__main__":
    AutoHeightRowsApp().run()