Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Windows taskbar icon in PyQt

I'm working on an applcation in Python's PyQt4 and cannot find how to change the taskbar icon. I made my .ui files in Qt's Designer, where I can change the windowIcon properties. But that is not what I am looking for. I want to change the look of the application's icon in windows taskbar. For now it is Python logo in a window icon.

I found some information on SO: link but it's not helping me much.

I tried:

app = QtGui.QApplication([]) app.setWindowIcon(QtGui.QIcon('chip_icon_normal.png')) app.exec_() 

But the icon remains unchanged.

What i want to change, showing the picture: (This is done calling the setWindowIcon on main window/ dialog, or the application, as shown above.)

Taskbar icon change

like image 869
Marko Avatar asked Sep 14 '12 22:09

Marko


People also ask

How do I get the Windows icon on my taskbar?

To pin apps to the taskbar Select Start , scroll to the app you want to pin, then press and hold (or right-click) the app. Select More > Pin to taskbar. If the app is already open on the desktop, press and hold (or right click) the app's taskbar icon, and then select Pin to taskbar.


2 Answers

This problem is caused by some peculiarities in how taskbar icons are handled on the Windows platform.

See this answer for details, along with a workaround using ctypes.

like image 52
ekhumoro Avatar answered Sep 17 '22 15:09

ekhumoro


It seems to me that the problem may be caused by lack of icon with the right size. The following setup worked for me in PyQT4:

# set app icon     app_icon = QtGui.QIcon() app_icon.addFile('gui/icons/16x16.png', QtCore.QSize(16,16)) app_icon.addFile('gui/icons/24x24.png', QtCore.QSize(24,24)) app_icon.addFile('gui/icons/32x32.png', QtCore.QSize(32,32)) app_icon.addFile('gui/icons/48x48.png', QtCore.QSize(48,48)) app_icon.addFile('gui/icons/256x256.png', QtCore.QSize(256,256)) app.setWindowIcon(app_icon) 

I have got a task bar icon in Windows 7 and correct icons in all windows without any changes to ui files.

like image 22
Slawek Rewaj Avatar answered Sep 20 '22 15:09

Slawek Rewaj