Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use pyqt5 to develop programs in python

Shulou Source: shulou.com Published: 2022-06-02 03:17:23 09月22日 Update

Today, I will talk to you about how to use pyqt5 development programs in python, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

In this section, we use pyqt5 to develop programs. Below, we briefly analyze the knowledge points of the generated code:

The generation of interface is based on PyQt5 library.

The library comes from the pip pipeline download command, for example

Pip install pyqt5-I https://pypi.tuna.tsinghua.edu.cn/simple

Sys module is responsible for operating modules such as system files.

QtWidgets is the base class of all qt controls.

QApplication is simply understood as the process of the program, and the code is instantiated as the object app.

The main function of app.exec_ () is to use an endless loop to listen for events such as interface controls such as close buttons.

_ _ name__ when this file is running, the result is _ _ main__

Use _ _ name__=='__main__' to simulate the main entry of the python program

In order to make us more familiar with the code generated after qtdesigner design, we will use more pure pyqt5 code to write programs in the future. Of course, after we are familiar with it, we can directly use qtdesigner to directly and quickly develop the interface.

In our case in this section, we use QtWidgets to write the first program, based on pyqt5.

Write the first pyqt5 program in pure code, with the following source code:

Import sysfrom PyQt5.QtWidgets import QApplication,QWidget

If _ _ name__=='__main__': app = QApplication (sys.argv) w=QWidget () w.resize (400300) w.setWindowTitle ("Liu Jinyu programming") w.move (200300) w.show () sys.exit (app.exec_ ()) after reading the above, do you have any further understanding of how to use pyqt5 to develop programs in python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Programs code development interface content controls files more modules knowledge generation events functions portals epigenetic commands graphics instances objects that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Apple NVidia Shulou Information