Package elisa :: Package plugins :: Package bad :: Package weather :: Module weather_gtk_view
[hide private]
[frames] | no frames]

Source Code for Module elisa.plugins.bad.weather.weather_gtk_view

  1  # -*- coding: utf-8 -*- 
  2  # Elisa - Home multimedia server 
  3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
  4  # All rights reserved. 
  5  # 
  6  # This file is available under one of two license agreements. 
  7  # 
  8  # This file is licensed under the GPL version 3. 
  9  # See "LICENSE.GPL" in the root of this distribution including a special 
 10  # exception to use Elisa with Fluendo's plugins. 
 11  # 
 12  # The GPL part of Elisa is also available under a commercial licensing 
 13  # agreement from Fluendo. 
 14  # See "LICENSE.Elisa" in the root directory of this distribution package 
 15  # for details on that license. 
 16   
 17   
 18  __maintainer__ = 'Benjamin Kampmann <benjamin@fluendo.com>' 
 19   
 20  from elisa.base_components.view import View 
 21   
 22  import pygtk 
 23  pygtk.require('2.0') 
 24  import gtk 
 25   
26 -class WeatherGtkView(View):
27 28 """ 29 This class implements gtk weather view 30 """ 31 32 supported_controllers = ('weather:weather_controller',) 33
34 - def __init__(self):
35 View.__init__(self) 36 self.table = gtk.Table(rows=6, columns=4, homogeneous=True) 37 ## The Syntax is: self.table.attach 38 ## (child, left_attach, right_attach, top_attach, bottom_attach, 39 ##self.icon = gtk.Image 40 41 self.lbl_local = gtk.Label("Location") 42 self.table.attach(self.lbl_local,0,2,0,1) 43 self.lbl_local_val = gtk.Label() 44 self.table.attach(self.lbl_local_val,2,4,0,1) 45 self.lbl_local.show() 46 self.lbl_local_val.show() 47 48 self.lbl_temp = gtk.Label("Temprature") 49 self.table.attach(self.lbl_temp,0,1,3,4) 50 self.lbl_temp_val = gtk.Label() 51 self.table.attach(self.lbl_temp_val,1,2,3,4) 52 self.lbl_temp.show() 53 self.lbl_temp_val.show() 54 55 self.lbl_hum = gtk.Label("relative Humidity") 56 self.lbl_hum_val = gtk.Label() 57 self.table.attach(self.lbl_hum,0,1,4,5) 58 self.table.attach(self.lbl_hum_val,1,2,4,5) 59 self.lbl_hum.show() 60 self.lbl_hum_val.show() 61 62 self.lbl_dew = gtk.Label("Dew point") 63 self.table.attach(self.lbl_dew,2,3,1,2) 64 self.lbl_temp.show() 65 self.lbl_dew_val = gtk.Label() 66 self.table.attach(self.lbl_dew_val,3,4,1,2) 67 self.lbl_temp_val.show() 68 69 70 self.lbl_press = gtk.Label("Pressure") 71 self.table.attach(self.lbl_press,2,3,2,3) 72 self.lbl_press.show() 73 self.lbl_press_val = gtk.Label() 74 self.table.attach(self.lbl_press_val,3,4,2,3) 75 self.lbl_press_val.show() 76 77 self.lbl_wspeed = gtk.Label("Wind speed") 78 self.lbl_wspeed_val = gtk.Label() 79 self.table.attach(self.lbl_wspeed,2,3,3,4) 80 self.table.attach(self.lbl_wspeed_val,3,4,3,4) 81 self.lbl_wspeed.show() 82 self.lbl_wspeed_val.show() 83 84 self.lbl_windD = gtk.Label("Wind direction") 85 self.table.attach(self.lbl_windD,2,3,4,5) 86 self.lbl_windD.show() 87 self.lbl_windD_val = gtk.Label() 88 self.table.attach(self.lbl_windD_val,3,4,4,5) 89 self.lbl_windD_val.show() 90 91 92 93 self.lbl_sky = gtk.Label("Sky conditions") 94 self.table.attach(self.lbl_sky,0,2,5,6) 95 self.lbl_sky.show() 96 self.lbl_sky_val = gtk.Label() 97 self.table.attach(self.lbl_sky_val,2,4,5,6) 98 self.lbl_sky_val.show() 99 100 self.table.show() 101 self.context_path = 'gtk:gtk_context' 102 treestore = gtk.TreeStore(str) 103 treeview = gtk.TreeView(treestore) 104 ## delete this line, if you want to use it inside elisa 105 self.context_handle = self.table
106 107
108 - def controller_changed(self, old_controller, new_controller):
109 110 self.icon = gtk.Image() 111 pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( 112 self.frontend.theme.get_media( 113 self.controller.model.icon, 114 ('weather:data/%s.png' 115 % self.controller.model.icon) 116 ), 117 250, 118 250) 119 self.icon.set_from_pixbuf(pixbuf) 120 self.icon.show() 121 self.table.attach(self.icon,0,2,1,3) 122 self.debug("The icon is: %s and the path is: %s" % 123 (self.controller.model.icon, 124 self.frontend.theme.get_media( 125 self.controller.model.icon, 126 ('weather:data/%s.png' % 127 self.controller.model.icon 128 )) 129 ) 130 ) 131 self.lbl_local_val.set_text(self.controller.model.location) 132 self.lbl_temp_val.set_text("%d °C" % 133 self.controller.model.temp) 134 self.lbl_wspeed_val.set_text("%d km/h" % 135 self.controller.model.wind_speed) 136 self.lbl_windD_val.set_text("%d °" % 137 self.controller.model.wind_dir) 138 self.lbl_hum_val.set_text("%d %%" % 139 self.controller.model.relHumidity) 140 self.lbl_dew_val.set_text("%d °C" % 141 self.controller.model.dew) 142 self.lbl_sky_val.set_text(self.controller.model.sky) 143 self.lbl_press_val.set_text("%d hPa" % 144 self.controller.model.press)
145