-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertWindow.py
More file actions
68 lines (47 loc) · 1.8 KB
/
AlertWindow.py
File metadata and controls
68 lines (47 loc) · 1.8 KB
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QDesktopWidget
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
from Timer import Timer
from datetime import timedelta
from time import sleep
class AlertWindow(QWidget):
width = 250
height = 150
def __init__(self, inputMinutes):
super().__init__()
sizeObject = QDesktopWidget().screenGeometry(-1)
self.initUI(sizeObject)
self.timer = Timer(timedelta(minutes=inputMinutes))
self.beginWait()
def initUI(self, screenSize):
self.resize(self.width, self.height)
self.move(screenSize.width() - self.width, screenSize.height() - self.height - 50)
self.setWindowTitle('Перерыв')
self.setStyleSheet("background-color: #f16d95")
self.setWindowFlag(Qt.WindowStaysOnTopHint)
self.font = QFont("Calibri", 14, QFont.Bold)
self.initLabel()
self.initButton()
def initLabel(self):
self.lbl = QLabel(self)
self.lbl.resize(self.width, int(self.height / 2))
self.lbl.setText('<center>Необходимо<br> сделать<br> перерыв</center>')
self.lbl.setFont(self.font)
def initButton(self):
self.btn = QPushButton(self)
self.btn.setText("Перерыв")
self.btn.setFont(self.font)
self.btn.resize(self.width - 40, 30)
self.btn.move(20, int(self.height / 2 + 10))
self.btn.setStyleSheet("background-color: #f13c73")
self.btn.clicked.connect(self.beginWait)
def beginWait(self):
self.hide()
self.timer.beginTimer()
while True:
if self.timer.check():
self.show()
return
sleep(5)