diff --git a/.gitignore b/.gitignore index e69de29..b694934 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3905ae4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.rulers": [80] +} \ No newline at end of file diff --git a/GUI.py b/GUI.py new file mode 100644 index 0000000..30773c0 --- /dev/null +++ b/GUI.py @@ -0,0 +1,42 @@ +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/README.md b/README.md new file mode 100644 index 0000000..bf6aff1 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +install required modules to enviroment: + pip install -r requirements.txt \ No newline at end of file diff --git a/Tagger.py b/Tagger.py index 3914aa8..ad8a442 100644 --- a/Tagger.py +++ b/Tagger.py @@ -45,10 +45,16 @@ def main(): # ==== 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")) + 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")) + list_menu.add_command( + label="Akce na seznamu", + command=lambda: status_bar.config(text="Klikl jsi na seznam") + ) # ==== HANDLERY ==== def tree_right_click(event): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..037103e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pillow \ No newline at end of file diff --git a/src/images/32/32_calendar.png b/src/images/32/32_calendar.png new file mode 100644 index 0000000..71da133 Binary files /dev/null and b/src/images/32/32_calendar.png differ diff --git a/src/images/32/32_checked.png b/src/images/32/32_checked.png new file mode 100644 index 0000000..0b91010 Binary files /dev/null and b/src/images/32/32_checked.png differ diff --git a/src/images/32/32_computer.png b/src/images/32/32_computer.png new file mode 100644 index 0000000..58f77fe Binary files /dev/null and b/src/images/32/32_computer.png differ diff --git a/src/images/32/32_crossed.png b/src/images/32/32_crossed.png new file mode 100644 index 0000000..e34c323 Binary files /dev/null and b/src/images/32/32_crossed.png differ diff --git a/src/images/32/32_tag.png b/src/images/32/32_tag.png new file mode 100644 index 0000000..0d350f3 Binary files /dev/null and b/src/images/32/32_tag.png differ diff --git a/src/images/32/32_unchecked.png b/src/images/32/32_unchecked.png new file mode 100644 index 0000000..c503b47 Binary files /dev/null and b/src/images/32/32_unchecked.png differ diff --git a/src/images/orig/orig_calendar.png b/src/images/orig/orig_calendar.png new file mode 100644 index 0000000..eb3b953 Binary files /dev/null and b/src/images/orig/orig_calendar.png differ diff --git a/src/images/orig/orig_checked.png b/src/images/orig/orig_checked.png new file mode 100644 index 0000000..54a504d Binary files /dev/null and b/src/images/orig/orig_checked.png differ diff --git a/src/images/orig/orig_computer.png b/src/images/orig/orig_computer.png new file mode 100644 index 0000000..ac006a9 Binary files /dev/null and b/src/images/orig/orig_computer.png differ diff --git a/src/images/orig/orig_crossed.png b/src/images/orig/orig_crossed.png new file mode 100644 index 0000000..8cbd67b Binary files /dev/null and b/src/images/orig/orig_crossed.png differ diff --git a/src/images/orig/orig_tag.png b/src/images/orig/orig_tag.png new file mode 100644 index 0000000..f8de5fe Binary files /dev/null and b/src/images/orig/orig_tag.png differ