Corregge icona Esci HighDPI con CTkImage (main 1.0.4)
This commit is contained in:
20
main.py
20
main.py
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user