-
Notifications
You must be signed in to change notification settings - Fork 1
/
Accuwear.py
77 lines (62 loc) · 2.01 KB
/
Accuwear.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
import sys
from accuweather import get_weather
from multiprocessing import Queue
from newsearch import get_tweets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
def window():
app = QApplication(sys.argv)
win = QWidget()
image_url, weather_description, temperature = get_weather()
tweets = get_tweets()
sponsor = QLabel()
sponsor.setPixmap(QPixmap(resource_path("images/accuweather.png")))
sponsor.setFixedHeight(15)
sponsor.setFixedWidth(78)
sponsor.setScaledContents(True)
image = QLabel()
image.setPixmap(QPixmap(resource_path(image_url)))
image.setScaledContents(True)
description = QLabel(weather_description)
description.setAlignment(Qt.AlignCenter)
tempLabel = QLabel(str(temperature) + '° F')
tempLabel.setAlignment(Qt.AlignCenter)
progressBar = QProgressBar()
progressBar.setValue(((temperature / 130.0) * 100))
temperatureBox = QHBoxLayout()
temperatureBox.addWidget(progressBar)
temperatureBox.addWidget(tempLabel)
tweet1 = QLabel(tweets[0])
tweet2 = QLabel(tweets[1])
tweet3 = QLabel(tweets[2])
tweet4 = QLabel(tweets[3])
groupBox = QGroupBox("AccuTweets")
vbox = QVBoxLayout()
vbox.addWidget(tweet1)
vbox.addWidget(tweet2)
vbox.addWidget(tweet3)
vbox.addWidget(tweet4)
groupBox.setLayout(vbox)
vbox = QVBoxLayout()
vbox.addWidget(sponsor)
vbox.addWidget(image)
vbox.addStretch()
vbox.addWidget(description)
vbox.addStretch()
vbox.addLayout(temperatureBox)
vbox.addWidget(groupBox)
vbox.setAlignment(Qt.AlignCenter)
win.setLayout(vbox)
win.setWindowTitle("Accuwear")
win.setFixedSize(500, 600)
p = win.palette()
p.setColor(win.backgroundRole(), Qt.white)
win.setPalette(p)
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':
window()