Giter Site home page Giter Site logo

pyqt-'s Introduction

PyQT-

环境:Pycharm IDE+PtQT+Qt designer

第一步 安装环境

  需要安装python下qt的环境及工具,终端terminal下面运行指令,我这里已经安装,所以显示已经有了,两个都需要安装,需要记住安装的位置,一会儿需要设置环境变量。

pip install PyQt5
pip install PyQt5-tools
(DemoProject) E:\WorkSpace\BT\DemoProject>pip install PyQt5
Requirement already satisfied: PyQt5 in c:\users\guoqing.zhang\appdata\local\programs\python\python37\lib\site-packages (5.1
5.2)
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\users\guoqing.zhang\appdata\local\programs\python\python37\lib\site
-packages (from PyQt5) (12.8.1)

配置qt designer.exe环境变量,根据自己安装的目录选择 目录:C:\Users\guoqing.zhang\AppData\Local\Programs\Python\Python37\Lib\site-packages\qt5_applications\Qt\bin

在这里插入图片描述

第二步 Pycharm配置外部工具

  打开Pycharm,点击File-->Setting-->Tools-->External Tools,选择+号新建,第一个是qt designer,program为路径,arguments不填,working directory 为工作路径,填 $ FileDir $,为当前工作目录,这个工具可以直接打开qt designer(qt 设计师)。

在这里插入图片描述

  第二个是PyUIC,program为python路径,arguments 填:-m PyQt5.uic.pyuic $ FileName $ -o $FileName,可以将UI文件转换为python代码,注意FileName前后没有空格。

在这里插入图片描述

第三步 qt界面设计

  • 可以使用代码进行绘制
    self.Seed = QLineEdit()
    self.DescriptionSeed = QLabel()
    self.Key = QLineEdit()
    self.DescriptionKey = QLabel()
    self.DescriptionSeed.setText('Seed')
    self.DescriptionKey.setText('Key')
    self.Seed.setFixedWidth(200)
    self.Seed.setFixedHeight(25)
    self.Key.setFixedHeight(25)
    self.Key.setFixedWidth(200)
    self.Seed.setPlaceholderText('例如:0D 4A 1F FE')

在这里插入图片描述

几个函数介绍一下

  1. setFixedSize,设置控件大小
  2. QHBoxLayout,QVBoxLayout,控件横纵摆放函数
  3. addWidget,添加控件函数
  4. addLayout,添加布局函数
  5. QGroupBox,管理布局的组管理函数
  6. setLayout,设置布局,就可以显示出控件
  • 也可以直接使用qt designer 进行绘制

在这里插入图片描述

第四步打包生成exe文件

终端 terminal 下面运行指令:   pyinstaller -F -w win.py, 运行完成之后,工程目录中会有dist的文件夹,里面有exe问可执行文件。

在这里插入图片描述

碰到的问题:Pycharm 右键菜单选项里面没有external tools

解决办法复制Link或者path(如下图所示),然后到IDE界面显示工程文件的区域粘贴,反复尝试几次,然后重新打开就有了

在这里插入图片描述 在这里插入图片描述

关于本项目

  • 项目作者:ZGQ
  • 邮箱:[email protected]
  • 开发环境:PtQT5 版本5..15,Qt_Designer,Python 3.7
  • 适用平台:WIndow

pyqt-'s People

Contributors

zhangyixisucceed avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.