-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
105 lines (62 loc) · 2.4 KB
/
gui.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
# -*- coding: utf-8 -*-
"""
MainWindow
Window where Clock and Date should appear
@author: Felix Reichling
"""
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QLabel, QMainWindow, QVBoxLayout, QWidget, QLCDNumber
from PyQt5.QtCore import QDate, QTime, QTimer, Qt, QUrl, QCoreApplication
from PyQt5 import QtNetwork
import requests
from bs4 import BeautifulSoup
class MainWindow(QMainWindow):
def __init__(self, width, height, *args,**kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.initUI(width, height)
print('successfully built initUI...')
timer = QTimer(self)
timer.timeout.connect(self.showlcd)
timer.start(1000)
updateVerse = QTimer(self)
updateVerse.timeout.connect(self.redraw_Verse)
QTimer.singleShot(0, self.redraw_Verse)
updateVerse.start(60000*555) #update every 6 hours
self.showlcd()
self.showDate()
print('successfully showed lcd...')
def initUI(self, width, height):
self.lcd = QLCDNumber(self)
self.lcdDate = QLCDNumber(self)
self.lcd.setDigitCount(8)
self.lcdDate.setDigitCount(10)
self.label = QLabel(self)
self.label.setFont(QFont('Times', 70, QFont.Bold))
self.label.setAlignment(Qt.AlignCenter)
self.label.setWordWrap(True)
self.setGeometry(0,0,width,height)
self.setWindowTitle('RaspiClock')
layout = QVBoxLayout()
layout.addWidget(self.lcd)
layout.addWidget(self.lcdDate)
layout.addWidget(self.label)
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
self.show()
def showlcd(self):
time = QTime.currentTime()
text = time.toString('hh:mm:ss')
self.lcd.display(text)
def showDate(self):
date = QDate.currentDate()
date.toString(Qt.ISODate)
final = date.toString('dd.MM.yyyy')
self.lcdDate.display(final)
def redraw_Verse(self):
result = requests.get('https://www.bible.com/verse-of-the-day')
page = result.text
soup = BeautifulSoup(page, 'html.parser')
self.verse = soup.find('div', class_ = 'verse-wrapper').text
self.verse = self.verse.replace(".", ". ")
self.label.setText(self.verse)