forked from PyQt5/PyQt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrctest1.py
44 lines (33 loc) · 1.29 KB
/
qrctest1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2018年05月01日
@author: Irony."[讽刺]
@site: http://alyl.vip, http://orzorz.vip, https://coding.net/u/892768447, https://github.com/892768447
@email: [email protected]
@file: qrctest1
@description:
'''
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QLabel
import res_rc # @UnusedImport @UnresolvedImport
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: [email protected]"
__Copyright__ = "Copyright (c) 2017 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class ImageView(QLabel):
def __init__(self, *args, **kwargs):
super(ImageView, self).__init__(*args, **kwargs)
self.resize(800, 600)
# 从资源文件res_rc.py中加载
# 转换命令pyrcc5 res.qrc -o res_rc.py
# 这种方式是从通过pyrcc5转换res.qrc为res_rc.py文件,可以直接import加载
# 此时可以通过路径:/images/head.jpg来访问
self.setPixmap(QPixmap(":/images/head.jpg"))
if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
app.aboutToQuit.connect(res_rc.qCleanupResources) # 退出时要清理资源
w = ImageView()
w.show()
sys.exit(app.exec_())