From f862d9fecc1599bb0edbf4039abdbaa16fc7a983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Doubravsk=C3=BD?= Date: Mon, 8 Sep 2025 13:22:10 +0200 Subject: [PATCH] File structure organised --- GUI.py | 42 ------- Tagger.py | 77 +------------ src/__init__.py | 0 src/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 152 bytes src/core/SQL_handler.py | 0 src/core/__init__.py | 0 src/core/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 157 bytes .../__pycache__/image_handler.cpython-313.pyc | Bin 0 -> 622 bytes src/core/file_handler.py | 0 src/core/image_handler.py | 6 + src/gui/__init__.py | 0 src/gui/__pycache__/__init__.cpython-313.pyc | Bin 0 -> 156 bytes src/gui/__pycache__/gui.cpython-313.pyc | Bin 0 -> 5319 bytes src/gui/gui.py | 105 ++++++++++++++++++ src/{ => resources}/images/32/32_calendar.png | Bin src/{ => resources}/images/32/32_checked.png | Bin src/{ => resources}/images/32/32_computer.png | Bin src/{ => resources}/images/32/32_crossed.png | Bin src/{ => resources}/images/32/32_tag.png | Bin .../images/32/32_unchecked.png | Bin .../images/orig/orig_calendar.png | Bin .../images/orig/orig_checked.png | Bin .../images/orig/orig_computer.png | Bin .../images/orig/orig_crossed.png | Bin src/{ => resources}/images/orig/orig_tag.png | Bin 25 files changed, 113 insertions(+), 117 deletions(-) delete mode 100644 GUI.py create mode 100644 src/__init__.py create mode 100644 src/__pycache__/__init__.cpython-313.pyc create mode 100644 src/core/SQL_handler.py create mode 100644 src/core/__init__.py create mode 100644 src/core/__pycache__/__init__.cpython-313.pyc create mode 100644 src/core/__pycache__/image_handler.cpython-313.pyc create mode 100644 src/core/file_handler.py create mode 100644 src/core/image_handler.py create mode 100644 src/gui/__init__.py create mode 100644 src/gui/__pycache__/__init__.cpython-313.pyc create mode 100644 src/gui/__pycache__/gui.cpython-313.pyc create mode 100644 src/gui/gui.py rename src/{ => resources}/images/32/32_calendar.png (100%) rename src/{ => resources}/images/32/32_checked.png (100%) rename src/{ => resources}/images/32/32_computer.png (100%) rename src/{ => resources}/images/32/32_crossed.png (100%) rename src/{ => resources}/images/32/32_tag.png (100%) rename src/{ => resources}/images/32/32_unchecked.png (100%) rename src/{ => resources}/images/orig/orig_calendar.png (100%) rename src/{ => resources}/images/orig/orig_checked.png (100%) rename src/{ => resources}/images/orig/orig_computer.png (100%) rename src/{ => resources}/images/orig/orig_crossed.png (100%) rename src/{ => resources}/images/orig/orig_tag.png (100%) 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 0000000000000000000000000000000000000000..602124cab9676a3d74d1cc930232b040d416fec3 GIT binary patch literal 152 zcmey&%ge<81RT5fWq|0%AOZ#$p^VQgK*m&tbOudEzm*I{OhDdekkl>nWUH9a;?$zz znCv2R3rpje@cg3e;)2BF)R?ef=lqn^n2^Nu^wgr5;-ci3`1s7c%#!$cy@JYH95%W6 bDWy57c15f}b3pbKgBTx~85tRin1L(+?y@9S literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..498b71af6887c613026ceb2607f74fdf9935009b GIT binary patch literal 157 zcmey&%ge<81Sz}rWq|0%AOZ#$p^VQgK*m&tbOudEzm*I{OhDdekkl=kWUH9a;?$zz znCv2R3rpje@cg3e;)2BF)R?ef=lqn^n2^Nu^wgr5;-ci3kBzyxJ{mI5-SG6XXOGkP<4F%~g;F%>Z>Fa$G6F%&VU zGi$QE1S!;Hy2a|5o0y(@iycgbWG6F14FFLrK+FuppVtA2sSMFT5(0u?*1!aSv=T!o zgDF&Z9%CqD5G#@-lo`y3WCk0id=Lkwm?_k*JjQ6Sw?Qg`creug?PrA9uLAU$pC;2w z0id!XkUg60MIevdV#zN^&AY``lvunj92iooH)2UK#4!zMRB ir8Fniu1FZj1w~siFOc}a%*e=ipF!?33p1lKSUCWGJ$nxT literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..102ea21d264b48577a6e647945c81614dc624d0c GIT binary patch literal 156 zcmey&%ge<81ZlhWWq|0%AOZ#$p^VQgK*m&tbOudEzm*I{OhDdekkl>fWUH9a;?$zz znCv2R3rpje@cg3e;)2BF)R?ef=lqn^n2^Nu^wgr5;-ci3^wP|j`1s7c%#!$cy@JYH f95%W6DWy57c15f}vp{wggBTx~85tRin1L(++PEfI literal 0 HcmV?d00001 diff --git a/src/gui/__pycache__/gui.cpython-313.pyc b/src/gui/__pycache__/gui.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f44afeeb55918d3d80b2aace9e9043b66d2a695c GIT binary patch literal 5319 zcmbstT})fo`CR+@+Q$FpHx3~tgn%1DASrF287d8s5(sp@b`l8->tbJwWBXou?sfTD zH<^bjG}RWTQx*4VM4D9cP&IvOv`t;KuJ3kX!@EnXO6yDB=u&lin)aP*Y=djqw4Eg1 zJ?DHs=bZ1~d1kTHAQ-oP`|148EC~ILEQ&+3J9#z=llKsdSZW+$3ci|gbVY+TZnCEx z*IuD94RhLsur9!`x`7)AaR!6}x)Z2xSBM)$s0ig@o|5&Xhf=h%9D|QBE^^^uG$ab4 zT}t%>+(--mp8Z;f(2QlqI%Au$&p2kBGqvxb=@O;4c*oKXLgh0Bi?sq<~WgA`Sra@qUv#m&9{<2Merf=6% z-3Vyf%edlpNgwoyV^Sp5yy?3@VS|Kk&Hs@fcMe z<1P>RR17%B!nRg;NoNHSEca>A=Cd83McZC2PMawFx1i24qyzm5Xij z*I3bcO_AP>uDTF1p?!YbRg_%*5yd~} z)cR_xM(k<7<9UkhBHmGm!##0!xJ0YZT2QPtb z1N^b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%xY5a=gy< zEz;_k?`jSqJ^sW#QYQW0OzU3y-mKHTv|}x)H{0B`MV~1?s5yK5>=xZa-VfgS)|8q@ z6hknm23U|}Q#lqDWFF(!NL;Al-2iQGcSyv1x7vya=i!G}94OQTKmvjYfF_3z1|J|* zVzG}(h~Z?MAH*1lNP{JL0PJWfiux<6`w}&NiMswya}-s#Gpa?jd2MA=d*m;);jPgf JSh`eE{|0=CWDNiS literal 0 HcmV?d00001 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