当前位置:网站首页>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
边栏推荐
- 关于NodeJS中JSON5的相关配置和使用
- Prediction of tomorrow's trading limit of Low Frequency Quantization
- 微信小程序获取登录用户信息、openid和access_token
- 腾讯根据ip解析地址
- 使用Postman进行Mock测试
- 如何快速批量创建文本文档?
- visio安装报错 1:1935 2:{XXXXXXXX...
- SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
- 生成随机高质量符合高斯分布的随机数
- FBS(fman build system)打包
猜你喜欢
随机推荐
Jacob print word
Use of WiFi module based on wechat applet
VMware Workstation 无法连接到虚拟机。系统找不到指定的文件
Windos中安装labellmg教程
1256: bouquet for algenon
poi操作word模板替换数据并且导出word
Program compilation and debugging learning record
Jmeter安装教程以及我遇到的问题的解决办法
基于CM管理的CDH集群集成Phoenix
linux安装mysql后修改密码
Wechat applet obtains login user information, openid and access_ token
基于ibeacons三点定位(微信小程序)
封装logging模块
生成随机高质量符合高斯分布的随机数
websocket
Nacos+AspnetCore+Ocelot实战编码
RobotFramework 之 用例执行
微信小程序与低功耗蓝牙通信-接受硬件端发送来的数据(四)
POI operation word template replaces data and exports word
PATH环境变量