本文整理汇总了Python中menu.Menu类的典型用法代码示例。如果您正苦于以下问题:Python Menu类的具体用法?Python Menu怎么用?Python Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Menu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
def start(self):
pygame.display.flip()
menu = Menu(self.fenetre)
askToExit = False
while not askToExit:
for event in pygame.event.get():
if event.type == QUIT:
askToExit = True
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
askToExit = True
choix = menu.loop()
if choix <=0:
askToExit = True
if choix == 4:
regle = Regle(self.fenetre)
regle = regle.loop()
if regle <=0:
askToExit = True
if choix == 1:
niveau = Niveau(1)
joueurs = [Joueur(1),Joueur(1)]
partie = Partie(self.fenetre,niveau,joueurs)
askToExit = partie.start()
Joueur.i = 1
示例2: play
def play():
from menu import Menu
menu = Menu(screen)
#show menu before starting game.
menu.showMenu()
from player import Player
from bullet import Bullet
from enemies import Enemies
player = Player()
player.set_screen(screen)
to_update = player.create()
#draw player to screen immediately
pygame.display.update(to_update)
bullet = Bullet()
bullet.set_screen(screen)
enemies = Enemies()
enemies.set_screen(screen)
while player.is_alive():
to_update = []
pygame.event.pump()
key = pygame.key.get_pressed()
#key events that only need to be pressed once
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
menu.showMenu()
if event.key == pygame.K_SPACE:
player.fire(bullet, True)
if key[pygame.K_ESCAPE]:
sys.exit()
if key[pygame.K_RIGHT]:
to_update += player.move_right()
if key[pygame.K_LEFT]:
to_update += player.move_left()
if key[pygame.K_SPACE]:
player.fire(bullet, False)
frametime.start()
to_update += bullet.move(enemies, player)
to_update += enemies.move(bullet)
pygame.display.update(to_update)
#find how long it took to render this frame so we can adjust speeds
frametime.end()
#player died
player.game_over()
enemies.game_over()
bullet.game_over()
pygame.display.flip()
示例3: ready
def ready(self):
# Add two items to our main menu
Menu.add_item("main", MenuItem("Informacje o koncie",reverse("am_userInfo"),weight=10,icon="tools"))
Menu.add_item("main", MenuItem("zmień dane",reverse("am_changeUserdata"),weight=20,icon="report"))
Menu.add_item("main", MenuItem("zmień hasło",reverse("am_changeUserpassword"),weight=30,icon="report"))
Menu.add_item("main", MenuItem("twoje ankiety",reverse("am_userSurveys"),weight=40,icon="report"))
Menu.add_item("main", MenuItem("statystyki i aktywność użytkownika",reverse("am_userActivity"),weight=50,icon="report"))
示例4: albums_action
def albums_action(menuitem, gui, artist_id = None):
"""
Load the list of artists from the XBMC and display the menu.
"""
if artist_id:
result = xbmc.call.AudioLibrary.GetAlbums(artistid = artist_id)
else:
result = xbmc.call.AudioLibrary.GetAlbums()
def convert(album):
text = album["label"]
if album.has_key('thumbnail'):
pass
#image = self.cache.open_http(
# album["thumbnail"], self.config["default album"],
# image_convert)
else:
image = self.cache.open(self.config["default album"])
def action(menuitem2, gui2):
tracks_action(menuitem2, gui2, album["albumid"])
return MenuItem(image, text, action)
self.albums_menu.fill(*map(convert, result["albums"]))
Menu.action_helper(self.albums_menu)(menuitem, gui)
示例5: test_select_shouldShowLoadingWhileGettingItemsAsynchronously
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
示例6: show_menu
def show_menu(self):
from menu import Menu
import Tkinter as tk
root = tk.Tk()
self.add_human = 0
self.goOn = 0
def set_AI_vs_human():
self.add_human = 1
root.destroy()
self.goOn = 1
def set_AI_vs_AI():
root.destroy()
self.goOn = 1
def quit():
root.destroy()
items = [("AI vs Human", set_AI_vs_human), ("AI vs AI", set_AI_vs_AI), ("Quit", quit)]
menu = Menu(root, items)
menu.pack()
root.mainloop()
if not self.goOn:
self.quit()
else:
del self.goOn
示例7: strike_menu
def strike_menu():
roll_cube(player)
roll_cube(opponent)
if player.roll > opponent.roll:
print(player)
print(opponent)
print('You hits monster')
opponent.hp -= 2
print(player)
print(opponent)
else:
print(player)
print(opponent)
print('Monster hits you')
player.hp -= 2
print(player)
print(opponent)
name_items = Menu([
MenuItem(1, 'Try your luck', try_your_luck_menu),
MenuItem(2, 'Retreat', strike_menu),
MenuItem(3, 'Quit', quit),
])
name_items.print_menu()
name_items.choose()
示例8: show_menu
def show_menu(self, command, options):
"""Shows the tab-completion menu"""
menu = Menu(self.win, options )
option = menu.run()
menu.hide()
if option is not None:
self.set_buffer(command + ' ' + option)
示例9: test_single_options_single_digits
def test_single_options_single_digits(self):
m = Menu(test_contacts)
assert len(m.get_options('2')) == 1
assert m.get_options('2')[0]['number'] == '1'
assert len(m.get_options('3')) == 1
assert m.get_options('3')[0]['number'] == '2'
示例10: get_modification
def get_modification(self):#integrate options, perhaps send to 'get' functions and change those to file mods
choice = None
resume = False
while choice != 'q':
if self.mod_key == "Resume":
# if self.mod_value != None:
# print("\n\t\tHere is the current resume.")
# resume = self.controller.get_resume(self)
# self.open_resume(resume)
# choice = input("Please enter the new resumes file path\nand file name with a .pdf ending: ")
# resume = self.save_resume(choice)
# new_value = choice
print("\n\t\tResume saving inside database is currently malfunctioning, pick another option please.")
time.sleep(4)
break
else:
print("\n\t\tYou have chosen to modify '{}'.\n".format(self.mod_key))
print("\nOpening contents in text editor. Please modify and save the file.")
self.open_data()
new_value = None
choice = input("\n\t\tPress enter to continue when ready...")
if not new_value:
new_value = self.save_data()
Menu.clear_screen()
print("\nThe information you have entered is:\n{}".format(new_value))
verify = input("Is this correct? 'y' to confirm: ").lower()
if Menu.verify_yes_no(verify):
print("\nEntry complete and saving now.")
if resume:
self.info[self.mod_key] = resume.encode('utf8')
else:
self.info[self.mod_key] = new_value
choice = 'q'
time.sleep(2)
return resume
示例11: main
def main():
#Initialize
pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption(WINDOW_TITLE)
screen.fill(bg_color)
clock = pygame.time.Clock()
font = pygame.font.Font(font_path, fonth)
img_reglas = load_image(reglas_path)
img_creditos = load_image(creditos_path)
pygame.mixer.music.load(menu_music)
pygame.mixer.music.play()
while True:
menu = Menu(screen, font, ['Jugar', 'Reglas', 'Creditos', 'Salir'])
op = menu.main_loop()
if op == 0:
game = SC(screen, clock)
game.main_loop()
elif op == 1:
SimpleScreen(screen, img_reglas).main_loop()
elif op == 2:
SimpleScreen(screen, img_creditos).main_loop()
elif op == 3:
sys.exit(0)
示例12: mode__episodes
def mode__episodes(self):
id = self.args['id'][0]
menu = Menu(self.base_url, self.addon_handle)
for item in a3media.get_episodes(id):
video = {"Plot": item['plot']}
menu.add(MenuItem(item['title'], 'play', args={'id': id}, iconImage=item['img'], video=video))
menu.show()
示例13: mode__section
def mode__section(self):
id = self.args['id'][0]
menu = Menu(self.base_url, self.addon_handle)
for item in a3media.get_section(id):
video = {"Plot": item['plot']}
menu.add(MenuItem(item['title'], 'subcategories', args={'id': id, 'subid': item['id']}, iconImage=item['img'], video=video))
menu.show()
示例14: test_select_parents
def test_select_parents(self):
"""
Ensure the MENU_SELECT_PARENTS setting works
"""
settings.MENU_SELECT_PARENTS = False
request = self.factory.get('/parent2/kids2-1')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, True)
self.assertEqual(items[0].children[1].selected, True)
self.assertEqual(items[1].selected, False)
request = self.factory.get('/kids2-2')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, False)
self.assertEqual(items[0].children[0].selected, True)
self.assertEqual(items[1].selected, False)
settings.MENU_SELECT_PARENTS = True
request = self.factory.get('/kids2-2')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, True)
self.assertEqual(items[0].children[0].selected, True)
self.assertEqual(items[1].selected, False)
request = self.factory.get('/parent3/kids3-1/kid1')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, False)
self.assertEqual(items[0].children[1].selected, False)
self.assertEqual(items[1].selected, True)
self.assertEqual(items[1].children[0].selected, True)
self.assertEqual(items[1].children[0].children[0].selected, True)
self.assertEqual(items[1].children[1].selected, False)
self.assertEqual(items[2].selected, False)
示例15: quit_game
def quit_game():
quit_items=Menu([
MenuItem(1, "Save and Quit", save_and_quit),
MenuItem(2, "Quit without save", quit_without_save),
MenuItem(3, "Resume", resume)])
quit_items.print_menu_items()
quit_item=quit_items.select_menu_item()