0

I am trying to run this code to create a window with a given icon.

from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QWidget

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QtGui.QIcon('logo.png'))
        self.setGeometry(100,100,800,800)
        self.show()

if __name__=='__main__':
    app = QApplication([])
    window = Window()
    app.exec_()

The file logo.png is in the same folder. The problem is that when I run the code I get a window with the default icon and not logo.png.

ekhumoro
  • 107,367
  • 18
  • 208
  • 308
Andrea
  • 81
  • 5
  • Relative paths are relative to the *current working folder* which will almost always be different to the folder the script is in. – ekhumoro Aug 24 '21 at 20:44

0 Answers0