当前位置: 首页>>代码示例>>Python>>正文


Python Weather.wunder方法代码示例

本文整理汇总了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)
		
开发者ID:andytopham,项目名称:podplayer,代码行数:82,代码来源:uoledinfo.py


注:本文中的weather.Weather.wunder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。