button icon pyqt5

Solutions on MaxInterview for button icon pyqt5 by the best coders in the world

showing results for - "button icon pyqt5"
Yanis
30 Jul 2016
1from PyQt4 import QtGui, QtCore
2
3class Window(QtGui.QWidget):
4    def __init__(self):
5        QtGui.QWidget.__init__(self)
6        self.button = QtGui.QPushButton('', self)
7        self.button.clicked.connect(self.handleButton)
8        self.button.setIcon(QtGui.QIcon('myImage.jpg'))
9        self.button.setIconSize(QtCore.QSize(24,24))
10        layout = QtGui.QVBoxLayout(self)
11        layout.addWidget(self.button)
12
13    def handleButton(self):
14        pass
15
16
17if __name__ == '__main__':
18
19    import sys
20    app = QtGui.QApplication(sys.argv)
21    window = Window()
22    window.show()
23    sys.exit(app.exec_())
24