Replies: 2 comments
-
It's not really clear exactly what you're asking here, but here's a quick example:which might help clarify what you're looking for: from pathlib import Path
from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Button, DirectoryTree
class DirectoryTreeApp(App):
def compose(self) -> ComposeResult:
yield Button("Navigate to parent directory")
yield DirectoryTree("./")
@on(Button.Pressed)
def update_directory_tree(self) -> None:
tree = self.query_one(DirectoryTree)
assert isinstance(tree.path, Path)
tree.path = tree.path.parent.resolve()
tree.reload()
if __name__ == "__main__":
app = DirectoryTreeApp()
app.run() |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for the solution. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The
DirectoryTree
widget seems to not have a method for moving to the parent directory (only child items under current directory). What should I do?Beta Was this translation helpful? Give feedback.
All reactions