qpixmap pyqt5

Solutions on MaxInterview for qpixmap pyqt5 by the best coders in the world

showing results for - "qpixmap pyqt5"
Anton
15 May 2020
1#!/usr/bin/python
2
3"""
4ZetCode PyQt5 tutorial
5
6In this example, we display an image
7on the window.
8
9Author: Jan Bodnar
10Website: zetcode.com
11"""
12
13from PyQt5.QtWidgets import (QWidget, QHBoxLayout,
14                             QLabel, QApplication)
15from PyQt5.QtGui import QPixmap
16import sys
17
18
19class Example(QWidget):
20
21    def __init__(self):
22        super().__init__()
23
24        self.initUI()
25
26    def initUI(self):
27        hbox = QHBoxLayout(self)
28        pixmap = QPixmap('sid.jpg')
29
30        lbl = QLabel(self)
31        lbl.setPixmap(pixmap)
32
33        hbox.addWidget(lbl)
34        self.setLayout(hbox)
35
36        self.move(300, 200)
37        self.setWindowTitle('Sid')
38        self.show()
39
40
41def main():
42    app = QApplication(sys.argv)
43    ex = Example()
44    sys.exit(app.exec_())
45
46
47if __name__ == '__main__':
48    main()
49