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


Python Menu.run方法代码示例

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


在下文中一共展示了Menu.run方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
def main():

    WIDTH = 800
    HEIGHT = 800
    FULLSCREEN = True
    ode = '../resources/song.ogg'
    overture = '../resources/song1.ogg'
    moonlight = '../resources/song2.ogg'

    if (FULLSCREEN):
        screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
    else:
        screen = pygame.display.set_mode((WIDTH, HEIGHT))
    screen.fill((51,51,51))




    menu = Menu()
    menu.init(['Start', 'Quit'], screen)
    menu.draw(0)
    pygame.display.update()

    pygame.mixer.init()
    pygame.mixer.music.load('../resources/tuning_warmup.mp3')
    pygame.mixer.music.set_volume(2)
    pygame.mixer.music.play()

    pick = menu.run()

    while 1:
        if (pick == 1):
            menu = Menu()
            menu.init(['Start', 'Quit'], screen)
            menu.draw(0)
            pygame.display.update()
            pick = menu.run()
            if (pick == 1):
                menu = Menu()
                menu.init(['Ode To Joy','The Creatures of Prometheus','Moonlight Sonata mov 3','Quit'], screen)
                menu.draw(0)
                pygame.display.update()
                pick2 = menu.run()
                if (pick2 == 1):
                    game = Game(WIDTH, HEIGHT, FULLSCREEN, ode)
                    game.run()
                elif (pick2 == 2):
                    game = Game(WIDTH, HEIGHT, FULLSCREEN, overture)
                    game.run()
                elif (pick2 == 3):
                    game = Game(WIDTH, HEIGHT, FULLSCREEN, moonlight)
                    game.run()
            elif (pick == 2):
                break
开发者ID:manna422,项目名称:beethovens_final,代码行数:56,代码来源:main.py

示例2: show_menu

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
	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,代码行数:9,代码来源:input.py

示例3: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
class Game:
    def __init__(self):
        # current stat of game
        self.stat = 'menu'
        # init pygame
        pygame.mixer.pre_init(44100, 16, 2, 1024*4)
        pygame.init()
        pygame.display.set_caption("FUNNY TETRIS")
        self.init()
        try:
            self.screen = pygame.display.set_mode((640, 480), 
                    HWSURFACE | SRCALPHA, 32)
        except:
            self.screen = pygame.display.set_mode((640, 480), 
                    SRCALPHA, 32)
        try:
            pygame.display.set_icon(pygame.image.load(
                util.file_path("icon.png")).convert_alpha())
        except:
            # some platfom do not allow change icon after shown
            pass
        # init sub modules
        self.menu = Menu(self.screen)   # menu show start menu
        self.main = Main(self.screen)   # main is the real tetris

    def init(self):
        util.init()
        sound.load()

    def loop(self):
        clock = pygame.time.Clock()
        while self.stat != 'quit':
            elapse = clock.tick(25)
            if self.stat == 'menu':
                self.stat = self.menu.run(elapse)
            elif self.stat == 'game':
                self.stat = self.main.run(elapse)

            if self.stat.startswith('style'):
                level = int(self.stat.split()[1])
                print "Start game at style", level
                self.main.start(level)
                self.stat = "game"

            pygame.display.update()
        pygame.quit()
开发者ID:sherlockkenan,项目名称:Tetris,代码行数:48,代码来源:game.py

示例4: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
class Game:
    """
    This is the game manager modle 
    """
    def __init__(self):
        self.stat = 'menu'
        pygame.mixer.pre_init(44100, 16, 2, 1024*4) #mixer pre_init arguments
        pygame.init()
        pygame.display.set_caption("TETRIS_FUNNY") 
        self.init()
        try:
            self.screen = pygame.display.set_mode((640, 480),
                    HWSURFACE | SRCALPHA, 32)
        except:
            self.screen = pygame.display.set_mode((640, 480),
                    SRCALPHA, 32)
        try:
            pygame.display.set_icon(pygame.image.load(
                        util.file_path("icon.png")).convert_alpha())
        except:
            print "can't find icon picture under data directory"
            pass
        #init sub modules
        self.menu = Menu(self.screen)
        self.main = Main(self.screen)
    
    def init(self):
        util.init()
        sound.load()

    def loop(self):
        clock = pygame.time.Clock()
        while self.stat != r'quit':
            elapse = clock.tick(60)
            if self.stat == r'menu':
                self.stat = self.menu.run(elapse)
            elif self.stat == r'game':
                self.stat = self.main.run(elapse)

            if self.stat.startswith('level'):
                level = int(self.stat.split()[1])
                print "Start game at level", level
                self.main.start(level)
                self.stat = r"game"
            pygame.display.update()
        pygame.quit()
