本文整理汇总了Python中menu.Menu.select方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.select方法的具体用法?Python Menu.select怎么用?Python Menu.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_shouldShowLoadingWhileGettingItemsAsynchronously
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldShowLoadingWhileGettingItemsAsynchronously():
asyncFolder = mocks.NeverLoadingFolder("Dynamic", [])
dynamicMainFolder = mocks.Folder("Main", [asyncFolder])
menu = Menu(dynamicMainFolder)
menu.select()
assert asyncFolder.loadItemsCnt == 0
assert menu.item() is menu._loadingItem
示例2: test_select_shouldLoadAsyncFolders
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldLoadAsyncFolders():
asyncFolder = mocks.SynchronAsyncFolder("Dynamic", [])
dynamicMainFolder = mocks.Folder("Main", [asyncFolder])
menu = Menu(dynamicMainFolder)
menu.select()
assert asyncFolder.loadItemsCnt == 1
assert menu._currentItems == asyncFolder._itemsToLoad
示例3: test_mainFolder_shouldReturnCurrentMainFolder
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_mainFolder_shouldReturnCurrentMainFolder():
menu = Menu(mainFolder)
menu.select()
assert menu.folder() is folder1
assert menu.mainFolder() is folder1
menu.select()
assert menu.folder() is folder1a
assert menu.mainFolder() is folder1
menu.back().back()
assert menu.mainFolder() is None
示例4: main
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def main():
ser = serial.Serial('/dev/ttyAMA0', 7600, timeout=0)
menu = Menu(MENU_STRUCTURE, 20, 4, output='lcd')
menu.show()
while True:
data = ser.read(8).strip()
if data:
if data == 'c': # clockwise
menu.down()
elif data == 'a': # anti-clockwise
menu.up()
elif data == 'p': # press
menu.select()
menu.show()
sleep(0.01)
示例5: main
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def main():
menu = Menu(MENU_STRUCTURE, 20, 4, output='terminal')
def show():
for i in range(20):
print('')
menu.show()
show()
kgen = getch(0.1)
while True:
key = kgen.next()
if key:
if key == 'B':
menu.down()
elif key == 'A':
menu.up()
elif key in [' ', '\n']:
menu.select()
show()
示例6: test_select_shouldOpenFolderAndShowItsFirstEntry
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldOpenFolderAndShowItsFirstEntry():
menu = Menu(mainFolder)
menu.moveBy(1)
menu.select()
assert menu.folder() is folder2
assert menu.item() is folder2a
示例7: test_select_shouldShowRetryActionWhenLoadingFolderFailed_Asynchronously
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldShowRetryActionWhenLoadingFolderFailed_Asynchronously():
asyncFolder = mocks.FailingSynchronAsyncFolder("Dynamic", Exception(""))
dynamicMainFolder = mocks.Folder("Main", [asyncFolder])
menu = Menu(dynamicMainFolder)
menu.select()
assert isinstance(menu.item(), _RetryAction)
示例8: test_select_shouldExecuteSelectedAction
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldExecuteSelectedAction():
action = mocks.Action("Action")
folder = mocks.Folder("Folder", [action])
menu = Menu(folder)
menu.select()
assert action.runCnt == 1
示例9: test_select_shouldAddMessageForFailingFolder
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldAddMessageForFailingFolder():
someException = Exception("exception text")
failingFolder = mocks.FailingFolder("my failing folder", someException)
folder = mocks.Folder("Folder", [failingFolder])
menu = Menu(folder)
menu.select()
示例10: test_select_shouldAddMessageForFailingAction
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldAddMessageForFailingAction():
someException = Exception("exception text")
action = mocks.FailingAction("My Failing Action", someException)
folder = mocks.Folder("Folder", [action])
menu = Menu(folder)
menu.select()
示例11: test_back
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_back():
menu = Menu(mainFolder)
menu.select()
menu.back()
assert menu.folder() is mainFolder
示例12: test_back_shouldRememberIndex
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_back_shouldRememberIndex():
menu = Menu(mainFolder)
menu.moveBy(1)
menu.select()
menu.back()
assert menu.item() is folder2
示例13: test_select_emptyFolder_shouldDoNothing
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_emptyFolder_shouldDoNothing():
menu = Menu(emptyFolder, showBackItem=False)
assert menu.item() is menu._emptyItem
menu.select()
assert menu.item() is menu._emptyItem
示例14: main
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def main():
pygame.init()
pygame.mixer.music.load("rematch.mp3")
pygame.mixer.music.play(-1)
screen = pygame.display.set_mode((1000, 1000))
clock = pygame.time.Clock()
game_map = Map(0)
player = Character( game_map, 23, 1 )
prevKeys = {}
menu = Menu()
while True:
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
pygame.quit()
return
key = pygame.key.get_pressed()
if key[K_DOWN] and not prevKeys[K_DOWN]:
menu.move(1)
if key[K_UP] and not prevKeys[K_UP]:
menu.move(-1)
if key[K_RETURN] and not prevKeys[K_RETURN]:
r = menu.select()
if r == -1:
pygame.quit()
return
elif r == 1:
break
prevKeys = key
menu.draw(screen)
pygame.display.flip()
while True:
clock.tick(30)
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
pygame.quit()
return
key = pygame.key.get_pressed()
if key[K_LSHIFT]:
if key[K_UP] and not prevKeys[K_UP]:
player.attack_up()
elif key[K_DOWN] and not prevKeys[K_DOWN]:
player.attack_down()
elif key[K_LEFT] and not prevKeys[K_LEFT]:
player.attack_left()
elif key[K_RIGHT] and not prevKeys[K_RIGHT]:
player.attack_right()
else:
if key[K_UP] and not prevKeys[K_UP]:
player.move_up()
elif key[K_DOWN] and not prevKeys[K_DOWN]:
player.move_down()
elif key[K_LEFT] and not prevKeys[K_LEFT]:
player.move_left()
elif key[K_RIGHT] and not prevKeys[K_RIGHT]:
player.move_right()
while game_map.isWin(player.position.real, player.position.imag):
screen.blit(winScreen,(0,0))
pygame.display.flip()
for e in pygame.event.get():
if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
pygame.quit()
return
prevKeys = key
game_map.draw(screen)
player.draw(screen)
pygame.display.flip()
示例15: test_select_shouldLeaveRootFolder
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import select [as 别名]
def test_select_shouldLeaveRootFolder():
menu = Menu(mainFolder)
menu.select()
assert menu.isRoot() is False