Testing with image support
1
.gitignore
vendored
@@ -0,0 +1 @@
|
||||
.venv
|
||||
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"editor.rulers": [80]
|
||||
}
|
||||
42
GUI.py
Normal 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
@@ -0,0 +1,2 @@
|
||||
install required modules to enviroment:
|
||||
pip install -r requirements.txt
|
||||
10
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):
|
||||
|
||||
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pillow
|
||||
BIN
src/images/32/32_calendar.png
Normal file
|
After Width: | Height: | Size: 596 B |
BIN
src/images/32/32_checked.png
Normal file
|
After Width: | Height: | Size: 892 B |
BIN
src/images/32/32_computer.png
Normal file
|
After Width: | Height: | Size: 618 B |
BIN
src/images/32/32_crossed.png
Normal file
|
After Width: | Height: | Size: 961 B |
BIN
src/images/32/32_tag.png
Normal file
|
After Width: | Height: | Size: 710 B |
BIN
src/images/32/32_unchecked.png
Normal file
|
After Width: | Height: | Size: 716 B |
BIN
src/images/orig/orig_calendar.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/images/orig/orig_checked.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src/images/orig/orig_computer.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/images/orig/orig_crossed.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
src/images/orig/orig_tag.png
Normal file
|
After Width: | Height: | Size: 13 KiB |