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


Python menu.Menu类代码示例

本文整理汇总了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
开发者ID:Gustry,项目名称:Avion,代码行数:30,代码来源:game.py

示例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()
开发者ID:jcnix,项目名称:abg,代码行数:60,代码来源:abg.py

示例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"))
开发者ID:akucia,项目名称:DJANGO_PITE_PROJECT,代码行数:7,代码来源:on_start.py

示例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)
开发者ID:bluecube,项目名称:TouchBMC,代码行数:27,代码来源:menu_impl.py

示例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
开发者ID:spielzeugland,项目名称:kodi-control-panel,代码行数:7,代码来源:menu_test.py

示例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
开发者ID:ZhanruiLiang,项目名称:MSRA-Python-Clone,代码行数:28,代码来源:shippo.py

示例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()
开发者ID:greenfox-academy,项目名称:peterjuhasz,代码行数:27,代码来源:main_menu.py

示例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)
开发者ID:dantheta,项目名称:cursesfrp,代码行数:7,代码来源:input.py

示例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'
开发者ID:mattvenn,项目名称:python,代码行数:7,代码来源:test_menu.py

示例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
开发者ID:hoelter,项目名称:applicant-tracking,代码行数:35,代码来源:candidate.py

示例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)
开发者ID:jjconti,项目名称:secret-code-game,代码行数:30,代码来源:run.py

示例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()
开发者ID:samsaga2,项目名称:tv3alacarta,代码行数:7,代码来源:a3mediachannel.py

示例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()
开发者ID:samsaga2,项目名称:tv3alacarta,代码行数:7,代码来源:a3mediachannel.py

示例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)
开发者ID:Drieger,项目名称:django-simple-menu,代码行数:33,代码来源:test_menu.py

示例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()
开发者ID:greenfox-academy,项目名称:evabertalan,代码行数:7,代码来源:game.py


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