Table of contents
How to cancel the layout of the original control
Overview of this article
PYQT5 is a visual GUI development framework based on python. It has the advantages of easy to use, beautiful interface, and multi-platform deployment. Through a series of tutorials, the author will lead everyone from zero basics to entry~to realize GUI development independently.
about the author
The author himself is an artificial intelligence alchemist. Currently, his main research direction in the laboratory is generative models. He also has some knowledge of other directions. He hopes to communicate and share with friends who are also interested in artificial intelligence on the CSDN platform. progress. Thank you everyone~~~
如果你觉得这篇文章对您有帮助,麻烦点赞、收藏或者评论一下,这是对作者工作的肯定和鼓励。
Create main window
We select Main Window and click Create to create the main window of our GUI interface
horizontal layout
First, we drag the 5 button controls from the control bar on the left into our main window
Then, we hold down the left mouse button and select the five button controls in the main interface.
Then right-click the mouse and select Horizontal Layout in Layout
We can try dragging to change the width and height of the horizontal layout. We can find that the button controls in the horizontal layout will maintain equal width and equal distance. Among them, the width of the button control in the layout will change as the width of the horizontal layout changes, but the height of the button control will not change as the height of the layout changes.
vertical layout
Like the horizontal layout, we first prepare 5 button controls and place them vertically
Select vertical layout in layout
We can try dragging to change the width and height of the vertical layout. We can find that the button controls in the vertical layout will maintain equal width and equal distance. Among them, the width of the button control in the layout will change as the width of the vertical layout changes, but the height of the button control will not change as the height of the layout changes.
grid layout
We imitate the number area on the keyboard and arrange 11 button controls, as shown in the figure below
After we select all controls, select grid layout
We can try dragging to change the width and height of the grid layout. We can find that the button controls in the grid layout will maintain equal width and equal distance. Among them, the width of the button control in the layout will change as the width of the grid layout changes, but the height of the button control will not change as the height of the layout changes.
In addition, we also need to place the controls as neatly as possible, otherwise the positions of the controls after layout may be messed up, as shown in the error example below.
However, after actual use, the layout recognition is still very accurate. As long as it is not too crooked, it can basically be accurately recognized.
splitter horizontal layout
Continue to invite our veteran actor F5
layout selected splitter horizontal layout
We can try dragging to change the width and height of the splitter's horizontal layout. We can find that the button controls in the splitter's horizontal layout will maintain equal width and equal distance. Among them, the width of the button control in the layout will change as the width of the splitter horizontal layout changes, and the height of the button control will also change as the height of the layout changes.
splitter vertical layout
Similar to the above operation
We can try dragging to change the width and height of the splitter vertical layout. We can find that the button controls in the splitter vertical layout will maintain equal width and equal distance. Among them, the width of the button control in the layout will change as the width of the splitter vertical layout changes, and the height of the button control will also change as the height of the layout changes.
Free layout
As the name suggests, free layout means the position and size of the control. We can adjust it manually by ourselves, or we can adjust it through the property editor of the control.
We first create a control and select the control
Among them, [(301,275),] in the geometry attribute is the coordinate of the upper left corner of the control and its superior container. For example, our button control is currently placed under the main window, so this (301, 275) is the distance from the upper left corner of the main window. x,y distance of angular coordinate (0,0). If we put this control in a container window, then the coordinates are determined based on the coordinates of the upper left corner of the container window. Therefore we can change the coordinates in the geometry to change the relative position of our control
[,75x20] is the width and height of the control. We can also change the width and height of the control by modifying this parameter.
How to cancel the layout of the original control
Right-click the control that already has a layout, and then select Break layout in the layout.
The content of this chapter is indeed a bit watery, mainly because there is not much to say.
Epilogue
如果您觉得这篇文章对您有帮忙,请点赞、收藏。您的点赞是对作者工作的肯定和鼓励,这对作者来说真的非常重要。如果您对文章内容有任何疑惑和建议,欢迎在评论区里面进行评论,我将第一时间进行回复。