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


Python main函数代码示例

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


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

示例1: cargar_usuarios

def cargar_usuarios():
    Main()  #Me lleva  al menu de usuarios
    print ("Ingrese aqui su DNI")
    dniUsuario = input()
    usuarioJugando = buscarUsuarioEnTXT(int(CantidadUsuarios()),
    int(dniUsuario), RecuperarUsuarios())
    main(usuarioJugando)
开发者ID:NykolaiPerezVelez,项目名称:JuegoDondeSeminario,代码行数:7,代码来源:menu_mejorado.py

示例2: __init__

    def __init__(self):
        """
        __init__(self)
            this function will initiate the startwindow
        """
        environ['SDL_VIDEO_CENTERED']='1'
        pygame.init()
        seticon('images/icon.png')
        start_screen = pygame.display.set_mode((498,501),NOFRAME,32)
        init_background = pygame.image.load("images/init_bg.png").convert()
        pygame.display.set_caption("Dominoes!")
        onQuite_clicked_img = pygame.image.load("images/onclicked1.png")
        onenjoy_clicked_img = pygame.image.load("images/onclicked2.png")
        
        bg_sound = path.join('sounds','bg.wav')
        soundtrack = pygame.mixer.Sound(bg_sound)
        soundtrack.set_volume(0.9)
        soundtrack.play(-1)
        
        enjoy_sound = path.join('sounds','enjoy.wav')
        enjoyTick = pygame.mixer.Sound(enjoy_sound)
        enjoyTick.set_volume(0.9)

        quit_sound = path.join('sounds','quit.wav')
        quitTick = pygame.mixer.Sound(quit_sound)
        quitTick.set_volume(0.9)
                
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    exit()
                     
                if event.type == MOUSEBUTTONDOWN:
                    x,y = pygame.mouse.get_pos()
                    if x >= 172 and x <= 320 and y >= 435 and y<=480:
                        start_screen.blit(onenjoy_clicked_img,(190,438))
                        enjoyTick.play(0)
                        pygame.display.update()
                        pygame.time.wait(500)
                        main()
                    
                    if x >= 324 and x <= 423 and y >= 327 and y<=369:
                        start_screen.blit(onQuite_clicked_img,(317,322))
                        quitTick.play(1)
                        pygame.display.update()
                        exit()
                
                if event.type == KEYDOWN:
                    if event.key == K_KP_ENTER or event.key == K_SPACE:
                        enjoyTick.play(0)
                        main()
                        
                    if event.key == K_ESCAPE:
                        quitTick.play(0)
                        exit()
                        
            
            start_screen.blit(init_background,(0,0))
            pygame.display.update()
开发者ID:LibreGames,项目名称:dominos,代码行数:59,代码来源:Dominos.py

示例3: script

def script(argv):
    # Save PEP 3122!
    if "." in __name__:
        from .script import main
    else:
        from script import main

    main(argv, version)
开发者ID:AmaanC,项目名称:saxo,代码行数:8,代码来源:core.py

示例4: sendToSolve

    def sendToSolve(self):
        SOLVESTATE = 1

        self.buttonSolve["command"] = " "
        self.reset_cube()
        text_file = open("UserData.txt", "w")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[WHITEFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[WHITEFACE[i]]))
        text_file.write("\n")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[YELLOWFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[YELLOWFACE[i]]))
        text_file.write("\n")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[ORANGEFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[ORANGEFACE[i]]))
        text_file.write("\n")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[REDFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[REDFACE[i]]))
        text_file.write("\n")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[GREENFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[GREENFACE[i]]))
        text_file.write("\n")
        for i in range(0,4):
            text_file.write("%s " % str(COLORS[BLUEFACE[i]]))
        for i in range(5,9):
            text_file.write("%s " % str(COLORS[BLUEFACE[i]]))
        text_file.write("\n")
        text_file.close()

        main()

        notfound = True
        self.thingsToDo = []
        while notfound:
            with open("instructions.txt") as file:
                for line in file:
                    self.thingsToDo.append(line.strip())
                notfound = False
        currThing = 0
        for i in range(len(self.thingsToDo)):
            if currThing == 0: self.label1(type = str(self.thingsToDo(i)))
            if currThing == 1: self.label2(type = str(self.thingsToDo(i)))
            if currThing == 2: self.label3(type = str(self.thingsToDo(i)))
            if currThing == 3: currThing = 0
开发者ID:DLukeNelson,项目名称:Rubiks_Cube_Solver,代码行数:53,代码来源:RubicksCubeGUI.py

