forked from hflake13/SigicomDataHandler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglowButton.py
179 lines (146 loc) · 5.84 KB
/
glowButton.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 09:39:59 2019
@author: hayden.flake
"""
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class dragView(QGraphicsView):
def __init__(self,parent):
super(dragView,self).__init__()
self.parent=parent
def mousePressEvent(self,event):
self.m_old_pos = event.globalPos();
self.m_mouse_down = event.button()== Qt.LeftButton;
def mouseMoveEvent(self,event):
if event.buttons()==Qt.LeftButton:
currPos=self.parent.mapToGlobal(self.parent.pos())
globalPos=event.globalPos()
diff=globalPos-self.m_old_pos
newPos=self.parent.mapFromGlobal(currPos+diff)
self.m_old_pos=event.globalPos()
self.parent.move(newPos)
def mouseReleaseEvent(self,event):
self.m_mouse_down=False;
class coolButton(QPushButton):
def __init__(self,text):
super(coolButton,self).__init__()
self.setText(text)
self.setObjectName('coolButton')
self.setStyleSheet('#coolButton{border-radius:4px; padding: 5px; \
color: white; selection-color: rgb(30,70,120);background-color:rgb(66,134,244)} #coolButton:hover{background-color:rgb(75,150,250)}')
self.effect=QGraphicsDropShadowEffect()
self.effect.setColor(QColor(66,134,244))
self.effect.setOffset(0,0)
self.effect.setBlurRadius(20)
self.setGraphicsEffect(self.effect)
#self.update()
def update(self):
if not self.isEnabled():
self.effect.setBlurRadius(0)
else:
self.effect.setBlurRadius(20)
def changeEvent(self,event):
if event.type()==98:
if not self.isEnabled():
self.effect.setBlurRadius(0)
self.setStyleSheet('#coolButton:disabled{background-color: rgb(87,88,89); color:grey} #coolButton:hover{background-color:rgb(75,150,250)}')
else:
self.effect.setBlurRadius(20)
self.setStyleSheet('#coolButton:enabled{background-color:rgb(66,134,244);color: white} #coolButton:hover{background-color:rgb(75,150,250)}')
def mousePressEvent(self,event):
if self.isEnabled():
self.effect.setColor(QColor(247, 34, 73))
#self.setStyleSheet('#coolButton:pressed{background-color:rgb(33,70,120)}')
def mouseReleaseEvent(self,event):
if self.isEnabled():
self.effect.setColor(QColor(66,134,244))
#self.setStyleSheet('#colorButton:!pressed{background-color:rgb(66,134,244)}')
self.clicked.emit()
class glowButton(QLabel):
def __init__(self,pixmap,pixHeight,color):
super(glowButton,self).__init__()
self.pixmap=pixmap
#self.pixmap=QImage(pixmap)
self.pixHeight=pixHeight
self.color=QColor(color[0],color[1],color[2])
self.partner=None
self.negative()
self.initWidget()
self.state=True
def initWidget(self):
self.pixmap=self.pixmap.scaledToHeight(self.pixHeight)
#self.setCentralWidget(self.pixmap)
self.setPixmap(self.pixmap)
self.effect = QGraphicsDropShadowEffect()
self.effect.setColor(self.color)
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.setGraphicsEffect(self.effect)
self.setMask(self.pixmap.mask())
def setChecked(self,val):
if self.isChecked()==val:
return
self.toggle()
def negative(self):
img=QImage(self.pixmap)
img.invertPixels()
self.pixmap=QPixmap(img)
def mousePressEvent(self,event):
self.toggle()
print('glowButton state is: {}'.format(str(self.state)))
def isChecked(self):
return self.state
def toggle(self):
if not self.partner:
if self.state:
self.state=False
else:
self.state=True
self.update()
else:
if self.state and not self.partner.state:
self.state=False
self.partner.state=True
else:
if self.state:
self.state=False
else:
self.state=True
self.update()
self.partner.update()
def update(self):
if self.state:
self.effect.setBlurRadius(20)
else:
self.effect.setBlurRadius(0)
def pairWith(self,partner):
self.partner=partner
self.partner.partner=self
class fontWindow(QMainWindow):
def __init__(self):
super(fontWindow,self).__init__()
self.view=QWidget()
self.scrollView=QScrollArea()
self.scrollView.setWidget(self.view)
self.scrollView.setWidgetResizable(True)
self.setCentralWidget(self.scrollView)
self.mainLayout=QVBoxLayout()
self.view.setLayout(self.mainLayout)
lbl=QLabel('Here are the fonts:')
self.mainLayout.addWidget(lbl)
name='a'
for font in QFontDatabase().families():
#for font in range(0,20):
print(font)
self.newLabel=QLabel(str(font))
self.newLabel.setMinimumHeight(15)
#newName=font.replace(' ','')
self.newLabel.setObjectName(name)
self.newLabel.setStyleSheet('#'+name+'{font: '+font+'}')
name+='a'
self.mainLayout.addWidget(self.newLabel)
#self.view.setStyleSheet('QLabel{font: Vladimir Script}')
def show_window(self):
self.show()