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