-
Notifications
You must be signed in to change notification settings - Fork 217
/
06-QLabel-内容操作.py
49 lines (35 loc) · 1.35 KB
/
06-QLabel-内容操作.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
45
46
47
48
49
import sys
from PyQt5.Qt import *
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QLabel-内容操作")
self.resize(500, 500)
self.move(400, 250)
self.setup_ui()
def setup_ui(self):
label = QLabel(self)
label.move(100, 100)
# --------文本类型----------
# label.setText("<img src='../Icons/OS_Ubuntu_128px.ico' width=80 height=80>")
# --------数值类型---------
# label.setNum(888.88)
# ---------图形图像--------
# label.setPixmap(QPixmap('../Icons/OS_Ubuntu_128px.ico')) # 用于展示QPixmap,对图像显示有优化
# pic = QPicture() # 创建绘画设备(画布)
# painter = QPainter(pic)
# painter.setBrush(QBrush(QColor(0, 128, 128))) # 设置画刷
# painter.drawEllipse(0, 0, 200, 200) # 绘制椭圆
# label.setPicture(pic) # 用于展示QPicture
# -------动图----------
movie = QMovie("../Icons/打墙火柴人.gif")
label.setMovie(movie)
movie.setSpeed(200) # 播放速度(百分比)
movie.start()
# movie.setPaused(True) # 暂停播放
# label.clear() # 清空
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())