Loading video player…

Creating PyQt Layouts for GUI Applications (Overview)

PyQt’s layout managers provide a user-friendly and productive way of arranging graphical components, or widgets, on a GUI. Laying out widgets properly will make your GUI applications look polished and professional. Learning to do so efficiently and effectively is a fundamental skill for you to get up and running with GUI application development using Python and PyQt.

In this course, you’ll learn:

  • What the benefits are of using PyQt’s layout managers
  • How to programmatically lay out widgets on a GUI using PyQt’s layout managers
  • How to select the right layout manager for your GUI application
  • How to lay out widgets in main window–based and dialog-based applications

For a better understanding of how to use layout managers, some previous knowledge of how to create PyQt GUI applications and how to work with PyQt widgets would be helpful.


Sample Code (.zip)

9.4 KB

Course Slides (.pdf)

3.2 MB

00:00 Hello there! In this course, we are going to create flexible GUIs in PyQt5. Specifically, here’s what we are going to make. We are going to create some GUIs that scale in the horizontal axis, some that scale on the vertical axis, some that scale on both axes, and we are also going to make some GUIs that have tabs and entire different pages.

00:22 All of this can be achieved very easily because all we need to learn about is the PyQt layout manager. This is what we are going to focus on in this course.

00:32 This one allows us to place a widget on a GUI and to make it responsive, and this is going to be the main thing we are going to learn about. Besides that, we are going to talk about how to select specific layouts for specific purposes and generally, we are going to talk about how to create flexible GUIs in a presentable manner. All of this should be fairly straightforward, although I would recommend that you already know the basics of PyQt.

00:59 Now, this doesn’t have to be much. The minimum you should know is how to create a window in PyQt and at least know what widgets are. Although later on for one video, we are also going to use signals and slots, although we are only going to use it for the pages later on.

01:16 This comes quite late in this course, so you could follow most of the lessons without knowing about signals. But generally, most of the concepts are fairly simple, so if you know the basics of PyQt, this should be fairly straightforward.

01:29 I am using the latest version of PyQt5, which at the moment is 5.15.2. I assume that you already have PyQt installed yourself, either on the system or in a virtual environment that you know how to use. Now, if none of that made sense and you are just starting out with PyQt, check out the PyQt learning path.

01:50 All of the basics are explained in detail there. You can find the link to it in the description for this lesson.

01:57 Before we jump into the course, let’s talk about its structure. Fundamentally, there are two major components of this course. Number one is an introduction to layout managers. So in the next video, I talk about the main problem GUIs have. After that, for the next four videos we’ll talk about different layout managers.

02:14 Then there are two more videos to talk about different ways to customize them a little bit further. Once we have all of that covered, there are going to be two more videos that cover more advanced layout managers.

02:25 Once we have those, we are going to conclude this course and we are good to go. It should be pretty straightforward. So with all of that covered, let’s jump into the course!

Avatar image for geovanivicente

geovanivicente on June 18, 2023

Why does this code work well in Jupyter Notebook but not PyCharm? (about the precedure to set up a box with buttons)

Become a Member to join the conversation.