简体   繁体   中英

Python exe created with PyInstaller shows custom icon in Windows Explorer but not in Taskbar when executed

I have written a Python desktop application using PyQt5 for the UI. I create the exe file using PyInstaller from inside PyCharm with the following options: --onefile --windowed --icon=QRev.ico QRev.py

The resulting exe has the QRev.ico icon when viewed in Windows Explorer but when executed a generic or perhaps the PyInstaller icon appears in the Windows 10 taskbar rather than the QRev Icon.

If I pin QRev.exe to the taskbar the icon works as expected. The problem occurs when the exe is executed from anywhere other than the taskbar, the icon in the taskbar is not correct. How can I fix this so that the QRev icon is shown in the taskbar?

Finally figure it out after a friend found a similar post for Tkinter.

The icon in the taskbar comes from inside the code not from PyInstaller. For pyqt5 I simply added the command: self.setWindowIcon(QtGui.QIcon('QRev.ico'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM