当前位置:网站首页>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
边栏推荐
- linux安装mysql后修改密码
- Nacos+AspnetCore+Ocelot实战编码
- STM32学习记录0007——新建工程(基于寄存器版)
- SQL learning window function
- 读了一篇博客,重新理解闭包整理一下
- Modify the Jupiter notebook style
- smart-doc + torna生成接口文档
- Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
- China creates vast research infrastructure to support ambitious climate goals
- Interesting talk about network protocol
猜你喜欢
随机推荐
Universal template for scikit learn model construction
Crontab timing task output generates a large number of mail and runs out of file system inode problem processing
收藏博客贴
The art of automation
服务器中挖矿病毒了,屮
【项目】小帽外卖(八)
Analysis and understanding of atomicintegerarray source code
Leetcode? The first common node of two linked lists
JS force deduction brush question 102 Sequence traversal of binary tree
解决方案架构师的小锦囊 - 架构图的 5 种类型
Postman reference summary
New关键字的学习和总结
神经元与神经网络
What is the difference between blue-green publishing, rolling publishing and gray publishing?
[code analysis (3)] communication efficient learning of deep networks from decentralized data
smart-doc + torna生成接口文档
函数只执行第一次的执行一次 once函数
腾讯根据ip解析地址
Yarn online dynamic resource tuning
Nodejs安装及环境配置
![[VMware] address of VMware Tools](/img/0e/13f263bd69c8224f7c755258d94777.png)







![Special test 05 · double integral [Li Yanfang's whole class]](/img/af/0d52a6268166812425296c3aeb8f85.png)
