mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-23 14:51:50 +03:00
Fix API breakage from changes in textual 0.23.0
This commit is contained in:
parent
6a3ab712a5
commit
55419d671e
@ -23,8 +23,7 @@ class EnhancedDirectoryTree(DirectoryTree):
|
||||
node = self.root
|
||||
def get_node_name(node: TreeNode[DirEntry]) -> str:
|
||||
assert node.data
|
||||
return os.path.basename(node.data.path.rstrip(os.path.sep))
|
||||
# return os.path.basename(node.data.path.rstrip("/\\"))
|
||||
return os.path.basename(node.data.path)
|
||||
for path_segment in target_path.split(os.path.sep):
|
||||
# Find the child node with the right name.
|
||||
for child in node.children:
|
||||
@ -32,11 +31,11 @@ class EnhancedDirectoryTree(DirectoryTree):
|
||||
node = child
|
||||
break
|
||||
if get_node_name(node) == path_segment:
|
||||
assert node.data
|
||||
if node.data.is_dir:
|
||||
assert isinstance(node.data, DirEntry)
|
||||
if node.data.path.is_dir():
|
||||
if not node.is_expanded and not node.data.loaded:
|
||||
# load_directory also calls node.expand()
|
||||
self.load_directory(node)
|
||||
self._load_directory(node)
|
||||
else:
|
||||
# Found a file.
|
||||
break
|
||||
|
@ -85,11 +85,11 @@ class FileDialogWindow(DialogWindow):
|
||||
DirectoryTree gives FileSelected, but only for files, not folders.
|
||||
"""
|
||||
assert event.node.data
|
||||
if event.node.data.is_dir:
|
||||
self._directory_tree_selected_path = event.node.data.path
|
||||
if event.node.data.path.is_dir():
|
||||
self._directory_tree_selected_path = str(event.node.data.path)
|
||||
elif event.node.parent:
|
||||
assert event.node.parent.data
|
||||
self._directory_tree_selected_path = event.node.parent.data.path
|
||||
self._directory_tree_selected_path = str(event.node.parent.data.path)
|
||||
name = os.path.basename(event.node.data.path)
|
||||
if not self._expanding_directory_tree:
|
||||
self.query_one("FileDialogWindow .filename_input", Input).value = name
|
||||
|
Loading…
Reference in New Issue
Block a user