当前位置:网站首页>Pyqt environment in pycharm

Pyqt environment in pycharm

2022-06-21 13:50:00 It Xing

Download and install PyQT5

  1. cmd Install in mode
pip install PyQt5

 Insert picture description here
2. Official website ----https://www.riverbankcomputing.com — The latest version 5.14.1
1). Download the version you need
 Insert picture description here
2). Install and download .whl package —cmd Pattern —pip install +.whl File directory
 Insert picture description here

pycharm Configure the environment in

1. open pycharm +File+setting+ Search for "External Tools"
 Insert picture description here
2. Click on + ----------------- Enter the create tool window
 Insert picture description here
 Insert picture description here
3. Fill in the content
1) Fill in Name------ Random names ( Girlfriend's name is OK )
2) Fill in Program ----- Fill in QT Installation directory ( Maybe you don't know your QT Installation directory , I'll teach you )----- Be sure to add. .exe
 Insert picture description here
Next, open the file location ( You can )+ Copy files path+ Paste the Program in
3). Fill in Woking directory( Copy and paste )

$ProjectFileDir$ 

4) Next ok that will do
4. The increase will .ui File conversion to .py File tool (designer The files generated in the tool are .ui file , You need to .ui File conversion to .py file )
 Insert picture description here
1) Fill in Name------ Random names ( Girlfriend's name is OK )
2) Fill in Program -----python Installation directory ( Method is the same as above. )
3) Fill in Arguments( take .ui File conversion to .py File code )

-m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py

4) Fill in Woking directory

$FileDir$
  1. Click on ok
    6) Click on ok that will do
     Insert picture description here

Test environment

1. open Qt Designer Tools
 Insert picture description here
 Insert picture description here
2) Select main form + Click Create
 Insert picture description here
3)Ctrl+s Save the file , then .ui Save the file to the project directory
 Insert picture description here
4) take ui File conversion to .py file
 Insert picture description here
5) In the transformation of py Add running code to the file , function py file

    app = QtWidgets.QApplication(sys.argv)  #  You must first instantiate QApplication class , As GUI Main program entry 
    MainWindow = QtWidgets.QMainWindow()  #  Instantiation QtWidgets.QMainWindow class , Create your own menu Form type of QMainWindow
    ui = Ui_MainWindow()  #  example UI class 
    ui.setupUi(MainWindow)  #  Set the form UI
    MainWindow.show()  #  Display Form 
    sys.exit(app.exec_())  #  When a distribution event from the operating system assigns a call window ,
    #  The application opens the main loop (mainloop) The process ,
    #  When the window is created , The main cycle process needs to be ended ,
    #  Call at this time sys.exit() The method is to , End the main cycle process and exit ,
    #  And free up memory . Why app.exec_() instead of app.exec()?
    #  because exec yes python System default keyword , To make a difference , So it's written as exec_
原网站

版权声明
本文为[It Xing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221431341148.html