当前位置:网站首页>FBS (fman build system) packaging
FBS (fman build system) packaging
2022-04-23 14:07:00 【Fresh strawberries】
FBS(fman build system) pack
Apply to Pyside2 and PyQt5 project ( PySide6 and PyQt6 Pay for )
fbs It's based on Python Build tools for , For the use of PyQt or PySide The desktop application . It takes your source code and converts it into Windows、Mac or Linux Stand alone executable on . It also allows you to create an installer for your application .
- Running environment :fbs stay Windows、macOS and Linux(Ubuntu、Arch or Fedora) Up operation . You also need Python 3.fbs Free version support for Python 3.5 and 3.6. After the Python Version needs to be fbs Pro.
install
Create a virtual environment in the current directory :python3 -m venv venv
then , Use one of the following commands to activate the environment :
# On Mac/Linux:
source venv/bin/activate
# On Windows:
call venv\scripts\activate.bat
Next use pip install fbs And its dependencies :
pip install fbs PyQt6
You can install... Similarly PySide6, PyQt5 or PySide2. Use PyQt6 or PySide6 need fbs Pro
command
fbs startproject # New projects
App Name: # Enter a name
Author: # Enter the author name
Mac bundle identifier:# Input Mac Bound identifier
If the dependent environment is installed , Then it can run :fbs run
fbs freeze # Packaged as a formal project
fbs freeze --debug # Package test version
Directory structure
fbs The project uses the following directory structure . Brackets (...)
Indicates that the file is optional .
-src/
-build
-settings/
-base.json
-(mac.json)
-...
-main
-icons
-python
-(resources)
-(freeze)
-(installer/)
-(windows/)
-(mac/)
-...
-(requirements)
-(base.txt)
-(linux.txt)
-...
- When you use fbs when , You will see it target/ The name next to the above directory is Generate output in the folder of . It can also create a file called cache/ Folder , You can delete this folder at any time .
Yours Python Code
In order to make fbs Find it , Your Python The source code must be in src/main/python/
. There? , You need a script to start your application ApplicationContext.src/main/python/main.py
Runtime Generated default script fbs startproject
As shown below :
from fbs_runtime.application_context.PyQt6 import ApplicationContext
from PyQt6.QtWidgets import QMainWindow
import sys
if __name__ == '__main__':
appctxt = ApplicationContext() # 1. Instantiation ApplicationContext
window = QMainWindow()
window.resize(250, 150)
window.show ()
exit_code = appctxt.app.exec() # 2. call appctxt.app.exec()
sys.exit(exit_code)
As your application becomes more and more complex , You may want to split its source code into multiple files . under these circumstances , It is recommended that you put them all in one package . for example , If your application is named My App, Then you can call the package my_app
, The directory structure is shown below :
src/main/python/
my_app/
__init__.py
main.py
module_a.py
module_b.py
Resource file
Just put them in one of the following subfolders src/main/resources/
:
-base/ # Files required for all operating systems
-windows/ # Only applicable to Windows Documents required
-mac/ # Empathy
-linux- # Empathy
- When you call when fbs freeze,fbs The applicable files will be automatically copied to the frozen directory of your application in the folder target/.
- From you to Python Code access resource files , Just call ApplicationContext.get_resource(*rel_path) , This method returns With the given name or ( relative ) The absolute path of the resource file .
- src/main/resources/base/image.jpg And call get_resource('image.jpg'), This method returns the absolute path of the image . If the given file does not exist , The cause FileNotFoundError.
版权声明
本文为[Fresh strawberries]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400483455.html
边栏推荐
猜你喜欢
PyMySQL
Wechat applet initializes Bluetooth, searches nearby Bluetooth devices and connects designated Bluetooth (I)
帆软中使用if else 进行判断-使用标题条件进行判断
查询2013年到2021年的数据,只查询到2020的数据,遇到了这个问题所进行的解决办法
基於CM管理的CDH集群集成Phoenix
Promtail + Loki + Grafana 日志监控系统搭建
Wechat applet positioning and ranging through low-power Bluetooth device (2)
Windos中安装labellmg教程
Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动
Jmeter安装教程以及我遇到的问题的解决办法
随机推荐
接口文档yaml
MySQL 修改主数据库
Logging module
Easyexcel读取excel表地理位置数据,按中文拼音排序
Understand the concepts of virtual base class, virtual function and pure virtual function (turn)
gzip和gunzip 解压参数详解
Pycharm连接远程服务器并实现远程调试
生成随机高质量符合高斯分布的随机数
关于pthread多线程一些好文章
腾讯根据ip解析地址
微信小程序与低功耗蓝牙通信-往硬件端发送数据(三)
ActiveMq基础知识
星界边境文本自动翻译机使用说明
Wechat applet communicates with low-power Bluetooth - sending data to hardware (III)
Interesting talk about network protocol
关于NodeJS中JSON5的相关配置和使用
JSP学习2
微信小程序通过低功耗蓝牙设备进行定位及测距(二)
使用Postman进行Mock测试
基于CM管理的CDH集群集成Phoenix