Testing with image support

This commit is contained in:
2025-09-08 10:14:22 +02:00
parent 7928434cc0
commit 31e2b994d1
17 changed files with 57 additions and 2 deletions

1
.gitignore vendored
View File

@@ -0,0 +1 @@
.venv

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"editor.rulers": [80]
}

42
GUI.py Normal file
View File

@@ -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("<Button-1>", toggle)
root.mainloop()
if __name__ == "__main__":
main()

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
install required modules to enviroment:
pip install -r requirements.txt

View File

@@ -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):

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
pillow

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

BIN
src/images/32/32_tag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB