Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
✨ Add testing code for tree lines
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed May 3, 2023
1 parent 7f09ecc commit 850ff14
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tree_lines_tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""https://github.com/Textualize/textual/issues/2397"""

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Header, Footer, Tree
from textual.widgets.tree import TreeNode

class TreeLinesTestApp( App[ None ] ):

CSS = """
Tree {
border: round red;
}
Tree:focus {
border: double green;
}
"""

def compose( self ) -> ComposeResult:
yield Header()
with Horizontal():
yield Tree("Root", id="root")
yield Tree("Root", id="no-root")
yield Footer()

def populate( self, node: TreeNode, limit: int=3 ) -> Tree:
for n in range( limit ):
self.populate( node.add( str( n ) ), limit-1 )
return node.tree

def on_mount( self ) -> None:
self.query_one( "#no-root", Tree ).show_root = False
self.populate( self.query_one( "#root", Tree ).root ).root.expand_all()
self.populate( self.query_one( "#no-root", Tree ).root ).root.expand_all()

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

0 comments on commit 850ff14

Please sign in to comment.