0

I'm seeking a way to modify the icon on the top left position of the window and also the icon in the task bar at the bottom of the screen

enter image description here I would like use this one:

enter image description here

The answer of Netwave changed the icon of the window but not the one in the taskbar.

from PyQt5.QtWidgets import *
import sys 

class GUI(QMainWindow):
    def __init__(self, parent=None):
        super(GUI, self).__init__()
        self.parent = parent
        self.setWindowIcon(QIcon(QPixmap(os.path.join('icons','pulse.png'))))
        self.setFixedWidth(200)
        self.setFixedHeight(200)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = GUI(app)
    ex.show()
    sys.exit(app.exec_( ))
ymmx
  • 4,769
  • 5
  • 32
  • 64

1 Answers1

2

You can add it to the app:

app_icon = QIcon("path_to_file")
app.setWindowIcon(app_icon)

With your code would look like"

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app_icon = QIcon("path_to_file")
    app.setWindowIcon(app_icon)
    ex = GUI(app)
    ex.show()
    sys.exit(app.exec_( ))
Netwave
  • 40,134
  • 6
  • 50
  • 93
  • How simple It was. Do you know If I can modify the background color of the icon. I mean replaced the transparent part of the icon with a color? – ymmx Oct 22 '18 at 07:13
  • yes, you can do that also by loading the image, modifiying it and the using that image for building the icon – Netwave Oct 22 '18 at 07:21