开发者ID:AkiraKane,项目名称:Python,代码行数:48,代码来源:game.py

示例5: run

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
    def run(self, menu_choice=0):
        done = False

        #Static menu part

        menu_items = ["Quit", 
                      "Sound: " + bool_to_str(variables["sound"]), 
                      "Dialogue: " + bool_to_str(variables["dialogue"]), 
                      "Fullscreen mode: " + bool_to_str(variables["fullscreen"]), 
                      'Choose character: %s' % CHARACTERS[variables['character']][0], 
                      "Choose world: " + str(self.world.number)
                                    ]

        #Adds levels to the menu

        count = 0

        while (count <= variables["unlocked" + self.world.name] and count < self.world.level_count):
            menu_items.append("Play level " + str(count + 1))
            count += 1

        #Hi score and best time text on the bgscreen

        if self.score != None:
            score_text = "Your final score: %s" % str(self.score)
            if self.levels == self.world.level_count:
                time_text = "Your final time: %s frames" % str(self.time)
            else:
                time_text = "Didn't pass all levels"

            if self.score > variables["hiscore" + self.world.name]:
                score_text += " - NEW HIGH SCORE!"
                variables["hiscore" + self.world.name] = self.score
            else:
                score_text += " - High score: %s" % variables["hiscore" + self.world.name]

            if (self.time < variables["besttime" + self.world.name] or variables["besttime" + self.world.name] == 0) and (self.levels == self.world.level_count):
                time_text += " - NEW BEST TIME!"
                variables["besttime" + self.world.name] = self.time
            elif variables["besttime" + self.world.name] == 0:
                time_text += " - Best time: no best time"
            else:
                time_text += " - Best time: %s frames" % variables["besttime" + self.world.name]
        else:
            score_text = "High score: %s" % variables["hiscore" + self.world.name]
            if variables["besttime" + self.world.name] == 0:
                time_text = "Best time: no best time"
            else:
                time_text = "Best time: %s frames" % variables["besttime" + self.world.name]


        menu_image = render_text("World " + str(self.world.number) + ": " + self.world.name, COLOR_GUI)
        rect = menu_image.get_rect()
        rect.centerx = SCREEN_WIDTH / 2
        rect.top = GUI_MENU_TOP - 75
        self.bgscreen.blit(menu_image, rect)

        menu_image = render_text(score_text, COLOR_GUI)
        rect = menu_image.get_rect()
        rect.centerx = SCREEN_WIDTH / 2
        rect.top = GUI_MENU_TOP - 50
        self.bgscreen.blit(menu_image, rect)

        menu_image = render_text(time_text, COLOR_GUI)
        rect = menu_image.get_rect()
        rect.centerx = SCREEN_WIDTH / 2
        rect.top = GUI_MENU_TOP - 30
        self.bgscreen.blit(menu_image, rect)
        
        #Uses the menu class for the actual selection functionality

        menu = Menu(self.screen, menu_items, self.bgscreen, "Which way is up?")

        menu_choice = menu.run(menu_choice + MENU_OFFSET)

        #Quit (-3) gets special treatment, because it's returned as a constant when the player presses ESC
        #If offset would be applied to it, it would turn up -6

        if not (menu_choice == MENU_QUIT):
            menu_choice = menu_choice - MENU_OFFSET

        return menu_choice
开发者ID:whichwayisup2,项目名称:whichwayisup2,代码行数:84,代码来源:mainmenu.py

