Makes it use the glados_head image as app icon
This commit is contained in:
@@ -95,11 +95,44 @@ def list_ollama_models() -> List[str]:
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
# --- App icon helpers (Tk + macOS Dock) ---
|
||||
def _set_app_icon(root: tk.Tk, png_path: pathlib.Path):
|
||||
"""
|
||||
Sets the window icon (cross-platform) and, on macOS, the Dock icon.
|
||||
Falls back gracefully if assets or modules are missing.
|
||||
"""
|
||||
# 1) Tk window/taskbar icon
|
||||
try:
|
||||
if png_path.exists():
|
||||
try:
|
||||
if PIL_OK:
|
||||
_img = Image.open(str(png_path))
|
||||
root._app_icon = ImageTk.PhotoImage(_img) # keep ref!
|
||||
else:
|
||||
root._app_icon = tk.PhotoImage(file=str(png_path)) # keep ref!
|
||||
root.iconphoto(True, root._app_icon)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2) macOS Dock icon via PyObjC (optional)
|
||||
if sys.platform == "darwin":
|
||||
try:
|
||||
from Cocoa import NSImage, NSApplication # type: ignore
|
||||
app = NSApplication.sharedApplication()
|
||||
nsimg = NSImage.alloc().initWithContentsOfFile_(str(png_path))
|
||||
if nsimg is not None:
|
||||
app.setApplicationIconImage_(nsimg)
|
||||
except Exception:
|
||||
# PyObjC not available or other issue; ignore silently
|
||||
pass
|
||||
|
||||
class GladosGUI(tk.Tk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.title("GLaDOSify")
|
||||
_set_app_icon(self, HEAD_IMAGE_PATH)
|
||||
self.configure(bg=BG)
|
||||
# Global font/color defaults (use named font to handle space in family name)
|
||||
self._ui_font = tkfont.Font(family="Lucida Console", size=12)
|
||||
|
||||
Reference in New Issue
Block a user