Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Should you be using QT for Python as a GUI? Part four of an eight-part series of blogs |
---|
If you need to build a GUI system in Python, PyQt5 is probably the best choice, but don't take our word for it - read this blog and see what you think. |
In this blog
Layouts allow you to build forms with responsive designs, so you don't have to position widgets exactly where you want them to appear on screen:
The 4 layouts available in QT.
In the following example, I want my buttons to appear evenly spaced in a column:
The vertical layout (represented by the red rectangle) contains 3 buttons, the bottom one of which is shown selected.
Here are the size properties of each of the 3 buttons in the layout:
Each button will be at least 30 pixels high and 30 pixels high, but may stretch beyond this.
Here are the same buttons, but in a horizontal layout:
Horizontal layouts, as the name suggests, are for laying out controls in rows.
Understanding how widgets are spaced within a layout is the hardest thing about using QT Designer!
A grid consists of a rectangular block containing rows and columns:
This grid contains 3 rows and 2 columns.
A form layout is very similar, but a bit more restricted (you can only have two columns):
It's assumed that the first column contains labels, and the second input widgets.
You can use these widgets to space things out within layouts:
The two spacer widgets.
For example, this button appears in the centre of its parent horizontal layout because it has a horizontal spacer on either side of it:
A centrally aligned button.
For anyone reading this, here's a tip I wish I'd known when I first started using QT Designer: you can hold down the Shift key to select the immediate parent of a widget (so for the diagram above, holding down Shift and left-clicking would select the horizontal container in which the button sits).
Parts of this blog |
---|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.