• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python menu.Menu类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中menu.Menu的典型用法代码示例。如果您正苦于以下问题:Python Menu类的具体用法?Python Menu怎么用?Python Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Menu类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: delete_history

 def delete_history(self):
     m = Menu(options=['Likelihoods', 'Chains', 'All'], exit_str='Cancel')
     m.get_choice()
     if m.choice == 'Likelihoods' or m.choice == 'All':
         self.history['likelihoods'] = []
     if m.choice == 'Chains' or m.choice == 'All':
         self.history['chains'] = []
开发者ID:mmortonson,项目名称:CosmoCombo,代码行数:7,代码来源:session.py


示例17: main

def main():
    """Snake main entry point."""

    pygame.init()
    game_display = display.Display('Snake')

    # Create menu buttons
    menu_buttons = [Button("(1) Classic game",
                           (display.WINDOW_WIDTH * 1/3,
                            display.WINDOW_HEIGHT * 3/8),
                           pygl.K_1),
                    Button("(2) Exit",
                           (display.WINDOW_WIDTH * 1/3,
                            display.WINDOW_HEIGHT * 4/8),
                           pygl.K_2)]

    # Create the menu
    game_menu = Menu(game_display, menu_buttons, 'snake/images/menu/snake.png')
    game_menu.draw()

    while True:
        for event in pygame.event.get():
            if (event.type == pygl.QUIT) or \
               (event.type == pygl.KEYDOWN and event.key == pygl.K_ESCAPE):
                sys.exit(pygame.quit)
            for button in menu_buttons:
                if (event.type == pygl.KEYDOWN and
                   button.key_pressed(event.key)):
                    run_game(game_display)

        pygame.display.update()
        game_display.update_clock()
开发者ID:bregman-arie,项目名称:snake,代码行数:32,代码来源:main.py


示例18: add_chain

 def add_chain(self):
     pdf = self.choose_pdf(require_no_chain=True)
     # select from list of currently defined chains (from all pdfs),
     # previously used chains (read from file),
     # or get files and name for new chain (if new, save to file)
     if pdf is not None:
         if len(self.history['chains']) > 0:
             chain_history = sorted(self.history['chains'],
                                    key=lambda x: x[0], reverse=True)
             sort_indices = sorted(range(len(self.history['chains'])),
                                   key=lambda i: \
                                       self.history['chains'][i][0],
                                   reverse=True)
             options = [ch[1] for ch in chain_history]
             details = ['Chains:\n' + '\n'.join(
                     [textwrap.fill(s, initial_indent='    ',
                                    subsequent_indent='        ') \
                          for s in sorted(ch[2])]) \
                            for ch in chain_history]
             m = Menu(options=options, more=details,
                      exit_str='New chain',
                      header='Choose a chain:\n' + \
                          '(add ? to the number to get ' + \
                          'more info on a chain)')
             m.get_choice()
             if m.choice == m.exit:
                 pdf.add_chain(*self.define_new_chain())
             else:
                 self.history['chains'][sort_indices[m.i_choice]][0] += 1
                 pdf.add_chain(*self.history['chains'] \
                                    [sort_indices[m.i_choice]][1:])
         else:
             pdf.add_chain(*self.define_new_chain())
开发者ID:mmortonson,项目名称:CosmoCombo,代码行数:33,代码来源:session.py


示例19: __init__

    def __init__(self, app):
        Menu.__init__(self, app)

        self.header = ["Ebenezer personal accounting ver 0.1",\
                       "-----------[ Main menu ]------------"]

        num_acc = len(data.accounts)
        if self.app.active_account is None:
            active_account_name = "No account found!"
        else:
            active_account_name = self.app.active_account.name

        self.contents = ["Found " + str(num_acc) + " data.accounts",\
                         "Current active account : " + active_account_name,\
                         "[A]ccounts",\
                         "[T]ransactions",\
                         "[D]ebts",\
                         "[Q]uit"]

        self.prompt = "What do you want to do ?"

        self.answers = {"a":[self.change_menu, "accountlist"],\
                        "t":[self.change_menu, "accounttrans"],\
                        "d":[self.change_menu, "debts"],\
                        "q":[self.quit, None]}
开发者ID:grungi-ankhfire,项目名称:ebenezer,代码行数:25,代码来源:menu_main.py


示例20: add_likelihood

 def add_likelihood(self):
     pdf = self.choose_pdf()
     if pdf is not None:
         if len(self.history['likelihoods']) > 0:
             lk_history = sorted(self.history['likelihoods'], 
                                 key=lambda x: x[1], reverse=True)
             sort_indices = sorted(range(len(self.history['likelihoods'])),
                                   key=lambda i: \
                                       self.history['likelihoods'][i][1],
                                   reverse=True)
             options = [lk[0] for lk in lk_history]
             details = ['Likelihoods:\n' + '\n'.join(
                     ['    ' + s + ': ' +  str(lk[2][s]) \
                          for s in sorted(lk[2].keys())]) \
                            for lk in lk_history]
             m = Menu(options=options, more=details,
                      exit_str='New likelihood',
                      header='Choose a likelihood function:\n' + \
                          '(add ? to the number to get ' + \
                          'more info on a likelihood)')
             m.get_choice()
             if m.choice == m.exit:
                 new_lk = self.define_new_likelihood(pdf)
                 pdf.add_likelihood(new_lk[0], **new_lk[2])
             else:
                 self.history['likelihoods'][sort_indices[m.i_choice]][1] \
                     += 1
                 lk = self.history['likelihoods'][sort_indices[m.i_choice]]
                 pdf.add_likelihood(lk[0], **lk[2])
         else:
             new_lk = self.define_new_likelihood(pdf)
             pdf.add_likelihood(new_lk[0], **new_lk[2])
开发者ID:mmortonson,项目名称:CosmoCombo,代码行数:32,代码来源:session.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python menuinst.install函数代码示例发布时间:2022-05-27
下一篇:
Python menu.menu函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap