Python: 第一个Qt桌面应用程序 / 虚拟环境(virtualenv)中使用Nuitka打包exePython: 第一个Qt桌面应用程序 / 虚拟环境(virtualenv)中使用Nuitka打包exePython: 第一个Qt桌面应用程序 / 虚拟环境(virtualenv)中使用Nuitka打包exePython: 第一个Qt桌面应用程序 / 虚拟环境(virtualenv)中使用Nuitka打包exe
  • 首页
  • 博客
  • 文件
  • 书签
  • 分析
  • 登录
Search
Generic filters

Python: 第一个Qt桌面应用程序 / 虚拟环境(virtualenv)中使用Nuitka打包exe

Published by admin at 2022年3月20日
Categories
  • Practice
Tags
# 文件名:hello_word.py
import sys
from PyQt5.Qt import *

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.label_1 = QLabel()
        self.button_1 = QPushButton()
        self.set_ui()

    def set_ui(self):
        self.resize(300, 300)
        self.setStyleSheet("color:blue")
        self.setWindowTitle("主窗口")
        self.label()
        self.button()
        self.action()
        self.show()

    def label(self):
        self.label_1 = QLabel(self)
        self.label_1.setText("Hello")
        self.label_1.move(100, 100)

    def button(self):
        self.button_1 = QPushButton(self)
        self.button_1.setText("按下试试")
        self.button_1.move(100, 200)

    def action(self):
        self.button_1.clicked.connect(self.push_button)

    def push_button(self):
        self.label_1.setText("World!")
        self.label_1.adjustSize()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()
    sys.exit(app.exec_())

"""
1.Pycharm中从 文件>设置>项目>Python解释器 搜索并安装Nuitka
2.下载MinGW-W64 GCC-8.1.0,解压并将路径mingw64\bin添加环境变量并重启 下载地址:https://sourceforge.net/projects/mingw-w64/files/ 文件名:x86_64-win32-sjlj
3.打开Pycharm中的终端,执行命令 nuitka --mingw64 --standalone --windows-disable-console --show-progress --show-memory --plugin-enable=qt-plugins --output-dir=out hello_word.py
  执行过程中可能有Nuitka-Scons:INFO: Too old gcc 'C:\\mingw64\\bin\\gcc.exe' ((8, 1, 0) < (11, 2)) ignored!等提示,按提示下载所需文件即可。
4.完成,exe文件在out\hello_word.dist中,运行一下试试。
"""

发表回复 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Categories

  • 猫
  • Python
  • MySQL
  • Django
  • Html/CSS
  • JavaScript
  • Vue
  • RegExp
  • php
  • Practice
  • Virtualization
  • Linux
  • Windows
  • Android
  • NAS
  • Software
  • Hardware
  • Network
  • Router
  • Office
  • WordPress
  • SEO
  • English
  • Games
  • Recipes
  • living
  • Memorandum
  • Essays
  • 未分类

归档

©2015-2022 Alaica Blog support@alaica.com