126 self.load_tree(self.fsobjects[child_iid], parent=child_iid)
127
128 def item_opened(self, _event: tk.Event) -> None:
129 """130 Handler invoked when a folder item is expanded.
131 """
132 # Get the expanded item.
104 return iid
105
106 def load_tree(self, path: Path, parent: str = "") -> None:
107 """108 Load the contents of `path` into the treeview.
109 """
110 for fsobj in self.safe_iterdir(path):
94 return self.folder_image if path.is_dir() else self.file_image
95
96 def insert_item(self, name: str, path: Path, parent: str = "") -> str:
97 """ 98 Insert a file or folder into the treeview and return the item ID.
99 """
100 iid = self.treeview.insert(
77 self.load_tree(Path(Path(sys.executable).anchor))
78
79 def safe_iterdir(self, path: Path) -> tuple[Path, ...] | tuple[()]:
80 """ 81 Like `Path.iterdir()`, but do not raise on permission errors.
82 """
83 try:
If a docstring fits in a single line (72 characters according to PEP8), it is recommended to have the quotes on the same line.
def foo():
"""
Runs bar and returns baz.
"""
baz = bar()
return baz
def foo():
"""Runs bar and returns baz."""
baz = bar()
return baz