美文网首页
PyQt5安装及两种打包方法

PyQt5安装及两种打包方法

作者: 咸小鱼404 | 来源:发表于2019-04-28 20:25 被阅读0次

    安装

    pip install PyQt5==5.9.2
    pip install PyQt5-tools
    

    打包工具1-PyInstaller

    pip install PyInstaller

    pyinstaller -F -w xxxx.py

    pyinstaller -F -w -i xx.ico xxxx.py

    路径不要有中文!!!

    打包工具2-fbs

    1-创建并激活py虚拟环境
    python -m venv venv
    ./venv/scripts/activate.bat
    2-在py虚拟环境下创建项目
    fbs startproject
    这里会提示你输入项目名称作者及平台,注意项目名称不要有中文!!!
    /src/build/settings/base.json中可以设置项目主文件
    /src/main/icons中可以设置项目图标
    3-运行
    fbs run
    主程序默认io路径为项目主文件夹
    4-打包(免安装版)(推荐)
    fbs freeze
    5-打包(独立exe需解压)
    fbs installer
    win系统需要安装NSIS
    资源文件可以放在freeze后的文件夹内再installer即可一起打包进去

    fbs项目的Github地址:https://github.com/mherrmann/fbs-tutorial

    pyinstaller和fbs对应项目源码并不相同:

    pyinstaller:

    if __name__ == '__main__':
        app = QApplication(sys.argv)
        my = MyWindow()
        my.show()
        sys.exit(app.exec_())
    

    fbs:

    from fbs_runtime.application_context import ApplicationContext
    
    if __name__ == '__main__':
        appctxt = ApplicationContext()
        my = MyWindow()
        my.show()
        sys.exit(appctxt.app.exec_())
    

    相关文章

      网友评论

          本文标题:PyQt5安装及两种打包方法

          本文链接:https://www.haomeiwen.com/subject/yonjnqtx.html