A QPixmap can be used to show an image in a PyQT window. QPixmap() can load an image, as parameter it has the filename. To show the image, add the QPixmap to a QLabel.

QPixmap supports all the major image formats: BMP,GIF,JPG,JPEG,PNG,PBM,PGM,PPM,XBM and XPM.

Download Examples:
Download PyQt examples

PyQT image

QPixmap

Start by creating a QPixmap and a QLabel. Then you can combine them like this:

self.im = QPixmap("./image.jpg")
self.label = QLabel()
self.label.setPixmap(self.im)

Then add the whole thing to a layout, like a QGridLayout

self.grid = QGridLayout()
self.grid.addWidget(self.label,1,1)
self.setLayout(self.grid)

image

Example

Copy and paste the code below to load an image from your local computer. The image will be shown in a grid layout.

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtGui import QPixmap

class Example(QWidget):

def __init__(self):
super().__init__()

self.im = QPixmap("./image.jpg")
self.label = QLabel()
self.label.setPixmap(self.im)

self.grid = QGridLayout()
self.grid.addWidget(self.label,1,1)
self.setLayout(self.grid)

self.setGeometry(50,50,320,200)
self.setWindowTitle("PyQT show image")
self.show()

if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())