示例#1
0
    def drawNextWeatherInfo(self):

        weather = WeatherModel()
        nextWeather = weather.getNextWeather()

        for index in range(0,4):

            if(index % 2 != 0):
                color = Config.BLUE_COLOR
            else:
                color = Config.LIGHT_BLUE_COLOR
            pygame.draw.rect(self.window,color,((index*115)+10,115,115,195),0)

            font = pygame.font.Font("fonts/Verdana.ttf", 12)
            font.set_bold(True)
            dayText = nextWeather[index]["weekDay"]
            day = font.render(dayText, True, Config.WHITE_COLOR)
            dayRect = day.get_rect()
            dayRect.centerx = (index*115)+67.5
            dayRect.y = 130
            self.window.blit(day,dayRect)

            windText = "%s Km/h" % nextWeather[index]["wind"]
            wind = font.render(windText, True, Config.WHITE_COLOR)

            maxTempText = "MAX: %sºC" % nextWeather[index]["maxTemp"]
            maxTemp = font.render(maxTempText, True, Config.WHITE_COLOR)
            minTempText = "MIN: %sºC" % nextWeather[index]["minTemp"]
            minTemp = font.render(minTempText, True, Config.WHITE_COLOR)

            xposition = (index*115)+25

            maxTempRect = maxTemp.get_rect()
            maxTempRect.x = xposition
            maxTempRect.y = 240
            self.window.blit(maxTemp,maxTempRect)

            minTempRect = minTemp.get_rect()
            minTempRect.x = xposition
            minTempRect.y = maxTempRect.height + maxTempRect.y
            self.window.blit(minTemp,minTempRect)

            windRect = wind.get_rect()
            windRect.x = xposition
            windRect.y = minTempRect.y + minTempRect.height
            self.window.blit(wind,windRect)

            imageWeatherName = "images/weather%i.png" % nextWeather[index]["sky"]
            imageWeather = pygame.image.load(imageWeatherName).convert_alpha()
            self.window.blit(imageWeather,((index*115)+32.5,150))