示例5: menu_inicial

def menu_inicial():
    qtd_botao = 5
    textos_botao = ["Iniciar", u"Instruções", "Recordes", "Sobre", "Sair"]
    botoes = []
    for i in range(qtd_botao):
        botao = Botao(tela)
        botao.texto = textos_botao[i]
        botao.redimensionar(150, 50)
        botoes.append(botao)

    rodando = True
    pygame.mouse.set_visible(False)
    while rodando:
        pos_mouse = pos_mouse_x, pos_mouse_y = pygame.mouse.get_pos()

        LIMITE_BOTAO_X = pos_mouse_x > 20 and pos_mouse_x < 170
        LIMITE_1 = LIMITE_BOTAO_X and (pos_mouse_y > 300 and pos_mouse_y < 350)
        LIMITE_2 = LIMITE_BOTAO_X and (pos_mouse_y > 355 and pos_mouse_y < 405)
        LIMITE_3 = LIMITE_BOTAO_X and (pos_mouse_y > 410 and pos_mouse_y < 460)
        LIMITE_4 = LIMITE_BOTAO_X and (pos_mouse_y > 465 and pos_mouse_y < 515)
        LIMITE_5 = LIMITE_BOTAO_X and (pos_mouse_y > 520 and pos_mouse_y < 570)
        LIMITES = [LIMITE_1, LIMITE_2, LIMITE_3, LIMITE_4, LIMITE_5]

        tela.fill(branco)
        tela.blit(img_fundo, (0, 0))
        botao_y = 300
        for botao in botoes:
            botao.mostrar_botao(20, botao_y)
            texto = font.render(botao.texto, True, branco)
            tela.blit(texto, (40, botao_y + 15))
            botao_y += 55
        cursor.mostrar(pos_mouse)

        img_selecao = pygame.image.load("img/homem_neve.png")
        for i in range(len(LIMITES)):
            if LIMITES[i]:
                tela.blit(img_selecao, (175, 300 + 55 * i))

        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == pygame.MOUSEBUTTONDOWN:
                if LIMITES[0]:
                    tema_inicial.stop()
                    main()
                elif LIMITES[1]:
                    sub_menu("instrucoes")
                elif LIMITES[2]:
                    sub_menu("recordes")
                elif LIMITES[3]:
                    sub_menu("sobre")
                elif LIMITES[4]:
                    rodando = False
                    pygame.display.quit()
开发者ID:victorhundo,项目名称:PySki,代码行数:53,代码来源:menu.py

示例6: menu_final

def menu_final(tempo, skiador, obstaculos, homem_neve):
    texto_fim = font.render("FIM DE JOGO", True, branco)
    pontuacao = funcoes.cronometro(tempo)
    texto_pontuacao = font.render(pontuacao, True, branco)
    texto_aviso = font.render("Enter para Jogar", True, branco)
    nome_usuario = ""

    imagem_input = pygame.image.load("img/input-field.png")
    imagem_input = pygame.transform.scale(imagem_input, (234, 46))
    imagem_menu = pygame.image.load("img/menu.png")
    imagem_logo = pygame.image.load("img/logo_pyski.png")
    font_menor = pygame.font.SysFont("arial", 12)

    rodando = True
    while rodando:
        tela.fill(branco)
        skiador.mostrar_skiador()
        for obstaculo in obstaculos:
            obstaculo.mostrar_obstaculo()

        homem_neve.mostrar()

        texto_nome_usuario = font.render(nome_usuario, True, (0, 0, 0))
        texto_digite_nome = font_menor.render("Digite seu nome", True, branco)

        tela.blit(imagem_menu, (250, 80))
        tela.blit(imagem_input, (285, 190))
        tela.blit(texto_pontuacao, (355, 150))
        tela.blit(texto_nome_usuario, (300, 200))
        tela.blit(texto_fim, (340, 380))
        tela.blit(texto_aviso, (330, 480))
        tela.blit(texto_digite_nome, (360, 240))
        tela.blit(imagem_logo, (335, 330))

        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                rodando = False
                pygame.display.quit()

            elif event.type == pygame.KEYDOWN:
                if event.unicode.isalpha():
                    if len(nome_usuario) <= 10:
                        nome_usuario += event.unicode.upper()
                elif event.key == pygame.K_BACKSPACE:
                    nome_usuario = nome_usuario[:-1]

                elif event.key == pygame.K_RETURN:
                    if nome_usuario == "":
                        nome_usuario = "JOGADOR"
                    funcoes.ranking(nome_usuario, tempo)
                    main()
