def __update_weatherdata(self): if self.lastUpdate == None: #print("Update Weather data because of None") #self.emit(SIGNAL("start_loading")) if self.__service_available(): self.weatherdata = weather.get_weather_from_weather_com(self.LOCATION_ID) #self.emit(SIGNAL("stop_loading")) self.lastUpdate = [QTime.hour(QTime.currentTime()), QTime.minute(QTime.currentTime())] return True, True else: self.lastUpdate = None return False, True elif self.lastUpdate[0] < QTime.hour(QTime.currentTime()) or \ self.lastUpdate[1] < (QTime.minute(QTime.currentTime()) -10): #print("Update Weather data because of long periode without update") self.emit(SIGNAL("start_loading")) if self.__service_available(): self.weatherdata = weather.get_weather_from_weather_com(self.LOCATION_ID) self.emit(SIGNAL("stop_loading")) self.lastUpdate = [QTime.hour(QTime.currentTime()), QTime.minute(QTime.currentTime())] return True, True else: self.lastUpdate = None return False, True else: #print("It is just a few minutes ago that i updated the weather data... not again :-)") return True, False # Data is up to date, available but with no changes...
def __update_weatherdata(self): if self.lastUpdate == None: #print("Update Weather data because of None") #self.emit(SIGNAL("start_loading")) if self.__service_available(): try: self.weatherdata = weather.get_weather_from_weather_com( self.LOCATION_ID) #self.emit(SIGNAL("stop_loading")) self.lastUpdate = [ QTime.hour(QTime.currentTime()), QTime.minute(QTime.currentTime()) ] return True, True except: # it can still go something wrong with the API of weather.com ... if so, I have to avoid a crash self.lastUpdate = None return False, True else: self.lastUpdate = None return False, True elif self.lastUpdate[0] < QTime.hour(QTime.currentTime()) or \ self.lastUpdate[1] < (QTime.minute(QTime.currentTime()) -10): #print("Update Weather data because of long periode without update") self.emit(SIGNAL("start_loading")) if self.__service_available(): try: self.weatherdata = weather.get_weather_from_weather_com( self.LOCATION_ID) self.emit(SIGNAL("stop_loading")) self.lastUpdate = [ QTime.hour(QTime.currentTime()), QTime.minute(QTime.currentTime()) ] return True, True except: # it can still go something wrong with the API of weather.com ... if so, I have to avoid a crash self.lastUpdate = None return False, True else: self.lastUpdate = None return False, True else: #print("It is just a few minutes ago that i updated the weather data... not again :-)") return True, False # Data is up to date, available but with no changes...
def __init__( self ): super(XCalendarItem, self).__init__() curr_dtime = QDateTime.currentDateTime() curr_date = curr_dtime.date() curr_time = curr_dtime.time() self.setFlags(self.flags() | self.ItemIsSelectable) self.setAcceptHoverEvents(True) # round to the nearest 15 minute segment curr_time = QTime(curr_time.hour(), curr_time.minute() - curr_time.minute() % 30, 0) self._rebuildBlocked = False self._textData = [] self._customData = {} self._textColor = QColor('white') self._fillColor = QColor('blue') self._borderColor = QColor('blue') self._highlightColor = QColor('blue') self._title = 'No Title' self._description = '' self._dateStart = curr_date self._dateEnd = curr_date self._timeStart = curr_time self._timeEnd = curr_time.addSecs(60 * 60) self._allDay = True self._rebuildRequired = False if ( QTime(23, 0, 0) <= self._timeStart ): self._timeEnd = QTime(23, 59, 0) self.setColor('blue')
def __init__(self): super(XCalendarItem, self).__init__() curr_dtime = QDateTime.currentDateTime() curr_date = curr_dtime.date() curr_time = curr_dtime.time() self.setFlags(self.flags() | self.ItemIsSelectable) self.setAcceptHoverEvents(True) # round to the nearest 15 minute segment curr_time = QTime(curr_time.hour(), curr_time.minute() - curr_time.minute() % 30, 0) self._rebuildBlocked = False self._textData = [] self._customData = {} self._textColor = QColor('white') self._fillColor = QColor('blue') self._borderColor = QColor('blue') self._highlightColor = QColor('blue') self._title = 'No Title' self._description = '' self._dateStart = curr_date self._dateEnd = curr_date self._timeStart = curr_time self._timeEnd = curr_time.addSecs(60 * 60) self._allDay = True self._rebuildRequired = False if (QTime(23, 0, 0) <= self._timeStart): self._timeEnd = QTime(23, 59, 0) self.setColor('blue')