Python ui interface design (1)

1. Install PyQt5 and Qt Designer

After pressing win+R, enter cmd,

pip install pyqt5
pip install pyqt5-tools

Due to network and other reasons, the installation may fail, you can use

pip install pyqt5-tools -i https://pypi.tuna.tsinghua.edu.cn/simple

Installation path: C:\Users\fylal\AppData\Local\Programs\Python\Python37\Lib\site-packages\qt5_applications\Qt\bin

insert image description here

2. Configure in pycharm

File-settings-Tools-External Tools, then click the plus sign, and configure as follows.
insert image description here

Configure pyuic to directly convert ui files to py files
insert image description here

The installation and configuration of dependent packages and tools is complete. Here is a brief demonstration of how to use it. First open or create a new Python project, click " Tools " in the menu bar , select " External Tools ", you can see the two tools set up before, select " Qt Designer " to open the Qt design tool, the steps are shown in the following figure:
insert image description here

Common components

After clicking QtDesigner, or click designer.exe under the installation path, click Create.

Common components:

  • Confirm key (PushButton)

insert image description here

Can change object name and style etc.

  • label

Styles and object names can also be changed

  • Text Edit (text input box)

  • Line Edit (often used for account and password input)

  • Horizontal/Vertical Line (can be used for area division lines)

insert image description here

Press ctrl+R to preview

insert image description here

  • Edit signal/slot

insert image description here

If you choose to clear, click the button, the text of text will be cleared

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-o5o41deO-1637734568807) (C:\Users\fylal\AppData\Roaming\Typora\typora-user-images\ image-20211124135422790.png)]

Multiple signal slots can be connected

insert image description here

Save the ui interface as a .py file

First save the designed interface as a .ui file

  • in pycharm

insert image description here

  • terminal to convert

insert image description here
insert image description here

run, the result is:
insert image description here

Guess you like

Origin blog.csdn.net/fyfy96/article/details/121514498
Recommended