Esempio n. 1
0
 def draw_tile_header(self, x, y, w, h, fcast):
     """ Draw tile header
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     :param fcast: one day forecast
     """
     height = (h / 100) * TILE_HEADER_HEIGHT
     comp = Component(self.util)
     comp.content_x = x
     comp.content_y = y
     rect = pygame.Rect(x, y, w, height)
     comp.content = rect
     comp.fgr = self.semi_transparent_color
     comp.bgr = self.semi_transparent_color
     comp.bounding_box = rect
     self.add_component(comp)
     
     text_color = self.util.weather_config[COLOR_BRIGHT]
     font_size = int((height / 100) * DAY_HEIGHT)
     
     if fcast[DAY] == UNKNOWN:
         d = UNKNOWN
     else:
         d = self.weather_config[fcast[DAY].lower()]
         
     c = self.util.get_text_component(d, text_color, font_size)
     c.content_x = x + (w - c.content.get_size()[0]) / 2
     c.content_y = y + font_size / 8
     self.add_component(c)
Esempio n. 2
0
 def add_image(self, image, x, y, rect=None):
     """ Creates new UI component from provided image and adds it to the UI container.
     
     :param image: the image object
     :param x: x coordinate of the image top left corner
     :param y: y coordinate of the image top left corner
     :param rect: bounding rectangle of the image
     """
     c = Component(self.util)
     c.content = image
     c.content_x = rect.x
     c.content_y = rect.y
     if rect: c.bounding_box = rect
     self.add_component(c)
     return c
Esempio n. 3
0
 def add_image(self, image, x, y, rect=None):
     """ Creates new UI component from provided image and adds it to the UI container.
     
     :param image: the image object
     :param x: x coordinate of the image top left corner
     :param y: y coordinate of the image top left corner
     :param rect: bounding rectangle of the image
     """               
     c = Component(self.util)
     c.content = image
     c.content_x = x
     c.content_y = y
     if rect: c.bounding_box = rect
     self.add_component(c)
     return c
Esempio n. 4
0
 def draw_background(self, x, y, w, h):
     """ Draw background defined by input parameters
     
     :param x: x coordinate
     :param y: y coordinate
     :param w: width
     :param h: height
     """
     c = Component(self.util)
     c.content = pygame.Rect(x, y, w, h)
     c.content_x = x
     c.content_y = y
     c.bounding_box = c.content
     c.bgr = self.semi_transparent_color
     self.add_component(c)
Esempio n. 5
0
 def draw_image(self, image, x, y, container, rect=None):
     """ Draw background defined by input parameters
     
     :param image: image to draw
     :param x: x coordinate
     :param y: y coordinate
     :param container: container to which image will be added
     :param rect: bounding box
     """
     c = Component(self)
     c.content = image
     c.content_x = x
     c.content_y = y
     if rect: c.bounding_box = rect
     container.add_component(c)
     return c
Esempio n. 6
0
 def draw_weather(self):
     """ Draw weather forecast  """
     
     c = self.util.weather_config[COLOR_DARK]
     Container.__init__(self, self.util, self.rect, BLACK)
     
     c = Component(self.util)
     c.content = self.initial_image
     c.content_x = 0
     c.content_y = 0
     c.bounding_box = self.rect
     self.add_component(c)  
     
     widths = self.get_widths()
     heights = self.get_heights()
     
     self.draw_tiles(widths, heights)
Esempio n. 7
0
 def draw_weather(self):
     """ Draw Today's weather """
     
     Container.__init__(self, self.util, self.rect, BLACK)
     
     c = Component(self.util)
     c.content = self.initial_image
     c.content_x = 0
     c.content_y = 0
     c.bounding_box = self.rect
     self.add_component(c)       
     
     top_height = self.draw_top_background()
     self.draw_bottom_background()
     self.draw_city(top_height)
     self.draw_time(top_height)        
     self.draw_code()
     self.draw_temp()        
     self.draw_high_low()         
     self.draw_details()
Esempio n. 8
0
 def draw_tile_body(self, x, y, w, h, fcast):
     """ Draw center part of the tile
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     :param fcast: one day forecast
     """
     top_height = (h / 100) * TILE_HEADER_HEIGHT
     y += top_height
     h = h - top_height + 1
     comp = Component(self.util)
     comp.content_x = x
     comp.content_y = y
     rect = pygame.Rect(x, y, w, h)
     comp.content = rect
     comp.fgr = self.util.weather_config[COLOR_BRIGHT]
     comp.bgr = self.util.weather_config[COLOR_BRIGHT]
     comp.bounding_box = rect
     self.add_component(comp)
Esempio n. 9
0
 def draw_high_low(self):
     """ Draw high/low today's temperatures """
     
     bb_x = self.temp_right_edge
     bb_y = int((self.rect.h / 100) * TOP_HEIGHT)
     bb_w = self.rect.w - bb_x
     bb_h = self.rect.h - bb_y - int((self.rect.h / 100) * BOTTOM_HEIGHT)
     text_color = self.util.weather_config[COLOR_CONTRAST]
     font_size = int((bb_w / 100) * HIGH_LOW_TEXT_SIZE)
     
     c = self.util.get_text_component(self.high, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) - (font_size / 2)
     self.add_component(c)
     
     c = self.util.get_text_component(self.low, text_color, font_size)
     w = c.content.get_size()[0]
     h = c.content.get_size()[1]
     c.content_x = bb_x + int((bb_w - w) / 2)
     c.content_y = bb_y + int((bb_h - h) / 2) + (font_size / 1.4)
     self.add_component(c)
     
     x = c.content_x
     y = bb_y + int(bb_h / 2)
     w = c.content.get_size()[0]
     h = 2
     r = pygame.Rect(x, y, w, h)
     c = Component(self.util, r)
     c.name = "sep" + ".text"
     c.content_x = 0
     c.content_y = 0
     c.fgr = text_color
     c.bgr = text_color
     self.add_component(c)