DirectoryTree¶
A tree control to navigate the contents of your filesystem.
- Focusable
- Container
Example¶
The example below creates a simple tree to navigate the current working directory.
from textual.app import App, ComposeResult
from textual.widgets import DirectoryTree
class DirectoryTreeApp(App):
def compose(self) -> ComposeResult:
yield DirectoryTree("./")
if __name__ == "__main__":
app = DirectoryTreeApp()
app.run()
Messages¶
FileSelected
¶
Reactive Attributes¶
Name | Type | Default | Description |
---|---|---|---|
show_root |
bool |
True |
Show the root node. |
show_guides |
bool |
True |
Show guide lines between levels. |
guide_depth |
int |
4 |
Amount of indentation between parent and child. |
Component Classes¶
The directory tree widget provides the following component classes:
Class | Description |
---|---|
directory-tree--extension |
Target the extension of a file name. |
directory-tree--file |
Target files in the directory structure. |
directory-tree--folder |
Target folders in the directory structure. |
directory-tree--hidden |
Target hidden items in the directory structure. |
See also the component classes for Tree
.
See Also¶
- DirectoryTree code reference
- Tree code reference