~rockstar/entertainer/package-structure-apocalypse

« back to all changes in this revision

Viewing changes to entertainerlib/gui/screens/weather.py

  • Committer: Paul Hummer
  • Date: 2009-05-10 17:36:49 UTC
  • mfrom: (360.1.3 entertainer-future)
  • Revision ID: paul@eventuallyanyway.com-20090510173649-0odjpoqifn303t46
Merged from entertainer-future

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2009 Entertainer Developers - See COPYING - GPLv2
1
2
'''WeatherScreen - Screen allows user to view current weather conditions'''
2
3
 
3
 
__licence__ = "GPLv2"
4
 
__copyright__ = "2008, Jamie Bennett"
5
 
__author__ = "Jamie Bennett <jamie@linuxuk.org>"
6
 
 
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
11
8
 
 
9
 
12
10
class WeatherScreen(Screen):
13
11
    '''Screen to display the user's set weather location.'''
14
12
 
23
21
        screen_title = Label(0.13, "screentitle", 0, 0.87, _("Weather"))
24
22
        self.add(screen_title)
25
23
 
26
 
        # Show the location
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"))
29
27
        else:
30
28
            location_text = self.weather.get_location()
31
29
 
32
 
        location = Label(0.04167, "text", 0.40, 0.13, location_text,
33
 
            font_weight="bold")
34
 
        self.add(location)
35
 
 
36
 
        forecasts = self.weather.get_forecasts()
37
 
 
38
 
        # Show today's weather
39
 
        self.create_day(forecasts[0], 0.1, 0.15)
40
 
 
41
 
        # Show tomorrow's weather
42
 
        self.create_day(forecasts[1], 0.1, 0.5)
43
 
 
44
 
        # Show day 3
45
 
        self.create_day(forecasts[2], 0.4, 0.5)
46
 
 
47
 
        # Show day 4
48
 
        self.create_day(forecasts[3], 0.7, 0.5)
 
30
            location = Label(0.04167, "text", 0.40, 0.13, location_text,
 
31
                font_weight="bold")
 
32
            self.add(location)
 
33
 
 
34
            forecasts = self.weather.get_forecasts()
 
35
 
 
36
            # Show today's weather
 
37
            self.create_day(forecasts[0], 0.1, 0.15)
 
38
 
 
39
            # Show tomorrow's weather
 
40
            self.create_day(forecasts[1], 0.1, 0.5)
 
41
 
 
42
            # Show day 3
 
43
            self.create_day(forecasts[2], 0.4, 0.5)
 
44
 
 
45
            # Show day 4
 
46
            self.create_day(forecasts[3], 0.7, 0.5)
49
47
 
50
48
    def create_day(self, day, x, y):
51
49
        """Create the Texture and labels for one day"""