当前位置:网站首页>FBS(fman build system)打包
FBS(fman build system)打包
2022-04-23 14:01:00 【清新的草莓】
FBS(fman build system)打包
适用于 Pyside2 和 PyQt5 项目( PySide6 和 PyQt6 需付费)
fbs 是一个基于 Python 的构建工具,用于使用 PyQt或 PySide的桌面应用程序。它获取您的源代码并将其转换为 Windows、Mac 或 Linux 上的独立可执行文件。它还允许您为您的应用程序创建安装程序。
- 运行环境:fbs 在 Windows、macOS 和 Linux(Ubuntu、Arch 或 Fedora)上运行。您还需要 Python 3。fbs 的免费版本支持 Python 3.5 和 3.6。以后的 Python 版本需要fbs Pro。
安装
在当前目录下创建虚拟环境:python3 -m venv venv
然后,使用以下命令之一激活环境:
# On Mac/Linux:
source venv/bin/activate
# On Windows:
call venv\scripts\activate.bat
接下来用pip安装 fbs 及其依赖项:
pip install fbs PyQt6
您可以类似地安装PySide6, PyQt5或PySide2. 使用 PyQt6 或 PySide6 需要 fbs Pro
命令
fbs startproject # 新建项目
App Name: # 输入名称
Author: # 输入作者名称
Mac bundle identifier:# 输入 Mac 绑定的标识符
如安装了依赖环境,则可运行:fbs run
fbs freeze # 打包成正式项目
fbs freeze --debug # 打包测试版本
目录结构
fbs 项目使用以下目录结构。括号(...)
表示文件是可选的。
-src/
-build
-settings/
-base.json
-(mac.json)
-...
-main
-icons
-python
-(resources)
-(freeze)
-(installer/)
-(windows/)
-(mac/)
-...
-(requirements)
-(base.txt)
-(linux.txt)
-...
- 当您使用 fbs 时,您会看到它target/在上述目录旁边的名为 的文件夹中生成输出。它还可以创建一个名为 cache/ 的文件夹,您可以随时删除该文件夹。
你的 Python 代码
为了让 fbs 找到它,您的 Python 源代码必须位于src/main/python/
. 在那里,您需要一个脚本来启动您的应用程序 ApplicationContext。src/main/python/main.py
运行时 生成的默认脚本 fbs startproject
如下所示:
from fbs_runtime.application_context.PyQt6 import ApplicationContext
from PyQt6.QtWidgets import QMainWindow
import sys
if __name__ == '__main__':
appctxt = ApplicationContext() # 1. 实例化 ApplicationContext
window = QMainWindow()
window.resize(250, 150)
window.show ()
exit_code = appctxt.app.exec() # 2. 调用 appctxt.app.exec()
sys.exit(exit_code)
随着您的应用程序变得越来越复杂,您可能希望将其源代码拆分到多个文件中。在这种情况下,建议您将它们全部放在一个包装中。例如,如果您的应用程序名为 My App,则可以调用包my_app
,目录结构如下所示:
src/main/python/
my_app/
__init__.py
main.py
module_a.py
module_b.py
资源文件
只需将它们放在以下子文件夹之一中 src/main/resources/
:
-base/ # 适用于所有操作系统所需的文件
-windows/ # 仅适用于 Windows 所需的文件
-mac/ # 同理
-linux- # 同理
- 当您调用 时fbs freeze,fbs 会自动将适用的文件复制到文件夹内您应用的冻结目录中target/。
- 要从 Python 代码访问资源文件,只需调用 ApplicationContext.get_resource(*rel_path) ,此方法返回 具有给定名称或(相对)路径的资源文件的绝对路径。
- src/main/resources/base/image.jpg 并且调用 get_resource('image.jpg'),则此方法返回图像的绝对路径。如果给定文件不存在,则引发 FileNotFoundError。
版权声明
本文为[清新的草莓]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_36540244/article/details/124316114
边栏推荐
- Basic SQL query and learning
- BUG_me
- groutine
- 剑南春把文字游戏玩明白了
- Neuron and neural network
- 项目中遇到的问题(五)操作Excel接口Poi的理解
- Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
- About note 1
- UNIX final exam summary -- for direct Department
- Android 面试主题集合整理
猜你喜欢
The latest development of fed digital currency
Modify the Jupiter notebook style
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
Reading notes: meta matrix factorization for federated rating predictions
Node接入支付宝开放平台的沙箱实现支付功能
cnpm的诡异bug
Ptorch classical convolutional neural network lenet
STM32学习记录0007——新建工程(基于寄存器版)
随机推荐
Analysis and understanding of atomicintegerarray source code
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
L2-024 部落 (25 分)
Kettle--控件解析
linux MySQL数据定时dump
JS 力扣刷题 103. 二叉树的锯齿形层序遍历
[code analysis (2)] communication efficient learning of deep networks from decentralized data
Express middleware ③ (custom Middleware)
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
mysql新表,自增id长达20位,原因竟是......
专题测试05·二重积分【李艳芳全程班】
redis如何解决缓存雪崩、缓存击穿和缓存穿透问题
Universal template for scikit learn model construction
SQL learning window function
神经元与神经网络
Go语言 RPC通讯
websocket
1256:献给阿尔吉侬的花束
Multithreading
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