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
/
Copy pathTest_PushButton.py
76 lines (61 loc) · 2.64 KB
/
Test_PushButton.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年10月4日
@author: Irony."[讽刺]
@email: [email protected]
@description: TestPushButton
'''
from __future__ import unicode_literals
# 解决2.x到3.x的字符串问题
from os.path import dirname, abspath
import sys
# 父级目录
sys.path.insert(0, dirname(dirname(abspath(sys.argv[0]))))
sys.path.insert(0, dirname(dirname(abspath(__file__))))
from uilib.Utils import QT5
from uilib.widgets.PushButton import PushButton
if QT5():
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout # @UnresolvedImport @UnusedImport
else:
from PyQt4.QtGui import QWidget, QVBoxLayout, QApplication # @Reimport @UnresolvedImport
__Author__ = "By: Irony.\"[讽刺]\nQQ: 892768447\nEmail: [email protected]"
__Copyright__ = "Copyright (c) 2015 Irony.\"[讽刺]"
__Version__ = "Version 1.0"
class TestPushButton(QWidget):
def __init__(self):
super(TestPushButton, self).__init__()
self.setMinimumWidth(300)
defaultButton = PushButton(self, "default")
defaultButton.setFontSize(33)
# 这里通过的更新qss样式代码来设置字体大小
# 当然也可以用QFont就不用updateStyle
defaultButton.updateStyle(PushButton.DEFAULT_STYLE)
primaryButton = PushButton(self, "primary")
primaryButton.setBorderRadius(15) # 修改圆角
primaryButton.setPrimaryStyle(True) # 使用primary样式
primaryButton.updateStyle(PushButton.PRIMARY_STYLE) # 需要更新
# 也可以这样设置样式
warningButton = PushButton(self, "warning", style = PushButton.WARNING_STYLE)
warningButton.setMinHeight(55) # 修改最小高度
warningButton.updateStyle(PushButton.WARNING_STYLE)
dangerButton = PushButton(self, "danger", style = PushButton.DANGER_STYLE)
successButton = PushButton(self, "success", style = PushButton.SUCCESS_STYLE)
inverseButton = PushButton(self, "inverse", style = PushButton.INVERSE_STYLE)
infoButton = PushButton(self, "info", style = PushButton.INFO_STYLE)
disableButton = PushButton(self, "disable")
disableButton.setDisabled(True)
layout = QVBoxLayout(self)
layout.addWidget(defaultButton)
layout.addWidget(primaryButton)
layout.addWidget(warningButton)
layout.addWidget(dangerButton)
layout.addWidget(successButton)
layout.addWidget(inverseButton)
layout.addWidget(infoButton)
layout.addWidget(disableButton)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = TestPushButton()
window.show()
sys.exit(app.exec_())