[Python] How to set application icon in PyQt5 on MacOS

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am making an app in python with PyQt5 on a MacOS computer.

    This is my code:

    from PyQt5.QtWidgets import QApplication, QWidget, QLabel

    app = QApplication([])

    window = QWidget()
    window.setWindowTitle('Alarm App')

    label = QLabel('Alarm App', window)

    label.move(100, 50)
    window.show()

    app.exec_()


    When I run the app the window appears and and I can see the icon on the dock, the icon is the python launcher icon which is not icon I want, in the directory of the project I have an icon.png.

    I have tried:

    window.setWindowIcon(QIcon("icon.png"))


    But the icon still looks like this:

    [​IMG]

    Continue reading...

Compartilhe esta Página