当前位置:网站首页>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
边栏推荐
猜你喜欢
Chrome插件 之 Selenium IDE、XPath 安装
Wechat applet obtains login user information, openid and access_ token
Idea控制台乱码解决
Detailed tutorial on the use of setinterval timing function of wechat applet
MYSQL 主从同步避坑版教程
基于ibeacons签到系统
更改plsql工具栏的图标大小
Check in system based on ibeacons
帆软中单元格中隔行变色以及数量大于100字体变大变红设置
Indoor and outdoor map switching (indoor three-point positioning based on ibeacons)
随机推荐
smart-doc + torna生成接口文档
PATH环境变量
数据库DbVisualizer Pro报文件错误,导致数据连接失败
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
Nacos+AspnetCore+Ocelot实战编码
Restful WebService和gSoap WebService的本质区别
基于CM管理的CDH集群集成Phoenix
关于stream流,浅记一下------
Program compilation and debugging learning record
RobotFramework 之 公共变量
CentOS mysql多实例部署
帆软调用动态传参的方法,在标题中设置参数
Wechat applet obtains login user information, openid and access_ token
对List集合进行分页
Jmeter安装教程以及我遇到的问题的解决办法
Wechat applet input hidden and inoperable settings
报表FCRA考试题集及答案(错了11题)
pthread_ Why does self() repeat
Programming travel function
SQL数据库