Setting the Same Icon as Application Icon in Task bar for pyqt5 application
Question:
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.
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
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
The solution is in this line
import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
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.
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
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
The solution is in this line
import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)