本文整理汇总了Python中Interface.Interface.buttons方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.buttons方法的具体用法?Python Interface.buttons怎么用?Python Interface.buttons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interface.Interface
的用法示例。
在下文中一共展示了Interface.buttons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import buttons [as 别名]
class Scythe:
def __init__(self):
self.interface = Interface()
self.config = Config()
self.images = Images(self.config.get('Images', 'dir'), self.interface)
self.imageList = self.images.getFileList()
if len(self.imageList) == 0:
raise Exception('There are no images to scythe')
def displayImage(self, imageIndex):
self.interface.chooseImage(self.imageList[imageIndex][0])
self.config.set('Images', 'current', str(imageIndex))
sleep(1)
self.interface.scytheHome()
def runLoop(self):
exit = False
buttonPressed = False
imageIndex = int(self.config.get('Images', 'current'))
timeout = int(self.config.get('Display', 'timeout'))
maxImageIndex = len(self.imageList)
lastActivity = time.time()
self.displayData = self.images.getFileData(imageIndex)
self.renderer = Renderer(self.config, self.displayData, self.interface)
self.interface.scytheHome()
self.renderer.blank()
while(not exit):
buttons = self.interface.buttons()
if not buttonPressed and buttons != 0:
buttonPressed = True
lastActivity = time.time()
# 1 = select
# 2 = right
# 4 = down
# 8 = up
# 16 = left
if buttons == 1:
print('select')
self.interface.off()
sys.exit(0)
if buttons == 8:
print('up')
if imageIndex > 0:
imageIndex = imageIndex - 1
self.displayData = self.images.getFileData(imageIndex)
self.displayImage(imageIndex)
if buttons == 4:
print('down')
if imageIndex + 1 < maxImageIndex:
imageIndex = imageIndex + 1
self.displayData = self.images.getFileData(imageIndex)
self.displayImage(imageIndex)
if buttons == 2:
print('right')
if buttons == 16:
print('left')
elif buttonPressed and buttons == 0:
buttonPressed = False
if time.time() - lastActivity > timeout:
self.interface.off()