This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Test_GifWidget.py
80 lines (58 loc) · 2.15 KB
/
Test_GifWidget.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年10月15日
@author: Irony."[讽刺]
@email: [email protected]
@description:
'''
from __future__ import unicode_literals
from os.path import dirname, abspath
import sys
# 解决2.x到3.x的字符串问题
# 父级目录
sys.path.insert(0, dirname(dirname(abspath(sys.argv[0]))))
sys.path.insert(0, dirname(dirname(abspath(__file__))))
from PyQt5.QtCore import QMetaObject, pyqtSlot
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QFileDialog
from uilib.Utils import QT5
from uilib.widgets.GifWidget import GifWidget
if QT5():
from PyQt5.QtWidgets import QWidget, QApplication # @UnusedImport
else:
from PyQt4.QtGui import QWidget, QApplication # @UnusedImport @UnresolvedImport @Reimport
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: [email protected]"
__Copyright__ = "Copyright (c) 2015 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class Widget(QWidget):
def __init__(self):
super(Widget, self).__init__()
layout = QVBoxLayout(self)
self.gif = GifWidget(self, "../images/yin.gif")
startBtn = QPushButton("开始", self)
startBtn.setObjectName("startBtn")
stopBtn = QPushButton("停止", self)
stopBtn.setObjectName("stopBtn")
changeBtn = QPushButton("改变第二个图", self)
changeBtn.setObjectName("changeBtn")
layout.addWidget(self.gif)
layout.addWidget(startBtn)
layout.addWidget(stopBtn)
layout.addWidget(changeBtn)
QMetaObject.connectSlotsByName(self) # 通过objectname注册信号
@pyqtSlot() # 这里主要是解决qt5和qt4的区别(不加这个会出现点击两次的效果)
def on_startBtn_clicked(self):
self.gif.start()
@pyqtSlot()
def on_stopBtn_clicked(self):
self.gif.stop()
@pyqtSlot()
def on_changeBtn_clicked(self):
fn, _ = QFileDialog.getOpenFileName(self, "选择动态图片", None, "Gif Files (*.gif)")
if fn:
self.gif.setPath(fn)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Widget()
window.show()
sys.exit(app.exec_())