Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the Same Icon as Application Icon in Task bar for pyqt5 application

I am finding trouble with attaching the same icon in the task bar manager for pyqt5 application as I did for the icon of pyqt5 application. I have attached below code for icon display in pyqt5, just need a bit help that how to code for displaying of same icon of Application to the task bar. enter image description here

enter image description here

import sys
from SplashScreen import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QColor, qGray, QImage, QPainter, QPalette,QIcon
from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('./cricket.png'))
    w = QWidget()
    w.resize(300,300)
    w.setWindowTitle('Quick Cricket')
    w.show()
    sys.exit(app.exec_())

Thanks in advance

like image 547
Abdul Rehman Avatar asked Oct 19 '25 13:10

Abdul Rehman


2 Answers

Guess What I found the Answer.

I used three lines of Code at the start of my application and then run the code and windows show me same icon as it was my logo.

import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

What these lines do? So in short these lines will tell the window that this is my own registered application, so I will decide the icon of it.

I will give all credit to @DamonJW Stack Overflow Developer. Thanks @DamonJW. Here is the link of solution

< https://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7/1552105#1552105>

like image 194
Abdul Rehman Avatar answered Oct 22 '25 14:10

Abdul Rehman


enter image description here

The solution is in this line

import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
like image 39
lakhdar bekkari Avatar answered Oct 22 '25 12:10

lakhdar bekkari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!