This repository was archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathradiobutton.py
71 lines (54 loc) · 2.85 KB
/
radiobutton.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
from .checkable import *
class QMaterialRadioButton(QMaterialCheckable):
def __init__(self, parent: QWidget = None, **kwargs):
QMaterialCheckable.__init__(self, parent, **kwargs)
self.setAutoExclusive(True)
self.setCheckedIcon(QIcon(":/toggle/radio_button_checked.svg"))
self.setUncheckedIcon(QIcon(":/toggle/radio_button_unchecked.svg"))
self.uncheckedState.assignProperty(self.m_checkedIcon, "_iconSize", 0)
self.uncheckedState.assignProperty(self.m_uncheckedIcon, "_iconSize", 24)
self.disabledUncheckedState.assignProperty(self.m_checkedIcon, "_iconSize", 0)
self.disabledUncheckedState.assignProperty(
self.m_uncheckedIcon, "_iconSize", 24
)
self.checkedState.assignProperty(self.m_uncheckedIcon, "_iconSize", 0)
self.checkedState.assignProperty(self.m_checkedIcon, "_iconSize", 24)
self.disabledCheckedState.assignProperty(self.m_uncheckedIcon, "_iconSize", 0)
self.disabledCheckedState.assignProperty(self.m_checkedIcon, "_iconSize", 24)
self.uncheckedState.assignProperty(self.m_checkedIcon, "_opacity", 0)
self.uncheckedState.assignProperty(self.m_uncheckedIcon, "_opacity", 1)
self.checkedState.assignProperty(self.m_uncheckedIcon, "_opacity", 0)
self.checkedState.assignProperty(self.m_checkedIcon, "_opacity", 1)
self.m_checkedIcon.setIconSize(0)
self.checkedState.assignProperty(
self.m_checkedIcon, "_color", self.checkedColor()
)
self.checkedState.assignProperty(
self.m_uncheckedIcon, "_color", self.uncheckedColor()
)
self.uncheckedState.assignProperty(
self.m_uncheckedIcon, "_color", self.uncheckedColor()
)
animation = QPropertyAnimation(self.m_checkedIcon, b"_iconSize", self)
animation.setDuration(250)
self.stateMachine.addDefaultAnimation(animation)
animation = QPropertyAnimation(self.m_uncheckedIcon, b"_iconSize", self)
animation.setDuration(250)
self.stateMachine.addDefaultAnimation(animation)
animation = QPropertyAnimation(self.m_uncheckedIcon, b"_opacity", self)
animation.setDuration(250)
self.stateMachine.addDefaultAnimation(animation)
animation = QPropertyAnimation(self.m_checkedIcon, b"_opacity", self)
animation.setDuration(250)
self.stateMachine.addDefaultAnimation(animation)
def setupProperties(self) -> None:
QMaterialCheckable.setupProperties(self)
self.m_checkedState.assignProperty(
self.m_checkedIcon, "_color", self.checkedColor()
)
self.m_checkedState.assignProperty(
self.m_uncheckedIcon, "_color", self.uncheckedColor()
)
self.m_uncheckedState.assignProperty(
self.m_uncheckedIcon, "_color", self.uncheckedColor()
)