本文整理汇总了Python中weather.Weather.wunder方法的典型用法代码示例。如果您正苦于以下问题:Python Weather.wunder方法的具体用法?Python Weather.wunder怎么用?Python Weather.wunder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weather.Weather
的用法示例。
在下文中一共展示了Weather.wunder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InfoDisplay
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import wunder [as 别名]
class InfoDisplay(Oled):
''' Richer info on the oled. '''
def __init__(self,rowcount=4):
self.logger = logging.getLogger(__name__)
Oled.__init__(self, rowcount) # We are a subclass, so need to be explicit about which init
if rowcount == 2:
self.rowlength = 16
else:
self.rowlength = 20
self.update_row1('Starting up... ')
self.myWeather = Weather()
self.update_row2(1)
self.lasttime = 0
self.delta = 0.001
def update_row1(self, string):
self.writerow(1, string)
def update_row2(self, temperature_refresh_needed=False, time_remaining=0):
'''Time and temperature display on the info line - not necessarily row 2!'''
if self.rowlength == 16:
inforow = 2
else:
inforow = 4
try:
clock = time.strftime("%R")
self.logger.info('Update row2:'+clock)
if temperature_refresh_needed:
self.temperature = self.myWeather.wunder(config.key, config.locn)
except:
self.logger.warning('Error in updaterow2, part 1.')
return(1)
if True:
if self.rowlength == 16:
self.writerow(inforow,
'{0:5s} {1:7.1f}^C'.format(clock, float(self.temperature)))
else:
self.writerow(inforow,
'{0:5s}{1:13.1f}^C'.format(clock, float(self.temperature)))
else: # a version for debugging
if self.rowlength == 16:
self.writerow(inforow,
'{0:5s}{1:4d}{2:5.1f}^C'.format(clock, time_remaining, float(self.temperature)))
else:
self.writerow(inforow,
'{0:5s}{1:5d}{2:8.1f}^C'.format(clock, time_remaining, float(self.temperature)))
return(0)
def proginfo(self,string):
self.logger.info('proginfo:'+string)
if self.rowlength == 20:
self.writerow(2,string[0:20])
self.writerow(3,string[20:40])
else:
self.writerow(1,'{0:16.16}'.format(string))
def displayvol(self, string):
if self.rowlength == 16:
self.writerow(1, string)
else:
self.writerow(4, string)
def update_row3(self, elapsed=0, maxelapsed=0):
'''Show time gone.'''
if ((elapsed - self.lasttime) > self.delta) or ((self.lasttime - elapsed) > self.delta):
self.writerow(3,'Now={0:4.2f}s Max={1:5.2f}s'.format(elapsed, maxelapsed))
self.lasttime = elapsed
return(0)
def update_row4(self,prog='Test'):
'''Show test code.'''
self.writerow(4,prog)
return(0)
def update_whole_display(self):
self.update_row2()
self.update_row3()
self.update_row4()
return(0)