diff --git a/.gitignore b/.gitignore index eac483a..0e5ac79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .venv -**/__pycache__ \ No newline at end of file +__pycache__ \ No newline at end of file diff --git a/Tagger.py b/Tagger.py index c08322a..c093cf1 100644 --- a/Tagger.py +++ b/Tagger.py @@ -1,6 +1,11 @@ +# Imports import tkinter as tk from tkinter import ttk from src.gui.gui import main +from src.core.file_handler import list_files -main() \ No newline at end of file +# Functions +main() +a = list_files("./src/core") +print(a) \ No newline at end of file diff --git a/src/core/file_handler.py b/src/core/file_handler.py index e69de29..f3677fd 100644 --- a/src/core/file_handler.py +++ b/src/core/file_handler.py @@ -0,0 +1,22 @@ +# Module header +import sys + +if __name__ == "__main__": + sys.exit("This module is not intended to be executed as the main program.") + +# Imports +from pathlib import Path + +# Functions +def list_files(folder_path: str | Path) -> list[Path]: + """ + Vrátí seznam Path objektů všech souborů uvnitř složky (rekurzivně). + + :param folder_path: cesta ke složce (string nebo Path) + :return: list objektů Path + """ + folder = Path(folder_path) + if not folder.is_dir(): + raise NotADirectoryError(f"{folder} není platná složka.") + + return [file_path for file_path in folder.rglob("*") if file_path.is_file()] \ No newline at end of file diff --git a/src/core/image_handler.py b/src/core/image_handler.py index 132e449..d801316 100644 --- a/src/core/image_handler.py +++ b/src/core/image_handler.py @@ -1,6 +1,14 @@ +# Module header +import sys + +if __name__ == "__main__": + sys.exit("This module is not intended to be executed as the main program.") + +# Imports from PIL import Image, ImageTk -def load_icon(path): +# Functions +def load_icon(path) -> ImageTk.PhotoImage: img = Image.open(path) img = img.resize((16, 16), Image.Resampling.LANCZOS) return ImageTk.PhotoImage(img) \ No newline at end of file diff --git a/src/gui/gui.py b/src/gui/gui.py index 4fb73f0..23dce52 100644 --- a/src/gui/gui.py +++ b/src/gui/gui.py @@ -1,8 +1,16 @@ +# Module header +import sys + +if __name__ == "__main__": + sys.exit("This module is not intended to be executed as the main program.") + +# Imports import tkinter as tk from tkinter import ttk from src.core.image_handler import load_icon -def main(): +# Functions +def main() -> None: root = tk.Tk() root.title("Ukázka rozložení") root.geometry("800x600") @@ -37,7 +45,7 @@ def main(): states = {} # Funkce pro přepnutí checkboxu - def toggle(event): + def toggle(event) -> None: region = tree.identify("region", event.x, event.y) if region == "tree": item_id = tree.identify_row(event.y) @@ -99,7 +107,4 @@ def main(): tree.bind("", tree_right_click) listbox.bind("", list_right_click) - root.mainloop() - -if __name__ == "__main__": - main() \ No newline at end of file + root.mainloop() \ No newline at end of file