示例6: main

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
def main():

    #Parsing level from parameters:

    level = 0

    user_supplied_level = False

    parse_config()

    if len(sys.argv) > 1:
        for arg in sys.argv:
          if level == -1:
            try:
              level = int(arg)
              user_supplied_level = True
            except:
              print "Error: incorrect level number"
              level = 0
          elif arg == "-l":
            level = -1

    #Initializing pygame and screen

    pygame.init()
    print "Which way is up starting up."
    screen = pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT))
    pygame.display.set_caption("Which way is up?")

    if (pygame.joystick.get_count() > 0):
      joystick = pygame.joystick.Joystick(0)
      joystick.init()
    else:
      joystick = None

    score = Score(0)

    done = False

    if (Variables.vdict["unlocked"] == 0) or user_supplied_level: # Go straight to the game
      end_trigger = END_NEXT_LEVEL
      menu_choice = -2
    else:                                      # Go to the menu first
      end_trigger = END_MENU
      menu_choice = 0

    #Menu and level changing loop, actual game code is in game.py:

    while not done:
      if end_trigger == END_NEXT_LEVEL:
        if level < TOTAL_LEVELS or user_supplied_level:
          end_trigger = game.run(screen, level, score, joystick)
          level += 1
          if end_trigger == END_QUIT:
            end_trigger = END_MENU
        else:
          end_trigger = END_WIN
      if end_trigger == END_LOSE:
        display_bg("lose", screen)
        end_trigger = END_MENU
      elif end_trigger == END_WIN:
        display_bg("victory", screen)
        end_trigger = END_MENU
      elif end_trigger == END_QUIT or end_trigger == END_HARD_QUIT:
        done = True
      elif end_trigger == END_MENU:
        prev_score = score.score
        score = Score(0)
        if prev_score != 0:
          menu = Menu(screen, prev_score)
        else:
          menu = Menu(screen)
        menu_choice = menu.run(menu_choice)
        if menu_choice == MENU_QUIT:
          end_trigger = END_QUIT
        elif menu_choice == MENU_SOUND:
          Variables.vdict["sound"] = not Variables.vdict["sound"]
          end_trigger = END_MENU
        elif menu_choice == MENU_DIALOGUE:
          Variables.vdict["dialogue"] = not Variables.vdict["dialogue"]
          end_trigger = END_MENU
        else:
          level = menu_choice
          end_trigger = END_NEXT_LEVEL
      else:
        if user_supplied_level:
          user_supplied_level = False
          end_trigger = END_WIN
        else:
          if Variables.vdict["unlocked"] < level:
            Variables.vdict["unlocked"] = level
            print "Unlocked level " + str(Variables.vdict["unlocked"])

    write_config()

    return
开发者ID:geofmatthews,项目名称:csci321,代码行数:98,代码来源:main.py

示例7: World

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
class World(DirectObject):
    #client side making it easier and not having to log in everytime for debuging just follow the comments
    def __init__(self):
        print("began")
        self.taskMgr = taskMgr
        with open('config.json') as data_file:    
            self.conf = json.load(data_file)
        self.ServerConnection = ServerConnection()#uncomment when going live
        self.ServerConnection.connect(self.conf['host'],self.conf['port'])#uncomment when going live
        props = WindowProperties( )
        props.setTitle( 'Log In' )
        props.setFixedSize(True)
        props.setSize(1280,740)
        props.setOrigin(-2,-2)
        base.win.requestProperties( props )
        self.base = ShowBase
        self.main_theme = base.loader.loadSfx("assets/sounds/terminator_theme.ogg")
        self.main_theme.play()
        
        self.username = ""
        self.balance = "900000"

        self.authConnection = AuthConnectionModel(self)#uncomment when going live
        self.authConnection.setHandler(self.parseAuthResponse, self.parseRegResponse)
        self.ServerConnection.setupConnectionModel(self.authConnection)#uncomment when going live
       
        
        self.heartbeatConnection = HeartbeatConnectionModel()#uncomment when going live
        
        self.ServerConnection.setupConnectionModel(self.heartbeatConnection)#uncomment when going live
        
        
        self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat")#uncomment when going live
        
        self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat")
        
        self.screen = Login(self)#uncomment when going live
        #self.screen = Menu(self)#comment this one when you are trying to log into it like normal

        
        self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat")
        
        self.taskMgr.doMethodLater(1, self.doSong, "song")
        
        self.screenType = "login"
        self.screen.run()
    
    def doHeartbeat(self,task):
        self.heartbeatConnection.sendHeartbeat()
        return task.again
    
    def doSong(self,task):
        if self.main_theme.status() == self.main_theme.READY:
            self.main_theme.play()
        return task.again
    
    def doMenu(self):
        print("doing menu")
        self.screen.unloadScreen()
        self.screenType = "menu"
        self.screen = Menu(self)
    
    def parseAuthResponse(self,data):
        if data == 1:
            print("unloading")
            self.doMenu()
        else: 
            if data == 2:
                self.screen.setStatusText("Already logged in")
            else:
                self.screen.setStatusText("Invalid username/password")   
            self.screen.enter_btn['state'] = DGG.NORMAL
            self.screen.register_btn['state'] = DGG.NORMAL        
        
    def parseRegResponse(self,data):
        if data == 1:
            print("unloading")
            self.doMenu()
        else:
            self.screen.setStatusText("User already exists")   
            self.screen.cancel_btn['state'] = DGG.NORMAL
            self.screen.register_btn['state'] = DGG.NORMAL
