mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fixed some rendering glitches
This commit is contained in:
1944
examples/food.json
Normal file
1944
examples/food.json
Normal file
File diff suppressed because it is too large
Load Diff
32
examples/tree.py
Normal file
32
examples/tree.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import json
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Header, Footer, Tree
|
||||
|
||||
|
||||
with open("food.json") as data_file:
|
||||
data = json.load(data_file)
|
||||
|
||||
from rich import print
|
||||
|
||||
print(data)
|
||||
|
||||
|
||||
class TreeApp(App):
|
||||
|
||||
BINDINGS = [("a", "add", "Add node")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header()
|
||||
yield Footer()
|
||||
yield Tree("Root")
|
||||
|
||||
def action_add(self) -> None:
|
||||
tree = self.query_one(Tree)
|
||||
|
||||
tree.add_json(data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = TreeApp()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user