开发者ID:victorhundo,项目名称:PySki,代码行数:52,代码来源:menu.py

示例7: test_with_initially_incomplete_arguments

 def test_with_initially_incomplete_arguments(self):
     """should prompt user_for files, then proceed"""
     mkr = mock.Mock(side_effect=["vvexport_471745.txt"])
     out = StringIO()
     trans = main(["-s limesurvey_survey_471745.txt"], mkr, out)
     self.assertTrue("survey structure txt is limesurvey_survey_471745.txt"
             in out.getvalue())
     mkr = mock.Mock(side_effect=["limesurvey_survey_471745.txt"])
     out = StringIO()
     trans = main(["-v vvexport_471745.txt"], mkr, out)
     self.assertTrue("response vvexport txt is vvexport_471745.txt"
             in out.getvalue())
     self.assertIn("translated_EDNA_471745.txt", os.listdir("."))
开发者ID:wceichelb,项目名称:lime_db_transfer,代码行数:13,代码来源:TestMain.py

示例8: run

 def run(self):
     global text, time_out, current_theme, results, song
     time_out = True
     song = None
     results = main(text)
     results = results.decode("gbk")
     if text == "#":
         results = '<p style="font-family:Microsoft Yahei;font:24px">Stuart:好吧...</p>'.decode("utf-8")
     if results[-5:] == "@sing":
         song = str(random.randint(1, 2))
         lyric_file = open("data/sounds/" + song + ".txt", "r")
         lyric = lyric_file.read()
         lyric_file.close()
         href_file = open(style_path + "href.txt", "r")
         href = href_file.read()
         href_file.close()
         results = (
             '<p style="font-family:Microsoft Yahei;font:24px">'
             + lyric.replace("\n", "<br>")
             + '<br><a style="text-decoration:none;color:#'
             + href
             + '" href="#">别唱了!</a></p>'
         )
         results = results.decode("utf-8")
     time_out = False
     self.trigger.emit()
开发者ID:Jackeriss,项目名称:Companions,代码行数:26,代码来源:Companions.py

示例9: entry

def entry(isPublic, isSelectable, threadNum, appID, target):

    log_utils.info("Curr Python Version::%s", config_utils.get_py_version())

    print(u"**********所有游戏**********")
    print(u"\t appID \t\t 游戏文件夹 \t\t 游戏名称 \n\n")

    games = config_utils.getAllGames()
    if games != None and len(games) > 0:
        for ch in games:
            print(u"\t %s \t\t %s \t\t\t%s" % (ch['appID'], ch['appName'], ch['appDesc']))

    sys.stdout.write(u"请选择一个游戏(输入appID):")
    sys.stdout.flush()

    selectedGameID = str(appID)

    game = getGameByAppID(selectedGameID, games)

    log_utils.info("current selected game is %s(%s)", game['appName'], game['appDesc'])

    if isSelectable:
        return main(game, isPublic, target)
    else:
        return main_thread.main(game, isPublic, threadNum)
开发者ID:WaitGodot,项目名称:U8PackageTools,代码行数:25,代码来源:packGame.py

示例10: launcher

def launcher():
    outputs = main()

    #update the text
    tex.insert(END, outputs)

    # join
    sb.config(command=tex.yview)
    tex.config(yscrollcommand=sb.set)
开发者ID:Guerillero,项目名称:OpenAnthroStat,代码行数:9,代码来源:OpenAnthroStat.py

示例11: test_with_initially_empty_arguments

 def test_with_initially_empty_arguments(self):
     """should prompt user_for files, then proceed"""
     mkr = mock.Mock(side_effect=["limesurvey_survey_471745.txt",
         "vvexport_471745.txt"])
     out = StringIO()
     trans = main([], mkr, out)
     self.assertEqual(trans.survey_structure.sid, "471745",
             "should produce trans")
     self.assertIn("translated_EDNA_471745.txt", os.listdir("."),
             "should write output")
开发者ID:wceichelb,项目名称:lime_db_transfer,代码行数:10,代码来源:TestMain.py

示例12: de

