Pycharm+python+pyqt5 use

Source: Internet
Author: User
Tags qt designer

Reprinted from Http://www.cnblogs.com/dalanjing/p/6978373.html, and made minor changes

1. Open cmd installation PyQt5

Pip Install Pyqt5

2,PYQT5 no longer provides tools such as QT Designer, so you need to install Pyqt5-tools

Pip Install Pyqt5-tools

3. Open Pycharm, enter settings, add external Tools

4, add Qtdesigner,designer.exe in the installation directory D:\ProgramData\Anaconda3\Lib\site-packages\pyqt5-tools\ Designer.exe, notice that the working directory is changed to make it easier.

5, set "Pyuic"-this is mainly used to convert the QT interface into the PY code

In the Pyuic settings, the other is the same, program writes to the Python address, parameters writes

-M PyQt5.uic.pyuic  $FileName $-O $FileNameWithoutExtension $.py

The above complete Setup, the following simple example uses the method

6, New project

Using designer, after creating a new main window, use Pyuic to convert the Hello.ui file to hello.py

If in the 5th step, set Pyuic, working directory: This is not set to $filedir$, the above operation may be wrong.

7, add main.py because the UI file is named Hello, so import is Hello

1 ImportSYS2 ImportHello3  fromPyqt5.qtwidgetsImportqapplication, Qmainwindow4 5 if __name__=='__main__':6App =qapplication (SYS.ARGV)7MainWindow =Qmainwindow ()8UI =Hello. Ui_mainwindow ()9 ui.setupui (MainWindow)Ten mainwindow.show () OneSys.exit (App.exec_ ())

Pycharm+python+pyqt5 use

Related Article

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.