当前位置:网站首页>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
边栏推荐
- How does redis solve the problems of cache avalanche, cache breakdown and cache penetration
- Analysis and understanding of atomicintegerarray source code
- 联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
- 读了一篇博客,重新理解闭包整理一下
- 记录一个奇怪的bug:缓存组件跳转之后出现组件复制
- JS force deduction brush question 102 Sequence traversal of binary tree
- Record a strange bug: component copy after cache component jump
- Quartus prime hardware experimental development (de2-115 board) experiment 1 CPU instruction calculator design
- STM32 learning record 0007 - new project (based on register version)
- Pytorch 经典卷积神经网络 LeNet
猜你喜欢
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
How does redis solve the problems of cache avalanche, cache breakdown and cache penetration
Decentralized Collaborative Learning Framework for Next POI Recommendation
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
蓝绿发布、滚动发布、灰度发布,有什么区别?
第一章 电商秒杀商品回顾
Postman reference summary
STM32 learning record 0007 - new project (based on register version)
STM32学习记录0007——新建工程(基于寄存器版)
Un modèle universel pour la construction d'un modèle d'apprentissage scikit
随机推荐
记录一个奇怪的bug:缓存组件跳转之后出现组件复制
freeCodeCamp----time_ Calculator exercise
Oracle alarm log alert Chinese trace and trace files
[code analysis (4)] communication efficient learning of deep networks from decentralized data
redis如何解决缓存雪崩、缓存击穿和缓存穿透问题
Android篇:2019初中级Android开发社招面试解答(中
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
JMeter pressure test tool
收藏博客贴
函数只执行第一次的执行一次 once函数
Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
Chapter 15 new technologies of software engineering
[code analysis (5)] communication efficient learning of deep networks from decentralized data
STM32 learning record 0007 - new project (based on register version)
Reading notes: meta matrix factorization for federated rating predictions
Leetcode brush question 𞓜 13 Roman numeral to integer
Interesting talk about network protocol
centOS下mysql主从配置
腾讯根据ip解析地址
Special test 05 · double integral [Li Yanfang's whole class]