示例#1
0
    def drawWeatherInfo(self,surface):
        weather = WeatherModel()
        currentWeather = weather.getCurrentWeather()

        font = pygame.font.Font("fonts/Verdana.ttf", 30)
        font.set_bold(True)

        tempText = "%sºC" % currentWeather["temp"]
        temp = font.render(tempText, True, Config.WHITE_COLOR)

        font = pygame.font.Font("fonts/Verdana.ttf", 12)
        font.set_bold(True)
        windText = "%s Km/h" % currentWeather["wind"]
        wind = font.render(windText, True, Config.WHITE_COLOR)

        tempRect = temp.get_rect()
        tempRect.x = 375
        tempRect.y = 90
        surface.blit(temp,tempRect)

        windRect = wind.get_rect()
        windRect.x = self.moduleRect.centerx - (windRect.width / 2) - 10
        windRect.y = 160
        surface.blit(wind,windRect)

        imageCompass = pygame.image.load("images/minicompass.png").convert_alpha()
        surface.blit(imageCompass,(windRect.x + windRect.width + 5,windRect.y-8))

        imageWeatherName = "images/weather%i.png" % currentWeather["sky"]
        imageWeather = pygame.image.load(imageWeatherName).convert_alpha()
        surface.blit(imageWeather,(self.moduleRect.x + 15,self.moduleRect.y + 20))
示例#2
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))
示例#3
0
    def drawCurrentWeatherInfo(self):

        weather = WeatherModel()
        currentWeather = weather.getCurrentWeather()

        font = pygame.font.Font("fonts/Verdana.ttf", 42)
        font.set_bold(True)

        tempText = "%sºC" % currentWeather["temp"]
        temp = font.render(tempText, True, Config.WHITE_COLOR)

        font = pygame.font.Font("fonts/Verdana.ttf", 12)
        font.set_bold(True)
        windText = "%s Km/h" % currentWeather["wind"]
        wind = font.render(windText, True, Config.WHITE_COLOR)

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

        tempRect = temp.get_rect()
        tempRect.x = 140
        tempRect.y = 30
        self.window.blit(temp,tempRect)

        windRect = wind.get_rect()
        windRect.x = 310
        windRect.y = 25
        self.window.blit(wind,windRect)

        maxTempRect = maxTemp.get_rect()
        maxTempRect.x = 310
        maxTempRect.y = 45 + windRect.height
        self.window.blit(maxTemp,maxTempRect)

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

        imageCompass = pygame.image.load("images/minicompass.png").convert_alpha()
        self.window.blit(imageCompass,(windRect.x + windRect.width + 35,windRect.y-8))

        imageWeatherName = "images/weather%i.png" % currentWeather["sky"]
        imageWeather = pygame.image.load(imageWeatherName).convert_alpha()
        self.window.blit(imageWeather,(40,20))