开发者ID:2015-CS454,项目名称:lobby-team,代码行数:84,代码来源:newMain.py

示例8: main

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
def main():
    
    menu = Menu()
    menu.run()
开发者ID:dimmk0,项目名称:Hummer,代码行数:6,代码来源:hummer.py

示例9: Menu

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
top = Menu('Main','Welcome to NYC Resistor', [
    ('Frequently Asked Questions',mpass),
    ('main.py',Pager('main code','main.py')),
    ('Play a game',games)
])

def eat(m):
    while len(m.recv(1)) == 0:
        pass
 
if __name__ == '__main__':
    port = os.getenv('PORT','/dev/ttyACM0')
    baud = int(os.getenv('BAUD','4800'))
    logging.info('Opening minitel on port {} at {} 8N1'.format(port,baud))
    try:
        if port == 'SIM':
            m = minitel_curses.MinitelCurses()
        else:
            m = minitel.Minitel(port,baud,minitel.MODE_VIDEOTEX,hax=True)
	while True:
            eat(m)
            top.run(m,[])
            logging.info('Top level menu exited; waiting for input.')
    except:
        logging.exception('Could not open connection to minitel; aborting.')
        sys.exit(1)
    finally:
        m.close()

    
开发者ID:phooky,项目名称:Minitel,代码行数:30,代码来源:main.py

示例10: Menu

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
           'E': IMAGES['floorEnd'],
           '/': IMAGES['spacer'],
           '*': IMAGES['forkLiftUp']}

pygame.init()
FPSCLOCK = pygame.time.Clock()
DISPLAYSURF = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Sokoban v 0.01')
BASICFONT = pygame.font.SysFont('monospace', 18)
SCOREFONT = pygame.font.SysFont('arial', 28)
SCOREFONT.set_bold(True)

# Create main menu
menu_items = ('Press enter to start', '')
mainMenu = Menu(DISPLAYSURF, menu_items, BGCOLOR, BASICFONT, TEXTCOLOR)
mainMenu.run()

def movePlayerRight():
    nextPos = maze.getCharAtPos(player.getRow(), player.getCol() + 1)
    if nextPos == "#":
        print "This is a wall"
    else:
        if nextPos == "C":
            # Check that the next position is clear for the crate
            nextCratePos = maze.getCharAtPos(player.getRow(), player.getCol() + 2)
            if nextCratePos == "#" or nextCratePos == "C":
                # path is obstructed
                movePlayerLeft()
                player.decrementMoves()
            else:
                # path is clear to push crate
开发者ID:xerox3333,项目名称:SokobanPygame,代码行数:33,代码来源:main.py

示例11: Config

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import run [as 别名]
#!/usr/bin/python

import time, date_time
import speak
from menu import Menu
from persistant import get
from config import Config

c = Config()

def visit(item) :
   action = item.getAttribute('action')
   if action == "" :
      text = item.getAttribute('title')
   else : 
      text = eval(action)
   if text is not None :
      mtext = speak.expand(text,speak.tracker_substitutes)
      speak.say(mtext,c.menu_voice,c.menu_speed)
      print (text)
   
menu = Menu(c.menu)
menu.run(visit) 

开发者ID:KitWallace,项目名称:routefinder,代码行数:25,代码来源:start_menu.py


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