def de():
  def evaluate(frontier):
    for n, i in enumerate(frontier):
      assign(i)
      scores[n] = main()[-1] # score[i]= [pd,pf,prec, g], the second objecit in returned value
    print scores
    return scores

  def best(scores):
    ordered = sorted(scores.items(), key=lambda x: x[1][-1])  # alist of turple
    bestconf = frontier[ordered[-1][0]] #[(0, [100, 73, 9, 42]), (1, [75, 41, 12, 66])]
    bestscore = ordered[-1][-1][-1]
    return bestconf, bestscore

  scores = {}
  global The  
  The.option.tuning = True
  np = Settings.de.np
  repeats = Settings.de.repeats
  life = Settings.de.life
  changed = False
  evaluation = 0
  frontier = [generate() for _ in xrange(np)]
  scores = evaluate(frontier)
  bestconf, bestscore = best(scores)
  for k in xrange(repeats):
    if life <= 0 or bestscore >=90:
      break
    nextgeneration = []
    for n, f in enumerate(frontier):
      new = update(n, f, frontier)
      assign(new)
      newscore = main()[-1]
      evaluation +=1
      if newscore[-1] > scores[n][-1] : # g value
        nextgeneration.append(new)
        scores[n] = newscore[:]
        changed = True
      else:
        nextgeneration.append(f)
    frontier = nextgeneration[:]
    newbestconf, newbestscore = best(scores)
    if newbestscore > bestscore:
      print "newbestscore %s:" % str(newbestscore)
      print "bestconf %s :" % str(newbestconf)
      bestscore = newbestscore
      bestconf = newbestconf[:]
    if not changed: # the pareto frontier changed or not
      life -= 1
    changed = False
  assign(bestconf)
  writeResults(bestscore, evaluation)
开发者ID:michalt25,项目名称:Courses,代码行数:52,代码来源:de.py

示例13: main

"""
Entrypoint module, in case you use `python -m{{cookiecutter.package_name}}`.


Why does this file exist, and why __main__? For more info, read:

- https://www.python.org/dev/peps/pep-0338/
- https://docs.python.org/2/using/cmdline.html#cmdoption-m
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
"""
{%- if cookiecutter.command_line_interface|lower == 'plain' %}
import sys
{% endif %}
from {{cookiecutter.package_name}}.cli import main

if __name__ == "__main__":
{%- if cookiecutter.command_line_interface|lower == 'click' %}
    main()
{%- else %}
    sys.exit(main())
{%- endif %}
开发者ID:SimonBiggs,项目名称:cookiecutter-pylibrary,代码行数:21,代码来源:__main__.py

示例14: environment_class

    _LOG.info(
        'Target is url %s from application_id %s on server %s',
        parsed_args.course_url_prefix, parsed_args.application_id,
        parsed_args.server)

    if not parsed_args.disable_remote:
        environment_class(
            parsed_args.application_id, parsed_args.server).establish()

    _force_config_reload()

    if parsed_args.mode == _MODE_DELETE:
        _delete(
            parsed_args.course_url_prefix, parsed_args.type,
            parsed_args.batch_size)
    elif parsed_args.mode == _MODE_DOWNLOAD:
        _download(
            parsed_args.type, parsed_args.archive_path,
            parsed_args.course_url_prefix, parsed_args.datastore_types,
            parsed_args.batch_size, privacy_transform_fn)
    elif parsed_args.mode == _MODE_RUN:
        _run_custom(parsed_args)
    elif parsed_args.mode == _MODE_UPLOAD:
        _upload(
            parsed_args.type, parsed_args.archive_path,
            parsed_args.course_url_prefix, parsed_args.force_overwrite)


if __name__ == '__main__':
    main(PARSER.parse_args())
开发者ID:Domofera,项目名称:Domofera_MOOC,代码行数:30,代码来源:etl.py

示例15: print

            window.current_frame[-2] = window.player.previous_reward
            window.current_frame[-1] = window.game_over

            
            # Send the bytes of the current frame
            self.request.sendall(window.current_frame)
            
            action_count += 1
            if action_count % COUNTER_DISPLAY_FREQUENCY == 0:
                print("TOTAL ACTION COUNT: %d" % action_count)


if __name__ == '__main__':
    global window

    # Verify the necessary directories exist and conform to the configurations in this file
    verify_directories()
    # Verify the necessary files conform to the configurations in this file
    verify_files()
    
    window = main()

    HOST, PORT = TCP_HOST, TCP_PORT

    # Create the server, binding to localhost on port 9999
    server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)

    # Activate the server; this will keep running until you
    # interrupt the program with Ctrl-C
    server.serve_forever()
开发者ID:menwhitehead,项目名称:DeepMindCraft,代码行数:30,代码来源:game_server.py


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