当前位置: 首页 > news >正文

PySide6 pyside6-deploy 命令 Linux 部署

文章目录

    • PySide6 Linux 部署
      • 写在前边
        • 参考
      • 笔者环境
      • 前置条件
      • 部署案例
        • 部署命令
      • 运行效果

PySide6 Linux 部署

写在前边

Qt是非常强大的跨平台框架,Qt for Python(PySide/PyQt)作为QtPython提供的接口,理论上也可以部署到任意平台上边。这篇文章就是将PySide6``Python实现的代码部署到Linux环境。 其部署出的文件是一个.bin文件。

pyside6-deployQt for Python 的部署工具,基于Nuitka

Ccache 是一个编译器缓存。它通过缓存以前的编译并检测何时再次执行相同的编译来加快重新编译 。

参考

pyside6-deploy:Qt for Python 的部署工具¶

Nuitka the Python Compiler

Ccache简介

笔者环境

  • 系统环境: Fedora Linux 42 (Workstation Edition)
  • Python环境: Python 3.11.X
  • Conda/Minconda环境:conda 25.7.0
  • PySide环境: PySide6.10.0

前置条件

sudo dnf install gcc gcc-c++ ccache

Conda安装

conda install libpython-static

部署案例

Hello.py

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
from __future__ import annotations"""
hello.py
--------This simple script shows a label with changing "Hello World" messages.
It can be used directly as a script, but we use it also to automatically
test PyInstaller or Nuitka. See testing/wheel_tester.py .When compiled with Nuitka or used with PyInstaller, it automatically
stops its execution after 2 seconds.
"""import sys
import random
import platform
import timefrom PySide6.QtWidgets import (QApplication, QLabel, QPushButton,QVBoxLayout, QWidget)
from PySide6.QtCore import Slot, Qt, QTimeris_compiled = "__compiled__" in globals()   # Nuitka
auto_quit = "Nuitka" if is_compiled else "PyInst"class MyWidget(QWidget):def __init__(self):super().__init__()self.hello = ["Hallo Welt", "你好,世界", "Hei maailma","Hola Mundo", "Привет мир"]self.button = QPushButton("Click me!")self.text = QLabel(f"Hello World auto_quit={auto_quit}")self.text.setAlignment(Qt.AlignmentFlag.AlignCenter)self.layout = QVBoxLayout()self.layout.addWidget(self.text)self.layout.addWidget(self.button)self.setLayout(self.layout)# Connecting the signalself.button.clicked.connect(self.magic)@Slot()def magic(self):self.text.setText(random.choice(self.hello))if __name__ == "__main__":print("Start of hello.py       ", time.ctime())print("  sys.version         = ", sys.version.splitlines()[0])# Nuitka and hence pyside6-deploy fails on Python versions <= 3.9# when this module is usedif sys.version_info.minor > 9:print("  platform.platform() = ", platform.platform())app = QApplication()widget = MyWidget()widget.resize(800, 600)widget.show()if auto_quit:milliseconds = 2 * 1000  # run 2 secondQTimer.singleShot(milliseconds, app.quit)retcode = app.exec()print("End of hello.py        ", time.ctime())sys.exit(retcode)
部署命令
pyside6-deploy /path/to/hello.py

运行效果

在这里插入图片描述

http://www.dtcms.com/a/529056.html

相关文章:

  • 网站内的搜索怎么做的学校网站建设情况报告
  • 电脑建立网站朝阳区手机网站建设服务
  • 谷歌商店下载APK教程,先下载谷歌三件套,再直接从 Google Play 下载 APK 文件?
  • Spring中事务的传播行为
  • 将镜像推送到 Docker Hub 或私有仓库
  • 做qq图片的网站吗wordpress没有链接地址
  • 面向模块的综合技术之重定时优化(六)
  • 社交模板网站建设成都青羊网站建设
  • Android 数据持久化(SharedPreferences)
  • 四、高效注意力机制与模型架构
  • 沧州做网站公司兰州网站建站
  • C++ STL:string类(1) |了解string|编码|常用接口|迭代器|算法查找|auto|范围for
  • ESP32 Linux 开发环境
  • 网站建设全国排名alexa排名前三十
  • 声乐基础知识学习
  • Redis底层原理-持久化【详细易懂】
  • 现在建网站可以拖拉式的吗深圳住房建设网站
  • 流量打不开网站怎么办营销型企业网站 网络服务
  • 如何用ps做网站ui如何在云主机上建设网站
  • 营销网站建设818gx做商城网站多少钱
  • 【C/C++】动态加载(dlopen)和直接链接 库的区别
  • 集团内部协同项目管理模式整理表
  • 基于yolov11的机场跑道异物检测系统python源码+pytorch模型+训练数据集+精美GUI界面
  • 【开题答辩全过程】以 滨海游泳馆管理系统为例,包含答辩的问题和答案
  • 阿里云网站实名认证设备租赁业务网站如何做
  • 2025年9月电子学会全国青少年软件编程等级考试(scratch图形化四级)真题及答案
  • 中国万网icp网站备案专题wordpress播放器问题
  • MATLAB图形绘制基础(一)二维图形
  • 软件开发和网站建设泰安网站设计
  • 一文读懂 AUTOSAR 中的 CAN 模块:通俗图解与发送接收全流程