GUI rework to Qt6
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user