1
# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2
1
2
'''WeatherScreen - Screen allows user to view current weather conditions'''
4
__copyright__ = "2008, Jamie Bennett"
5
__author__ = "Jamie Bennett <jamie@linuxuk.org>"
7
4
from entertainerlib.gui.screens.screen import Screen
8
5
from entertainerlib.gui.widgets.label import Label
9
6
from entertainerlib.gui.widgets.texture import Texture
10
7
from entertainerlib.weather import Weather
12
10
class WeatherScreen(Screen):
13
11
'''Screen to display the user's set weather location.'''
23
21
screen_title = Label(0.13, "screentitle", 0, 0.87, _("Weather"))
24
22
self.add(screen_title)
27
24
if (self.weather.get_location() == ''):
28
location_text = _("No weather location defined!")
25
self.add(Label(0.04167, "text", 0.30, 0.20,
26
_("No weather location defined!"), font_weight="bold"))
30
28
location_text = self.weather.get_location()
32
location = Label(0.04167, "text", 0.40, 0.13, location_text,
36
forecasts = self.weather.get_forecasts()
38
# Show today's weather
39
self.create_day(forecasts[0], 0.1, 0.15)
41
# Show tomorrow's weather
42
self.create_day(forecasts[1], 0.1, 0.5)
45
self.create_day(forecasts[2], 0.4, 0.5)
48
self.create_day(forecasts[3], 0.7, 0.5)
30
location = Label(0.04167, "text", 0.40, 0.13, location_text,
34
forecasts = self.weather.get_forecasts()
36
# Show today's weather
37
self.create_day(forecasts[0], 0.1, 0.15)
39
# Show tomorrow's weather
40
self.create_day(forecasts[1], 0.1, 0.5)
43
self.create_day(forecasts[2], 0.4, 0.5)
46
self.create_day(forecasts[3], 0.7, 0.5)
50
48
def create_day(self, day, x, y):
51
49
"""Create the Texture and labels for one day"""