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


Python perspective_manager.get_perspective函数代码示例

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


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

示例1: on_copy_fen_activate

    def on_copy_fen_activate(self, widget):
        persp = perspective_manager.get_perspective("games")
        if perspective_manager.current_perspective == persp:
            persp.cur_gmwidg().board.view.copy_fen()
            return

        persp = perspective_manager.get_perspective("database")
        if perspective_manager.current_perspective == persp:
            if persp.preview_panel is not None:
                persp.preview_panel.boardview.copy_fen()
开发者ID:leogregianin,项目名称:pychess,代码行数:10,代码来源:Main.py

示例2: accept_new_properties

    def accept_new_properties(button, *args):
        persp = perspective_manager.get_perspective("games")
        gamemodel = persp.cur_gmwidg().gamemodel

        # Remove the existing tags in string format
        for tag in list(gamemodel.tags):
            if isinstance(gamemodel.tags[tag], str):
                del gamemodel.tags[tag]

        # Copy of the tags from the dedicated fields
        for tag in dedicated_tags:
            gamemodel.tags[tag] = widgets["%s_entry" % tag.lower()].get_text()

        combo = widgets["result_combo"]
        tree_iter = combo.get_active_iter()
        if tree_iter is not None:
            model = combo.get_model()
            status = model[tree_iter][0]
            if status != gamemodel.status:
                gamemodel.status = status
                gamemodel.checkStatus()

        # Copy the extra tags from the editor
        for tag in tags_store:
            if tag[0] != "" and tag not in dedicated_tags:
                gamemodel.tags[tag[0]] = tag[1]

        widgets["game_info"].hide()

        # Apply some settings to the game model
        gamemodel.players[BLACK].setName(gamemodel.tags["Black"])
        gamemodel.players[WHITE].setName(gamemodel.tags["White"])
        gamemodel.emit("players_changed")
        return True
开发者ID:leogregianin,项目名称:pychess,代码行数:34,代码来源:gameinfoDialog.py

示例3: startClicked

    def startClicked(self, button):
        color = self.widgets["colorDock"].get_child().get_active()
        if color == 2:
            color = random.choice([WHITE, BLACK])

        opp = self.widgets["opponentDock"].get_child()
        tree_iter = opp.get_active_iter()
        if tree_iter is not None:
            model = opp.get_model()
            engine = model[tree_iter][1]

        opponent = self.widgets["opponentDock"].get_child().get_active()
        difficulty = int(self.widgets["skillSlider"].get_value())

        gamemodel = GameModel(TimeModel(5 * 60, 0))

        name = conf.get("firstName")
        player0tup = (LOCAL, Human, (color, name), name)
        if opponent == 0:
            name = conf.get("secondName")
            player1tup = (LOCAL, Human, (1 - color, name), name)
        else:
            engine = discoverer.getEngineByName(engine)
            name = discoverer.getName(engine)
            player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, 1 - color, difficulty,
                           variants[NORMALCHESS], 5 * 60, 0), name)

        perspective = perspective_manager.get_perspective("games")
        if color == WHITE:
            create_task(perspective.generalStart(gamemodel, player0tup, player1tup))
        else:
            create_task(perspective.generalStart(gamemodel, player1tup, player0tup))
开发者ID:leogregianin,项目名称:pychess,代码行数:33,代码来源:TaskerManager.py

示例4: start_endgame_from

def start_endgame_from(pieces):
        fen = create_fen(pieces)

        timemodel = TimeModel(0, 0)
        gamemodel = LearnModel(timemodel)
        gamemodel.set_learn_data(ENDGAME, pieces)

        player_name = conf.get("firstName", _("You"))
        p0 = (LOCAL, Human, (WHITE, player_name), player_name)

        engine = discoverer.getEngineByName(discoverer.getEngineLearn())
        ponder_off = True
        engine_name = discoverer.getName(engine)
        p1 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, BLACK, 20, variants[NORMALCHESS], 60, 0, 0, ponder_off), engine_name)

        def restart_analyzer(gamemodel):
            asyncio.async(gamemodel.restart_analyzer(HINT))
        gamemodel.connect("learn_success", restart_analyzer)

        def start_analyzer(gamemodel):
            asyncio.async(gamemodel.start_analyzer(HINT, force_engine=discoverer.getEngineLearn()))
        gamemodel.connect("game_started", start_analyzer)

        perspective = perspective_manager.get_perspective("games")
        asyncio.async(perspective.generalStart(gamemodel, p0, p1, loaddata=(StringIO(fen), fen_loader, 0, -1)))
开发者ID:teacoffee2017,项目名称:pychess,代码行数:26,代码来源:EndgamesPanel.py

示例5: anal_combo_set_value

