Im running through PyQt5 tuts and came across a couple of tutorials that use QIcon. I cant get anything given to QIcon to work at all whether its through QAction or setting the window icon via...
full code:
Ubuntu 16.04
My system was acting wacky so i did a complete fresh install again. Maybe i am missing a dependency or something?
self.setWindowIcon(QtGui.QIcon('py.png'))I tried the following based on google search results:
- full path
- changing image formats
- changing image sizes
- image in same directory as script
full code:
import sys from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication from PyQt5.QtGui import QIcon from PyQt5.QtCore import QFile class Example(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): print(QFile.exists('py.png')) exitAction = QAction(QIcon('/home/metulburr/py.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(qApp.quit) self.statusBar() menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(exitAction) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Menubar') self.show() if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() sys.exit(app.exec_())Anything given to QIcon is as if the line didnt exist at all.
Ubuntu 16.04
My system was acting wacky so i did a complete fresh install again. Maybe i am missing a dependency or something?
Recommended Tutorials: