diff --git a/GUI.py b/GUI.py deleted file mode 100644 index 30773c0..0000000 --- a/GUI.py +++ /dev/null @@ -1,42 +0,0 @@ -import tkinter as tk -from tkinter import ttk -from PIL import Image, ImageTk # Pillow je nutné mít nainstalované - -def main(): - root = tk.Tk() - root.title("Treeview s checkboxy") - - tree = ttk.Treeview(root) - tree.pack(fill="both", expand=True) - - # Funkce pro načtení a zmenšení obrázku na 16x16 - def load_icon(path): - img = Image.open(path) - img = img.resize((16, 16), Image.Resampling.LANCZOS) - return ImageTk.PhotoImage(img) - - unchecked = load_icon("/home/honza/Documents/Tagger/src/images/32/32_unchecked.png") - checked = load_icon("/home/honza/Documents/Tagger/src/images/32/32_checked.png") - - # Slovník pro ukládání stavů - states = {} - - # Přidání uzlu se stavem - item = tree.insert("", "end", text="Položka 1", image=unchecked) - states[item] = False - - # Funkce pro přepnutí checkboxu - def toggle(event): - region = tree.identify("region", event.x, event.y) - if region == "tree": - item_id = tree.identify_row(event.y) - if item_id: - states[item_id] = not states[item_id] - tree.item(item_id, image=checked if states[item_id] else unchecked) - - tree.bind("", toggle) - - root.mainloop() - -if __name__ == "__main__": - main() diff --git a/Tagger.py b/Tagger.py index ad8a442..c08322a 100644 --- a/Tagger.py +++ b/Tagger.py @@ -1,79 +1,6 @@ import tkinter as tk from tkinter import ttk -def main(): - root = tk.Tk() - root.title("Ukázka rozložení") - root.geometry("800x600") +from src.gui.gui import main - # ==== MENU ==== - menu_bar = tk.Menu(root) - root.config(menu=menu_bar) - - file_menu = tk.Menu(menu_bar, tearoff=0) - file_menu.add_command(label="Otevřít") - file_menu.add_command(label="Ukončit", command=root.quit) - menu_bar.add_cascade(label="Soubor", menu=file_menu) - - # ==== HLAVNÍ RÁM ==== - main_frame = tk.Frame(root) - main_frame.pack(fill="both", expand=True) - - main_frame.columnconfigure(0, weight=1) - main_frame.columnconfigure(1, weight=2) - main_frame.rowconfigure(0, weight=1) - - # ==== VLEVO: STROM ==== - tree = ttk.Treeview(main_frame) - tree.grid(row=0, column=0, sticky="nsew", padx=2, pady=2) - - root_node = tree.insert("", "end", text="Root") - tree.insert(root_node, "end", text="Child 1") - tree.insert(root_node, "end", text="Child 2") - tree.item(root_node, open=True) - - # ==== VPRAVO: SEZNAM ==== - listbox = tk.Listbox(main_frame) - listbox.grid(row=0, column=1, sticky="nsew", padx=2, pady=2) - - for i in range(1, 21): - listbox.insert("end", f"Položka {i}") - - # ==== STAVOVÝ ŘÁDEK ==== - status_bar = tk.Label(root, text="Připraven", anchor="w", relief="sunken") - status_bar.pack(side="bottom", fill="x") - - # ==== KONTEXTOVÁ MENU ==== - tree_menu = tk.Menu(root, tearoff=0) - tree_menu.add_command( - label="Akce na stromu", - command=lambda: status_bar.config(text="Klikl jsi na strom") - ) - - list_menu = tk.Menu(root, tearoff=0) - list_menu.add_command( - label="Akce na seznamu", - command=lambda: status_bar.config(text="Klikl jsi na seznam") - ) - - # ==== HANDLERY ==== - def tree_right_click(event): - item_id = tree.identify_row(event.y) - if item_id: # klik na uzel - tree.selection_set(item_id) - tree_menu.tk_popup(event.x_root, event.y_root) - - def list_right_click(event): - index = listbox.nearest(event.y) - if index >= 0: # klik na položku - listbox.selection_clear(0, "end") - listbox.selection_set(index) - list_menu.tk_popup(event.x_root, event.y_root) - - tree.bind("", tree_right_click) - listbox.bind("", list_right_click) - - root.mainloop() - -if __name__ == "__main__": - main() +main() \ No newline at end of file diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/__pycache__/__init__.cpython-313.pyc b/src/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..602124c Binary files /dev/null and b/src/__pycache__/__init__.cpython-313.pyc differ diff --git a/src/core/SQL_handler.py b/src/core/SQL_handler.py new file mode 100644 index 0000000..e69de29 diff --git a/src/core/__init__.py b/src/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/core/__pycache__/__init__.cpython-313.pyc b/src/core/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..498b71a Binary files /dev/null and b/src/core/__pycache__/__init__.cpython-313.pyc differ diff --git a/src/core/__pycache__/image_handler.cpython-313.pyc b/src/core/__pycache__/image_handler.cpython-313.pyc new file mode 100644 index 0000000..86512c0 Binary files /dev/null and b/src/core/__pycache__/image_handler.cpython-313.pyc differ diff --git a/src/core/file_handler.py b/src/core/file_handler.py new file mode 100644 index 0000000..e69de29 diff --git a/src/core/image_handler.py b/src/core/image_handler.py new file mode 100644 index 0000000..132e449 --- /dev/null +++ b/src/core/image_handler.py @@ -0,0 +1,6 @@ +from PIL import Image, ImageTk + +def load_icon(path): + 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/__init__.py b/src/gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/gui/__pycache__/__init__.cpython-313.pyc b/src/gui/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000..102ea21 Binary files /dev/null and b/src/gui/__pycache__/__init__.cpython-313.pyc differ diff --git a/src/gui/__pycache__/gui.cpython-313.pyc b/src/gui/__pycache__/gui.cpython-313.pyc new file mode 100644 index 0000000..f44afee Binary files /dev/null and b/src/gui/__pycache__/gui.cpython-313.pyc differ diff --git a/src/gui/gui.py b/src/gui/gui.py new file mode 100644 index 0000000..4fb73f0 --- /dev/null +++ b/src/gui/gui.py @@ -0,0 +1,105 @@ +import tkinter as tk +from tkinter import ttk +from src.core.image_handler import load_icon + +def main(): + root = tk.Tk() + root.title("Ukázka rozložení") + root.geometry("800x600") + + # ==== MENU ==== + menu_bar = tk.Menu(root) + root.config(menu=menu_bar) + + file_menu = tk.Menu(menu_bar, tearoff=0) + file_menu.add_command(label="Otevřít") + file_menu.add_command(label="Ukončit", command=root.quit) + menu_bar.add_cascade(label="Soubor", menu=file_menu) + + # ==== HLAVNÍ RÁM ==== + main_frame = tk.Frame(root) + main_frame.pack(fill="both", expand=True) + + main_frame.columnconfigure(0, weight=1) + main_frame.columnconfigure(1, weight=2) + main_frame.rowconfigure(0, weight=1) + + # ==== Ikony ==== + unchecked = load_icon("src/resources/images/32/32_unchecked.png") + checked = load_icon("src/resources/images/32/32_checked.png") + icons = {"unchecked": unchecked, "checked": checked} + + # ==== VLEVO: STROM ==== + tree = ttk.Treeview(main_frame) + tree.grid(row=0, column=0, sticky="nsew", padx=2, pady=2) + + # Slovník pro stavy checkboxů + states = {} + + # Funkce pro přepnutí checkboxu + def toggle(event): + region = tree.identify("region", event.x, event.y) + if region == "tree": + item_id = tree.identify_row(event.y) + if item_id: + states[item_id] = not states[item_id] + tree.item(item_id, image=icons["checked"] if states[item_id] else icons["unchecked"]) + + tree.bind("", toggle) + + # Přidání uzlů se stavem + root_node = tree.insert("", "end", text="Root", image=icons["unchecked"]) + states[root_node] = False + + child1 = tree.insert(root_node, "end", text="Child 1", image=icons["unchecked"]) + states[child1] = False + child2 = tree.insert(root_node, "end", text="Child 2", image=icons["unchecked"]) + states[child2] = False + + tree.item(root_node, open=True) + + # ==== VPRAVO: SEZNAM ==== + listbox = tk.Listbox(main_frame) + listbox.grid(row=0, column=1, sticky="nsew", padx=2, pady=2) + + for i in range(1, 21): + listbox.insert("end", f"Položka {i}") + + # ==== STAVOVÝ ŘÁDEK ==== + status_bar = tk.Label(root, text="Připraven", anchor="w", relief="sunken") + status_bar.pack(side="bottom", fill="x") + + # ==== KONTEXTOVÁ MENU ==== + tree_menu = tk.Menu(root, tearoff=0) + tree_menu.add_command( + label="Akce na stromu", + command=lambda: status_bar.config(text="Klikl jsi na strom") + ) + + list_menu = tk.Menu(root, tearoff=0) + list_menu.add_command( + label="Akce na seznamu", + command=lambda: status_bar.config(text="Klikl jsi na seznam") + ) + + # ==== HANDLERY ==== + def tree_right_click(event): + item_id = tree.identify_row(event.y) + if item_id: # klik na uzel + tree.selection_set(item_id) + tree_menu.tk_popup(event.x_root, event.y_root) + + def list_right_click(event): + index = listbox.nearest(event.y) + if index >= 0: # klik na položku + listbox.selection_clear(0, "end") + listbox.selection_set(index) + list_menu.tk_popup(event.x_root, event.y_root) + + tree.bind("", tree_right_click) + listbox.bind("", list_right_click) + + root.mainloop() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/images/32/32_calendar.png b/src/resources/images/32/32_calendar.png similarity index 100% rename from src/images/32/32_calendar.png rename to src/resources/images/32/32_calendar.png diff --git a/src/images/32/32_checked.png b/src/resources/images/32/32_checked.png similarity index 100% rename from src/images/32/32_checked.png rename to src/resources/images/32/32_checked.png diff --git a/src/images/32/32_computer.png b/src/resources/images/32/32_computer.png similarity index 100% rename from src/images/32/32_computer.png rename to src/resources/images/32/32_computer.png diff --git a/src/images/32/32_crossed.png b/src/resources/images/32/32_crossed.png similarity index 100% rename from src/images/32/32_crossed.png rename to src/resources/images/32/32_crossed.png diff --git a/src/images/32/32_tag.png b/src/resources/images/32/32_tag.png similarity index 100% rename from src/images/32/32_tag.png rename to src/resources/images/32/32_tag.png diff --git a/src/images/32/32_unchecked.png b/src/resources/images/32/32_unchecked.png similarity index 100% rename from src/images/32/32_unchecked.png rename to src/resources/images/32/32_unchecked.png diff --git a/src/images/orig/orig_calendar.png b/src/resources/images/orig/orig_calendar.png similarity index 100% rename from src/images/orig/orig_calendar.png rename to src/resources/images/orig/orig_calendar.png diff --git a/src/images/orig/orig_checked.png b/src/resources/images/orig/orig_checked.png similarity index 100% rename from src/images/orig/orig_checked.png rename to src/resources/images/orig/orig_checked.png diff --git a/src/images/orig/orig_computer.png b/src/resources/images/orig/orig_computer.png similarity index 100% rename from src/images/orig/orig_computer.png rename to src/resources/images/orig/orig_computer.png diff --git a/src/images/orig/orig_crossed.png b/src/resources/images/orig/orig_crossed.png similarity index 100% rename from src/images/orig/orig_crossed.png rename to src/resources/images/orig/orig_crossed.png diff --git a/src/images/orig/orig_tag.png b/src/resources/images/orig/orig_tag.png similarity index 100% rename from src/images/orig/orig_tag.png rename to src/resources/images/orig/orig_tag.png