def anal_combo_set_value(combobox, value, show_arrow_check, ana_check,
                         analyzer_type):
    engine = discoverer.getEngineByMd5(value)
    if engine is None:
        combobox.set_active(0)
        # This return saves us from the None-engine being used
        # in later code  -Jonas Thiem
        return
    else:
        try:
            index = list(discoverer.getAnalyzers()).index(engine)
        except ValueError:
            index = 0
        combobox.set_active(index)

    from pychess.widgets.gamewidget import widgets
    perspective = perspective_manager.get_perspective("games")
    for gmwidg in perspective.gamewidgets:
        spectators = gmwidg.gamemodel.spectators
        md5 = engine.get('md5')

        if analyzer_type in spectators and \
                spectators[analyzer_type].md5 != md5:
            gmwidg.gamemodel.remove_analyzer(analyzer_type)
            asyncio.async(gmwidg.gamemodel.start_analyzer(analyzer_type))
            if not widgets[show_arrow_check].get_active():
                gmwidg.gamemodel.pause_analyzer(analyzer_type)
开发者ID:bboutkov,项目名称:pychess,代码行数:27,代码来源:preferencesDialog.py

示例6: print_obj_referrers

def print_obj_referrers():
    perspective = perspective_manager.get_perspective("games")
    if len(perspective.gamewidgets) > 0:
        return

    for klass in (
        ICGameModel,
        GameModel,
        GameWidget,
        BoardView,
        BoardControl,
        CECPEngine,
        UCIEngine,
        Human,
        ICPlayer,
        # TODO:
        # ArrowButton,
        # StarArrowButton,
        # HighlightArea,
        # Board,
        # LBoard,
    ):
        obj_referrers(klass)

    if ICLogon.dialog is None or not hasattr(ICLogon.dialog, "lounge"):
        for klass in (
            PyDockTop,
            PyDockLeaf,
        ):
            obj_referrers(klass)

    print("---------------------------------")
开发者ID:teacoffee2017,项目名称:pychess,代码行数:32,代码来源:debug.py

示例7: refresh_elo_rating_change

def refresh_elo_rating_change(widgets):
    persp = perspective_manager.get_perspective("games")
    gamemodel = persp.cur_gmwidg().gamemodel

    site = gamemodel.tags["Site"]
    if site is not None and ("lichess.org" in site or "chessclub.com" in site or "freechess.org" in site):
        # TODO : lichess takes 3 parameters per player
        widgets["w_elo_change"].set_text("")
        widgets["b_elo_change"].set_text("")
        return

    welo = widgets["whiteelo_entry"].get_text()
    belo = widgets["blackelo_entry"].get_text()

    wchange = get_elo_rating_change_str(gamemodel, WHITE, welo, belo)
    widgets["w_elo_change"].set_text(wchange)
    if wchange.startswith("+") or wchange.startswith("-"):
        widgets["w_elo_change"].override_color(Gtk.StateFlags.NORMAL, red if wchange.startswith("-") else green)
    else:
        widgets["w_elo_change"].override_color(Gtk.StateFlags.NORMAL, black)

    bchange = get_elo_rating_change_str(gamemodel, BLACK, welo, belo)
    widgets["b_elo_change"].set_text(bchange)
    if bchange.startswith("+") or bchange.startswith("-"):
        widgets["b_elo_change"].override_color(Gtk.StateFlags.NORMAL, red if bchange.startswith("-") else green)
    else:
        widgets["b_elo_change"].override_color(Gtk.StateFlags.NORMAL, black)
开发者ID:leogregianin,项目名称:pychess,代码行数:27,代码来源:gameinfoDialog.py

示例8: on_drag_received

 def on_drag_received(self, widget, context, x, y, selection, target_type, timestamp):
     if target_type == TARGET_TYPE_URI_LIST:
         uris = selection.get_uris()
         for uri in uris:
             if uri.lower().endswith(".fen"):
                 newGameDialog.loadFileAndRun(uri)
             else:
                 perspective = perspective_manager.get_perspective("database")
                 perspective.open_chessfile(uri)
开发者ID:leogregianin,项目名称:pychess,代码行数:9,代码来源:Main.py

示例9: recent_item_activated

 def recent_item_activated(self):
     uri = self.get_current_uri()
     try:
         urlopen(unquote(uri)).close()
         perspective = perspective_manager.get_perspective("database")
         perspective.open_chessfile(self.get_current_uri())
     except (IOError, OSError):
         # shomething wrong whit the uri
         recentManager.remove_item(uri)
开发者ID:bboutkov,项目名称:pychess,代码行数:9,代码来源:Main.py

示例10: start_puzzle_game

