当前位置:网站首页>Pyqt5 rapid development and practice 3.6 packaging resource files
Pyqt5 rapid development and practice 3.6 packaging resource files
2022-07-26 19:38:00 【Ding Jiaxiong】
PyQt5 Rapid development and actual combat
List of articles
3. The first 3 Chapter Qt Designer Use
3.6 Package resource files
Use PyQt5 There are two main ways for the generated application to reference image resources :
- Convert the resource file to Python file , Then the reference Python file
- Reference external image resources through relative paths in the program
3.6.1 Use Qt Designer Load resource file
New resource file apprcc.qrc

Create a new simple form

Resource editing

Add resources

apprcc.qrc The file automatically adds code

3.6.2 Use resource files in forms
Add one label label , change pixmap attribute

ui turn py

Call module CallMainWin02.py

Here we have to put .qrc The document is also changed to py file
And then call

import sys
from PyQt5.QtWidgets import QApplication,QMainWindow
from MainWin02 import Ui_Form
class MyMainWindow(QMainWindow,Ui_Form):
def __init__(self,parent = None):
super(MyMainWindow,self).__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
from pyqt5_plugins.examples.exampleqmlitem import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
myWin = MyMainWindow()
myWin.show()
sys.exit(app.exec_())
function

3.6.3 Convert resource files


3.6.4 Import .py Resource file
It has been operated in advance here .
Finally, everything in the script is normal , You can see the imported image resources in the window .
边栏推荐
- Synchronized theory
- PADS画2.54mm排针
- 安全测试与功能测试、渗透测试你知道有什么区别吗?
- Volatile keyword of JVM memory model
- 通过源码深度分析线程池中Worker线程的执行流程
- EN 1504-6 products for protection and repair of concrete structures - reinforcement anchorage - CE certification
- Save gas chitoken usage
- 周末看点回顾|数字人民币产业联盟成立;中国移动宣布:和飞信将停止服务…
- [yolov5] - detailed version of training your own dataset, nanny level learning, logging, hand-in-hand tutorial
- JVM内存模型之Volatile关键字
猜你喜欢

Advantages of advanced anti DDoS IP in Hong Kong and which industries are suitable for use

Reentrantlock learning - lock release process

基于ABP实现DDD--领域逻辑和应用逻辑

客户案例 | 聚焦流程体验,助银行企业APP迭代

Turn off win10 automatic update completely

All you want to know about interface testing is here

ReentrantLock学习之公平锁过程

2022 build enterprise level data governance system

安全测试与功能测试、渗透测试你知道有什么区别吗?

C # create and read dat file cases
随机推荐
什么是服务器集群?海外服务器集群的优势?
SEO、客户端渲染‘、服务端渲染、搜索引擎的理解
TB 117-2013 US Federal mandatory regulations
Software process that testers must know
基于华为云 IOT 设计智能称重系统 (STM32)【二】结尾有资料
香港高防IP优势及哪些行业适合使用
Synchronized theory
C language - Introduction - syntax - string (11)
The inventory of chips in the United States is high, and the shipment of chips in China has increased rapidly and the import of 28.3 billion chips has been greatly reduced. TSMC has a showdown
那些年解的疑难性能问题 --- ext4碎片整理
基于ABP实现DDD--领域逻辑和应用逻辑
UIAutomator2常用类之UiObject2
Vs2019 export import configuration
Image preview embedding location of blog maintenance record
C#创建及读取DAT文件案例
Save gas chitoken usage
B站SRE负责人亲述 713事故后的多活容灾建设|TakinTalks大咖分享
线性代数第3章向量
【MySQL必知必会】 日志Log详解
Weekend highlights review | establishment of digital RMB industry alliance; China Mobile announced that hefeixin will stop its service