The use of Python and PyQt5 (1)

Since I helped the teacher compile a small program recently, I need to use QT to design a human-computer interaction interface for the program. Here is a brief summary.

1. Configure QT designer and Py UIC

When designing the interface, if each functional requirement is coded, it must be slow and painful.

1.1 Install PyQt5 and qt5-tools

I am used to using Anaconda for environmental management. Here I also recommend two pip installation instructions that I like to use:
(1) pip install xxx -i http://pypi.douban.com/simple --trusted-host pypi .douban.com

(2)pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn module_name
insert image description here

1.2 PyCharm configuration environment

insert image description here
insert image description here

====================================================================

Next, enter in the order in the figure, and don't care about the others.
The program path, let me say here, I use Anaconda for environmental management, which is more convenient. So my path is: D:\Anaconda3\envs\pytorch\Lib\site-packages\qt5_applications\Qt\bin\designer.exe. If you can’t find it, just look for it patiently according to the location of your installation. Working directory: $FileDir$ (no spaces, the same below).
For PyUIC, choose the program path. Many blogs recommend the installation location of Python, but some people here will report an error. Here we choose pyuic5.exe as the program, and the actual parameter input:

$FileName$ -o $FileNameWithoutExtension$.py 

Other similar.
insert image description here
insert image description here

The next step is to open
insert image description here

2. Use QT designer and Py UIC

2.1QT designer

Here we take creating a Main Window as an example, we drag the controls we need to use into the window on the right. Pull to change the size and position, and double-click to change the appearance of the text. It should be emphasized that if you change the object name (object name), you need to remember it, because it needs to be used in the code to call related operations.
insert image description here
insert image description here

2.2Py UIC

Use QT designer to design the window and save it. Back in PyCharm, the .ui file with the file name we saved will appear. We need to use PyUIC to convert the .ui file to a .py file for subsequent operations. After clicking, the .py file will appear in PyCharm.
insert image description here
See the follow-up update article for the use of related code calls, etc., in vain~~~
insert image description here

Guess you like

Origin blog.csdn.net/weixin_50557558/article/details/128594749