Bundle logo asset and load via importlib resources

This commit is contained in:
lm 2025-10-17 15:08:01 +02:00
parent 0cce0939cd
commit 5ed060570d
2 changed files with 6 additions and 2 deletions

View File

@ -358,9 +358,10 @@ class UIBuilderMixin:
logo = None logo = None
try: try:
from PIL import Image, ImageTk # type: ignore from PIL import Image, ImageTk # type: ignore
from importlib import resources
logo_path = Path(__file__).resolve().parent / "assets" / "logo.png" logo_resource = resources.files("app.assets").joinpath("logo.png")
if logo_path.exists(): with resources.as_file(logo_resource) as logo_path:
image = Image.open(logo_path).convert("RGBA") image = Image.open(logo_path).convert("RGBA")
image.thumbnail((26, 26)) image.thumbnail((26, 26))
logo = ImageTk.PhotoImage(image) logo = ImageTk.PhotoImage(image)

View File

@ -18,3 +18,6 @@ package = true
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
include = ["app"] include = ["app"]
[tool.setuptools.package-data]
"app" = ["assets/logo.png"]