Pyqt5 and Qt-designer combined

Source: Internet
Author: User

In Ubuntu we installed python3-pyqt5 This package can be programmed with PYQT5, but only with pure code to write the form, very troublesome. We're going to use Qt-designer to design the form.

We can install Qt4-designer This package via the new installation, and the shell command Apt-get installs. The interface is as follows:

When the form is completed through this software, it is saved as a UI file. We're going to turn it into a py file. We're going to use the command pyuic5 or pyuic4. We can't use this command because we don't have the appropriate package installed.

This command is pyqt4-dev-tools in this package, which we can install with either a new or shell command.

Convert File command:

 #把a. UI Build a.py   -  o a.py a.ui

Let's look at the newly generated a.py:

Where a class Ui_formis automatically generated, there is a method in the class Setupui ()

We create a Python file, import a.py

ImportSYS fromPyqt5.qtwidgetsImportQapplication, Qwidget#Import the appropriate package fromAImport*if __name__=='__main__': App=qapplication () W=Qwidget () UI = Ui_form () ui.setupui (w) w.show () sys.exit (App.exec_ ())

Pyqt5 and Qt-designer combined

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.