当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
微信小程序与低功耗蓝牙通信-往硬件端发送数据(三)
关于Jmeter启动闪退问题
基于CM管理的CDH集群集成Phoenix
使用itextpdf实现截取pdf文档第几页到第几页,进行分片
Nifi 快速安装及文件同步操作
基於CM管理的CDH集群集成Phoenix
Mock测试
Postman的安装使用及填坑心得
leetcode--977. Squares of a Sorted Array
服务器日志分析工具(识别,提取,合并,统计异常信息)
leetcode--380. O (1) time insertion, deletion and acquisition of random elements
Three point positioning based on ibeacons (wechat applet)
Promtail + Loki + Grafana 日志监控系统搭建
switch使用(微信小程序)
Ptorch classical convolutional neural network lenet
1到100号的灯开关问题
基于ibeacons签到系统
数据库DbVisualizer Pro报文件错误,导致数据连接失败
Chapter I review of e-commerce spike products
星界边境文本自动翻译机(高级版)使用说明