fix(icon): eradicate tk86t.dll feather resource at DLL/EXE binary level and match shortcut AppUserModelID
This commit is contained in:
parent
b1344c2c0d
commit
e7b1c08cae
3 changed files with 53 additions and 5 deletions
|
|
@ -45,8 +45,8 @@ Source: "assets\logo.ico"; DestDir: "{app}\assets"; DestName: "ld_v35_icon.ico";
|
|||
Source: "LICENSE"; DestDir: "{app}"; Flags: ignoreversion
|
||||
|
||||
[Icons]
|
||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"; Tasks: desktopicon
|
||||
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"; AppUserModelID: "LilDosto.LDownloader.App.v35"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\assets\ld_v35_icon.ico"; AppUserModelID: "LilDosto.LDownloader.App.v35"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||
|
|
|
|||
16
ui/app.py
16
ui/app.py
|
|
@ -34,7 +34,7 @@ class LDownloaderApp(tk.Tk):
|
|||
except Exception:
|
||||
pass
|
||||
try:
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("lildosto.ldownloader.v35.ldicon2")
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("LilDosto.LDownloader.App.v35")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
@ -137,7 +137,17 @@ class LDownloaderApp(tk.Tk):
|
|||
if sys.platform != "win32" or not self._ico_path or not os.path.isfile(self._ico_path):
|
||||
return
|
||||
try:
|
||||
from ctypes import wintypes
|
||||
user32 = ctypes.windll.user32
|
||||
user32.GetParent.argtypes = [wintypes.HWND]
|
||||
user32.GetParent.restype = wintypes.HWND
|
||||
user32.LoadImageW.argtypes = [wintypes.HINSTANCE, wintypes.LPCWSTR, wintypes.UINT, ctypes.c_int, ctypes.c_int, wintypes.UINT]
|
||||
user32.LoadImageW.restype = wintypes.HANDLE
|
||||
user32.SendMessageW.argtypes = [wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM]
|
||||
user32.SendMessageW.restype = wintypes.LPARAM
|
||||
user32.SetClassLongPtrW.argtypes = [wintypes.HWND, ctypes.c_int, wintypes.HANDLE]
|
||||
user32.SetClassLongPtrW.restype = wintypes.HANDLE
|
||||
|
||||
hwnd = user32.GetParent(self.winfo_id()) or self.winfo_id()
|
||||
if not hwnd:
|
||||
return
|
||||
|
|
@ -149,9 +159,9 @@ class LDownloaderApp(tk.Tk):
|
|||
GCLP_HICON = -14
|
||||
GCLP_HICONSM = -34
|
||||
if not self._hicon_big:
|
||||
self._hicon_big = user32.LoadImageW(0, self._ico_path, IMAGE_ICON, 256, 256, LR_LOADFROMFILE)
|
||||
self._hicon_big = user32.LoadImageW(None, self._ico_path, IMAGE_ICON, 256, 256, LR_LOADFROMFILE)
|
||||
if not self._hicon_sm:
|
||||
self._hicon_sm = user32.LoadImageW(0, self._ico_path, IMAGE_ICON, 32, 32, LR_LOADFROMFILE)
|
||||
self._hicon_sm = user32.LoadImageW(None, self._ico_path, IMAGE_ICON, 32, 32, LR_LOADFROMFILE)
|
||||
if self._hicon_big:
|
||||
user32.SendMessageW(hwnd, WM_SETICON, ICON_BIG, self._hicon_big)
|
||||
user32.SetClassLongPtrW(hwnd, GCLP_HICON, self._hicon_big)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,42 @@
|
|||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
from PyInstaller.compat import win32api
|
||||
from PyInstaller.utils.win32 import icon as _pyi_icon
|
||||
|
||||
# Tcl/Tk'nin varsayılan mavi tüy ('TK') ikon kaynağını hem tk86t.dll hem de EXE içinde LD ikonuyla değiştir
|
||||
def _patch_tk_icon_resources():
|
||||
ico_file = os.path.abspath('assets/logo.ico')
|
||||
if not os.path.isfile(ico_file):
|
||||
return
|
||||
tk_dll = os.path.join(os.path.dirname(sys.executable), 'DLLs', 'tk86t.dll')
|
||||
if os.path.isfile(tk_dll):
|
||||
try:
|
||||
f = _pyi_icon.IconFile(ico_file)
|
||||
grp = f.grp_icon_dir() + f.grp_icondir_entries(1)
|
||||
hdst = win32api.BeginUpdateResource(tk_dll, 0)
|
||||
win32api.UpdateResource(hdst, _pyi_icon.RT_GROUP_ICON, 'TK', grp)
|
||||
win32api.UpdateResource(hdst, _pyi_icon.RT_GROUP_ICON, 1, grp)
|
||||
for idx, img in enumerate(f.images, start=1):
|
||||
win32api.UpdateResource(hdst, _pyi_icon.RT_ICON, idx, img)
|
||||
win32api.EndUpdateResource(hdst, 0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
_orig_copy_icons = _pyi_icon.CopyIcons_FromIco
|
||||
def _patched_copy_icons(dstpath, srcpath, id=1):
|
||||
_orig_copy_icons(dstpath, srcpath, id=id)
|
||||
try:
|
||||
f = _pyi_icon.IconFile(srcpath[0])
|
||||
grp = f.grp_icon_dir() + f.grp_icondir_entries(1)
|
||||
hdst = win32api.BeginUpdateResource(dstpath, 0)
|
||||
win32api.UpdateResource(hdst, _pyi_icon.RT_GROUP_ICON, 'TK', grp)
|
||||
win32api.UpdateResource(hdst, _pyi_icon.RT_GROUP_ICON, 'tk', grp)
|
||||
win32api.EndUpdateResource(hdst, 0)
|
||||
except Exception:
|
||||
pass
|
||||
_pyi_icon.CopyIcons_FromIco = _patched_copy_icons
|
||||
_patch_tk_icon_resources()
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue