-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoverButton.py
66 lines (58 loc) · 2.63 KB
/
HoverButton.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
from PyQt5 import QtWidgets
from PyQt5.QtCore import pyqtSignal
import logs
import logging
class HoverButton(QtWidgets.QLabel):
clicked = pyqtSignal(str)
#Help from https://stackoverflow.com/questions/9384305/hover-issue-in-pyqt
def __init__(self, parent=None, loglevel=logging.DEBUG):
super(HoverButton, self).__init__(parent)
self.logger = logs.build_logger(__name__, loglevel)
self.loglevel = loglevel
self.setMouseTracking(True)
self.setStyleSheet('''
background-color: blue;
font-family: "Lucida Console", Monaco, monospace;
font-size: 22px;
color: white;
font-weight: 400;
text-decoration: none;
font-style: normal;
font-variant: normal;
text-transform: none;
''')
# Help from https://stackoverflow.com/questions/9384305/hover-issue-in-pyqt
def enterEvent(self, event):
self.logger.debug("enter")
self.setStyleSheet('''
background-color: #1C6EA4;
font-family: "Lucida Console", Monaco, monospace;
font-size: 22px;
color: white;
font-weight: 400;
text-decoration: none;
font-style: normal;
font-variant: normal;
text-transform: none;
''')
# Help from https://stackoverflow.com/questions/9384305/hover-issue-in-pyqt
def leaveEvent(self, event):
self.setStyleSheet('''
background-color: blue;
font-family: "Lucida Console", Monaco, monospace;
font-size: 22px;
color: white;
font-weight: 400;
text-decoration: none;
font-style: normal;
font-variant: normal;
text-transform: none;
''')
self.logger.debug("leave")
def mousePressEvent(self, event):
self.logger.debug("mousepressevent occurred, i am %s" % (self.objectName()))
self.clicked.emit(self.text())
QtWidgets.QLabel.mousePressEvent(self, event)
def hide(self) -> None:
self.logger.debug("actioning hide")
super(HoverButton, self).hide()