From 82e1764c2e66779bca6bb155d949be6945d2b2c3 Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:05:13 +0200 Subject: [PATCH] Fix windows taskbar player icon --- .gitignore | 2 +- cbz/player.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 67c18da..8f51cff 100644 --- a/.gitignore +++ b/.gitignore @@ -171,4 +171,4 @@ poetry.toml pyrightconfig.json ### CBZ ### -.cbz \ No newline at end of file +*.cbz \ No newline at end of file diff --git a/cbz/player.py b/cbz/player.py index fad1e9c..4204734 100644 --- a/cbz/player.py +++ b/cbz/player.py @@ -3,6 +3,7 @@ import tkinter as tk from io import BytesIO from tkinter import ttk from tkinter.constants import DISABLED, NORMAL +from ctypes import windll from PIL import Image, ImageTk from pathlib import Path @@ -12,6 +13,8 @@ from cbz.page import PageInfo from cbz.utils import readable_size import os +PARENT = Path(__file__).parent + class Player: """ @@ -53,13 +56,12 @@ class Player: # Set initial window size self.root.geometry(self._get_initial_geometry()) - # Check if windows or linux + # Check if windows or linux for window icon if os.name == 'nt': - # Set window icon - self.root.iconbitmap(Path(__file__).parent / 'cbz.ico') + windll.shell32.SetCurrentProcessExplicitAppUserModelID('cbz.player') + self.root.iconbitmap(PARENT / 'cbz.ico') else: - # Set window icon - self.root.wm_iconphoto(True, tk.PhotoImage(file=Path(__file__).parent / 'cbz.png')) + self.root.wm_iconphoto(True, tk.PhotoImage(file=PARENT / 'cbz.png')) # Create main frame for content self.main_frame = ttk.Frame(self.root) @@ -93,7 +95,7 @@ class Player: str: Window title. """ if self.comic_info.series and self.comic_info.title: - return f"{self.comic_info.series} - {self.comic_info.title}" + return f'{self.comic_info.series} - {self.comic_info.title}' return self.comic_info.title or self.__class__.__name__ def _get_initial_geometry(self) -> str: