Corregge icona Esci HighDPI con CTkImage (main 1.0.4)

This commit is contained in:
2026-10-21 11:37:40 +02:00
parent 04406e840d
commit d3941e88cc
4 changed files with 23 additions and 12 deletions

20
main.py
View File

@@ -16,6 +16,7 @@ from runtime_support import ensure_stdio, run_with_fatal_log
ensure_stdio("warehouse_main")
import customtkinter as ctk
from PIL import Image, ImageDraw
from tkinter import messagebox
from async_loop_singleton import get_global_loop, stop_global_loop
@@ -357,17 +358,18 @@ class Launcher(ctk.CTk):
except Exception:
pass
def _make_exit_icon(self, *, color: str) -> tk.PhotoImage:
"""Create a small red X icon without adding image assets to the project."""
def _make_exit_icon(self, *, color: str) -> ctk.CTkImage:
"""Create a transparent X with extra resolution for HighDPI scaling."""
size = 14
image = tk.PhotoImage(width=size, height=size)
for offset in range(3, 11):
image.put(color, (offset, offset))
image.put(color, (offset + 1, offset))
image.put(color, (offset, size - 1 - offset))
image.put(color, (offset + 1, size - 1 - offset))
return image
scale = 3
image = Image.new("RGBA", (size * scale, size * scale), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
draw.line((3 * scale, 3 * scale, 10 * scale, 10 * scale),
fill=color, width=2 * scale)
draw.line((3 * scale, 10 * scale, 10 * scale, 3 * scale),
fill=color, width=2 * scale)
return ctk.CTkImage(light_image=image, dark_image=image, size=(size, size))
def _apply_dynamic_geometry(self) -> None:
"""Size the launcher around its current content and keep it docked at the top."""