0
votes

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

1
Please post code as text, not as image. Then, ensure that you provide a minimal, reproducible example. - musicamante
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_()) - Abdul Rehman
Here is the sample code - Abdul Rehman
don't use comments, as they don't support formatting and they make difficult to read code. Edit the question instead, and follow the guidelines about formatting code. - musicamante
@musicamante still waiting for answer - Abdul Rehman

1 Answers

0
votes

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://stackguides.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7/1552105#1552105>