-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (60 loc) · 2.17 KB
/
main.py
File metadata and controls
76 lines (60 loc) · 2.17 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
69
70
71
72
73
74
75
76
import kivy
kivy.require('2.0.0')
from kivy.app import App
from kivy.config import Config
from kivy.clock import Clock
from kivymd.uix.screen import Screen
from kivy.uix.label import Label
from weather import Weather
from currentTime import Time
Config.set("graphics", "height", "480")
Config.set("graphics", "width", "800")
class WeatherApp(App):
def build(self):
screen = Screen()
time = Time()
# Add time to the screen
screen.add_widget(time.current_time)
screen.add_widget(time.current_date)
Clock.schedule_interval(time.update_clock, 1)
weather = Weather()
# Schedule one new update at the next hour
secondsUntilNextHour = time.seconds_until_next_hour()
Clock.schedule_once(weather.update_weather, secondsUntilNextHour + 5)
# Update the weather every 10mins
Clock.schedule_interval(weather.update_weather, 600)
# Add temp and icon for current weather
screen.add_widget(weather.currentTemperature)
screen.add_widget(weather.currentIcon)
# Add temp and icon for weather in an hour
screen.add_widget(weather.secondTemperature)
screen.add_widget(weather.secondIcon)
screen.add_widget(weather.secondHour)
# Add temp and icon for weather in 2 hours
screen.add_widget(weather.thirdTemperature)
screen.add_widget(weather.thirdIcon)
screen.add_widget(weather.thirdHour)
# Add temp and icon for weather in 3 hours
screen.add_widget(weather.fourthTemperature)
screen.add_widget(weather.fourthIcon)
screen.add_widget(weather.fourthHour)
# Add temp and icon for weather in 4 hours
screen.add_widget(weather.fifthTemperature)
screen.add_widget(weather.fifthIcon)
screen.add_widget(weather.fifthHour)
if (weather.error == True):
screen.add_widget(
Label(
text = "Weather Error",
text_size= (500, 200),
halign="left",
pos_hint= {'x': .27, 'y': .99},
size_hint= (None, None),
font_size= 30,
color= (1, 0, 0)
)
)
return screen
WeatherApp().run()
if __name__ == '__main__':
WeatherApp().run()