You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PySimpleGUI+PyInstaller生成EXE任务栏图标重合问题咨询

PySimpleGUI打包EXE任务栏图标共享问题解决方案

这是PySimpleGUI从4.58.0版本开始引入的已知问题,根源在于新版本中Windows平台的默认应用程序ID(App User Model ID)被统一设置,导致系统任务栏将不同名称的打包EXE识别为同一应用,进而共享图标。

临时解决办法

1. 手动设置唯一应用程序ID

在创建窗口前,通过Windows API为每个程序指定唯一的AppUserModelID,确保系统能区分不同应用。修改后的代码如下:

import PySimpleGUI as sg
import ctypes

# 为每个程序设置唯一的ID,格式自定义即可
myappid = 'my.unique.app.id.v1'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

layout = [[sg.T(f"PSG version: {sg.version}")]]
window = sg.Window('Taskbar icon issue', layout)

while True:
    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break

window.close()

重新用pyinstaller --onefile --noconsole main.py --icon icon.ico打包后,不同名称的EXE将在任务栏显示各自的图标。

2. 降级PySimpleGUI版本

如果暂时不想修改代码,可以降级到4.57.0版本,该版本不存在此问题:

pip install PySimpleGUI==4.57.0

不过此方法会错过后续版本的功能更新与Bug修复,仅作为临时过渡方案。

内容的提问来源于stack exchange,提问作者Lee-xp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 12:22:09