This article describes a visual UI view layout for developing desktop applications using Python + PyQt5

I. Installation of environment package

  • 1, if you do not know the virtual environment can refer to, or directly use pipenv

  • 2. Install PyQt5

    pip3 install pyqt5
    Copy the code
  • 3, Install PyQT5-Tools (note that it only supports Windows operating system, if you are a MAC, please install your own VM)

    pip3 install pyqt5-tools
    Copy the code
  • 4. Use pip3 list to check whether the installation is successful

Second, inpycharmIn the configurationpyqt5-toolstool

There are three main configurations in the PyCharm editor

  • 1. Open the interface of visual design

  • 2. Convert the saved. UI file of visual design into

  • 3. Convert the resources used in visual design into.py files

  • 4. Configuration results

Three,pyqt5-toolsThe configuration of the

  • 1. Click the plus sign above
  • 2. Configure as shown in the figure
  • 3. The above parameters are introduced
    • 1.NameIt’s self-naming
    • 2.DescriptionIt’s a simple trace element
    • 3.programIt’s the program that you execute
    • 4.Working directory: $ProjectFileDir$Is the insert macro that represents the project file directory

Four, about.uiFile conversion to.pyFile tools

  • 1. The configuration result is shown in the figure
  • 2. Introduction of various parameters
    • 1.ProgramIn the installation packagepyuic5.exeThe program
    • 2.ArgumentsConfigured to$FileName$ -o $FileNameWithoutExtension$.py -x
    • 3.Working directoryConfigured to$FileDir$Current file directory

5. Convert resource files topyfile

  • 1. The configuration result is shown in the figure
  • 2. Introduction of parameters
    • 1.ProgramIn the installation packagepyrcc5.exeThe program
    • 2.ArgumentsConfigured to$FileName$ -o $FileNameWithoutExtension$_rc.py
    • 3.Working directoryConfigured to$FileDir$Current file directory

6. Check whether the configuration is successful

  • 1. View the configured external tools
  • 2, clickpyqt5-toolsOpen the visual window of the design
  • 3. Set the background image style for the button
  • 4. Create a resource by following the preceding steps and select the resource on the right
  • 5. After saving, one will be generated under this projectx.uiandx.qrcfile
  • 6. Right-click the file, select external tools, and select different compilation tools based on different file formats
  • 7. Direct operationx.uiThe compiledpyFile, view the effect