-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainWindow.py
55 lines (45 loc) · 1.76 KB
/
mainWindow.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
import sys
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from screeninfo import get_monitors
class MainWindow(QMainWindow):
def __init__(self, w, h):
QMainWindow.__init__(self)
self.setWindowFlags(
QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.FramelessWindowHint |
QtCore.Qt.X11BypassWindowManagerHint
)
self.setGeometry(
QtWidgets.QStyle.alignedRect(
QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
QtCore.QSize(w, h),
QtWidgets.qApp.desktop().availableGeometry()
)
)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents, True)
self.rectangles = []
# Need to add rectangles with locations to cover
# then update painter and it should be over the word we want
def paintEvent(self, event):
qp = QtGui.QPainter()
qp.begin(self)
# Change color here to actually cover after debugging is done
qp.setBrush(QtGui.QBrush(QtGui.QColor(200, 0, 100, 150), QtCore.Qt.SolidPattern))
qp.drawRects(self.rectangles)
qp.end()
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Q:
print("Exiting")
QtWidgets.qApp.quit()
exit()
def addRect(self, x, y, w, h):
self.rectangles.append(QtCore.QRect(x, y, w, h))
def clearRects(self):
self.rectangles.clear()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow(get_monitors()[0].width, get_monitors()[0].height)
window.show()
app.exec_()