def start_puzzle_game(gamemodel, filename, records, index, rec, from_lesson=False):
    gamemodel.set_learn_data(PUZZLE, filename, index, len(records), from_lesson=from_lesson)

    engine = discoverer.getEngineByName(discoverer.getEngineLearn())
    ponder_off = True

    color = gamemodel.boards[0].color

    w_name = "" if rec["White"] is None else rec["White"]
    b_name = "" if rec["Black"] is None else rec["Black"]

    player_name = conf.get("firstName")
    engine_name = discoverer.getName(engine)

    if rec["Event"].startswith("Lichess Practice"):
        w_name = player_name if color == WHITE else engine_name
        b_name = engine_name if color == WHITE else player_name

    opp_name = engine_name if rec["Event"].startswith("Lichess Practice") else b_name

    if color == WHITE:
        p0 = (LOCAL, Human, (WHITE, w_name), w_name)
        p1 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, BLACK, 20, variants[NORMALCHESS], 20, 0, 0, ponder_off), b_name)
    else:
        p0 = (ARTIFICIAL, discoverer.initPlayerEngine,
              (engine, WHITE, 20, variants[NORMALCHESS], 20, 0, 0, ponder_off), w_name)
        p1 = (LOCAL, Human, (BLACK, b_name), b_name)

    def on_game_started(gamemodel, name, color):
        perspective.activate_panel("annotationPanel")
        create_task(gamemodel.start_analyzer(HINT, force_engine=discoverer.getEngineLearn()))
        gamemodel.players[1 - color].name = name
        gamemodel.emit("players_changed")
    gamemodel.connect("game_started", on_game_started, opp_name, color)

    def goal_checked(gamemodle):
        if gamemodel.reason == PRACTICE_GOAL_REACHED:
            if from_lesson:
                progress = lessons_solving_progress[gamemodel.source]
            else:
                progress = puzzles_solving_progress[gamemodel.source]

            progress[gamemodel.current_index] = 1

            if from_lesson:
                lessons_solving_progress[gamemodel.source] = progress
            else:
                puzzles_solving_progress[gamemodel.source] = progress
    gamemodel.connect("goal_checked", goal_checked)

    gamemodel.variant.need_initial_board = True
    gamemodel.status = WAITING_TO_START

    perspective = perspective_manager.get_perspective("games")
    create_task(perspective.generalStart(gamemodel, p0, p1))
开发者ID:leogregianin,项目名称:pychess,代码行数:56,代码来源:PuzzlesPanel.py

示例11: on_spy_mode_activate

 def on_spy_mode_activate(self, widget):
     perspective = perspective_manager.get_perspective("games")
     if perspective is None:
         return
     for gmwidg in perspective.gamewidgets:
         if gmwidg.isInFront():
             if widget.get_active():
                 gmwidg.gamemodel.resume_analyzer(SPY)
             else:
                 gmwidg.gamemodel.pause_analyzer(SPY)
开发者ID:bboutkov,项目名称:pychess,代码行数:10,代码来源:Main.py

示例12: on_set_up_position_activate

 def on_set_up_position_activate(self, widget):
     rotate_menu = gamewidget.getWidgets()["rotate_board1"]
     rotate_menu.set_sensitive(True)
     persp = perspective_manager.get_perspective("games")
     gmwidg = persp.cur_gmwidg()
     if gmwidg is not None:
         ply = gmwidg.board.view.shown
         variation = gmwidg.board.view.shown_variation_idx
         fen = gmwidg.gamemodel.getBoardAtPly(ply, variation).asFen()
     else:
         fen = None
     newGameDialog.SetupPositionExtension.run(fen)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:12,代码来源:Main.py

示例13: openClicked

    def openClicked(self, button):
        if self.widgets["createNew"].get_active():
            perspective = perspective_manager.get_perspective("database")
            perspective.create_database()

        else:
            tree_iter = self.recent_combo.get_active_iter()
            if tree_iter is None:
                return
            else:
                model = self.recent_combo.get_model()
                uri = model[tree_iter][0]

            try:
                urlopen(unquote(uri)).close()
                perspective = perspective_manager.get_perspective("database")
                perspective.open_chessfile(unquote(uri))
                recent_manager.add_item(uri)
            except (IOError, OSError):
                # shomething wrong whit the uri
                recent_manager.remove_item(uri)
开发者ID:leogregianin,项目名称:pychess,代码行数:21,代码来源:TaskerManager.py

示例14: loadFileAndRun

def loadFileAndRun(uri):
    parts = splitUri(uri)
    uri = parts[1] if len(parts) == 2 else parts[0]
    loader = enddir[uri[uri.rfind(".") + 1:]]
    timemodel = TimeModel(0, 0)
    gamemodel = GameModel(timemodel)
    white_name = _("White")
    black_name = _("Black")
    p0 = (LOCAL, Human, (WHITE, white_name), white_name)
    p1 = (LOCAL, Human, (BLACK, black_name), black_name)
    perspective = perspective_manager.get_perspective("games")
    create_task(perspective.generalStart(gamemodel, p0, p1, (uri, loader, 0, -1)))
开发者ID:leogregianin,项目名称:pychess,代码行数:12,代码来源:newGameDialog.py

示例15: on_invanalyzer_check_toggled

 def on_invanalyzer_check_toggled(check):
     self.widgets["inv_analyzers_vbox"].set_sensitive(check.get_active())
     perspective = perspective_manager.get_perspective("games")
     if len(perspective.gamewidgets) != 0:
         if check.get_active():
             for gmwidg in perspective.gamewidgets:
                 asyncio.async(gmwidg.gamemodel.restart_analyzer(SPY))
                 if not widgets["spy_mode"].get_active():
                     gmwidg.gamemodel.pause_analyzer(SPY)
         else:
             for gmwidg in perspective.gamewidgets:
                 gmwidg.gamemodel.remove_analyzer(SPY)
开发者ID:bboutkov,项目名称:pychess,代码行数:12,代码来源:preferencesDialog.py


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