How to Show Image in Python & PyQt6

In this lesson we are going to learn How to Show Image in Python & PyQt6, for showing image in python and pyqt6 we are going to use QLabel, so first of all let’s talk about PyQt.

 

What is PyQt ?

PyQt is a set of Python bindings for the Qt application framework and runs on all platforms supported by Qt including Windows, OS X, Linux, iOS, and Android. PyQt is available under the GPL and commercial licenses. It is a multi-platform toolkit that helps developers create desktop applications that are compatible with different operating systems. It is built on top of the Qt library, which provides a large number of useful classes for creating desktop applications. PyQt allows developers to create GUI applications using Python and the Qt library, which provides a wide range of widgets and other tools for building modern and flexible user interfaces, there are different versions of PyQt, in this lesson we want to talk about latest version of PyQt and that is PyQt6. To install PyQt6, you can use the pip package manager by running the command pip install PyQt6.

 

 

What is QLabel ?

QLabel class is used for displaying messages, also you can use QLabel class for displaying images, there are different methods that you can use in QLabel class, for example we have setText() and it is used for setting the text, we have setPixamp() method and that is used for setting the image in the QLabel.

 

 

Learn More on PyQt6 GUI Development

 

 

 

This is the complete code for this lesson.

 

 

For showing image in PyQt6,  Qt provides four classes for handling images we have QImage, QPixmap, QBitmap and QPicture, in this lesson we are interested in QPixmap, and we have used that in here, make sure that you have already added an image in your working director.

 

 

 

Run the complete code and this will be the result.

How to Show Image in Python & PyQt6
How to Show Image in Python & PyQt6

 

 

Leave a Comment