Fix windows taskbar player icon

This commit is contained in:
hyugogirubato
2024-07-15 19:05:13 +02:00
parent f62a508d9a
commit 82e1764c2e
2 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -171,4 +171,4 @@ poetry.toml
pyrightconfig.json pyrightconfig.json
### CBZ ### ### CBZ ###
.cbz *.cbz
+8 -6
View File
@@ -3,6 +3,7 @@ import tkinter as tk
from io import BytesIO from io import BytesIO
from tkinter import ttk from tkinter import ttk
from tkinter.constants import DISABLED, NORMAL from tkinter.constants import DISABLED, NORMAL
from ctypes import windll
from PIL import Image, ImageTk from PIL import Image, ImageTk
from pathlib import Path from pathlib import Path
@@ -12,6 +13,8 @@ from cbz.page import PageInfo
from cbz.utils import readable_size from cbz.utils import readable_size
import os import os
PARENT = Path(__file__).parent
class Player: class Player:
""" """
@@ -53,13 +56,12 @@ class Player:
# Set initial window size # Set initial window size
self.root.geometry(self._get_initial_geometry()) self.root.geometry(self._get_initial_geometry())
# Check if windows or linux # Check if windows or linux for window icon
if os.name == 'nt': if os.name == 'nt':
# Set window icon windll.shell32.SetCurrentProcessExplicitAppUserModelID('cbz.player')
self.root.iconbitmap(Path(__file__).parent / 'cbz.ico') self.root.iconbitmap(PARENT / 'cbz.ico')
else: else:
# Set window icon self.root.wm_iconphoto(True, tk.PhotoImage(file=PARENT / 'cbz.png'))
self.root.wm_iconphoto(True, tk.PhotoImage(file=Path(__file__).parent / 'cbz.png'))
# Create main frame for content # Create main frame for content
self.main_frame = ttk.Frame(self.root) self.main_frame = ttk.Frame(self.root)
@@ -93,7 +95,7 @@ class Player:
str: Window title. str: Window title.
""" """
if self.comic_info.series and self.comic_info.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__ return self.comic_info.title or self.__class__.__name__
def _get_initial_geometry(self) -> str: def _get_initial_geometry(self) -> str: