This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |