Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Creating PyQt Layouts for GUI Applications (Summary)

Creating high-quality GUI applications requires laying out all the graphical components in a coherent and polished arrangement. In PyQt, an effective way of doing that is to use PyQt’s layout managers, which provide a user-friendly and productive way of approaching this task.

In this course, you’ve learned:

  • What the benefits are of properly laying out the widgets on a GUI
  • How to programmatically arrange widgets using PyQt’s built-in layout managers
  • Which layout manager to use for your specific use case
  • How to lay out main window–style and dialog-style applications in PyQt

Here are additional resources about PyQt:

Download

Sample Code (.zip)

9.4 KB
Download

Course Slides (.pdf)

3.2 MB

00:00 All right! That was quite a few different lessons, and if you have gotten that far, you should have learned a lot about PyQt and about how to lay out widgets on the GUI.

00:09 But let’s talk through what we have covered over the last couple of videos, just to wrap this entire thing out. We started with a basic outline of what the problem of GUIs is.

00:18 And the problem is that you don’t have control over how your user is going to use your app. All this really means is that you have to have a flexible GUI that can respond to basically any scenario and any kind of device.

00:31 To account for that, we have learned about layout managers. In the beginning, we have learned about four basic ones: QHBoxLayout and QVBoxLayout, QGridLayout and QFormLayout.

00:43 And those already gave us quite a few different options. Then we also learned how to combine different layout managers and how to add space in between them. After we covered that, we talked about widgets that can hide different elements on the screen so you only show the user specific content that you want to be visible.

01:01 And for that, we have seen two additional layout managers: QStackedLayout, and QTabWidget. Those are also fairly straightforward when it comes down to it.

01:10 QStackedLayout creates pages that you can switch between, and QTabWidget gives you tabs that the user can switch in between. And that’s pretty much it! If you have gotten that far, you should be reasonably confident to create basically any kind of GUI at this point. Although, obviously, it really helps to practice this quite a bit.

01:28 And, of course, if you want to learn more, you can check out the PyQt learning path. There are lots more videos for more advanced topics. Again, you can find the link below this video. All right!

01:38 I hope you enjoyed this course, and I will see you around!

Ghani on Feb. 19, 2021

Very nice course. Thanks

Terry on Feb. 15, 2023

Excellent course, with my TKinter background I was able to follow this and feel very comfortable coding. So much better than the TKinter built-in, but having that background accelerated the learning. Recommended!

Jeff on Dec. 31, 2023

This is a very helpful course. I also found it helpful to follow along with the course by implementing the layouts in Qt Designer. The course provided a solid understanding of the back end of implementing the layout managers which is helpful to understand what Qt Designer is actually doing (and makes it so can tweak the code generated by Qt Designer).

Become a Member to join the conversation.