GUI rework to Qt6

This commit is contained in:
2026-01-24 07:50:19 +01:00
parent 47b39aadfe
commit 2bcd5b1f4b
16 changed files with 1613 additions and 1870 deletions

View File

@@ -1,19 +1,22 @@
"""
UI utility functions for Tagger GUI.
UI utility functions for Tagger GUI (PySide6).
"""
from PIL import Image, ImageTk
from pathlib import Path
from PySide6.QtGui import QIcon, QPixmap
def load_icon(path) -> ImageTk.PhotoImage:
def load_icon(path: str | Path, size: int = 16) -> QIcon:
"""
Load an icon from file and resize to 16x16.
Load an icon from file and optionally resize.
Args:
path: Path to the image file
size: Icon size in pixels (default 16)
Returns:
ImageTk.PhotoImage resized to 16x16 pixels
QIcon object
"""
img = Image.open(path)
img = img.resize((16, 16), Image.Resampling.LANCZOS)
return ImageTk.PhotoImage(img)
pixmap = QPixmap(str(path))
if not pixmap.isNull():
pixmap = pixmap.scaled(size, size)
return QIcon(pixmap)