Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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("---------------------------------")
Ejemplo n.º 7
0
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)))
Ejemplo n.º 8
0
def loadPgnAndRun(data):
    if data in [None, '']:
        return False
    perspective = perspective_manager.get_perspective("games")
    p0 = (LOCAL, Human, (WHITE, _("White")), _("White"))
    p1 = (LOCAL, Human, (BLACK, _("Black")), _("Black"))
    create_task(perspective.generalStart(GameModel(), p0, p1, (StringIO(data), enddir['pgn'], 0, -1)))
    return True
Ejemplo n.º 9
0
 def on_load_game1_activate(self, widget):
     opendialog, savedialog, enddir, savecombo, savers = game_handler.getOpenAndSaveDialogs(
     )
     response = opendialog.run()
     if response == Gtk.ResponseType.ACCEPT:
         filename = opendialog.get_filename()
         perspective = perspective_manager.get_perspective("database")
         perspective.open_chessfile(filename)
     opendialog.hide()
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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)
 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
         recent_manager.remove_item(uri)
Ejemplo n.º 13
0
 def on_drag_received(self, widget, context, x, y, selection, target_type, timestamp):
     if target_type == TARGET_TYPE_URI_LIST:
         uris = selection.get_uris()
         if len(uris) == 1 and uris[0].lower()[-4:] in (".pgn", ".pdb", "epd"):
             uri = uris[0]
             perspective = perspective_manager.get_perspective("database")
             perspective.open_chessfile(uri)
         else:
             newGameDialog.loadFilesAndRun(uris)
Ejemplo n.º 14
0
def showDesignGW():
    global designGW
    perspective = perspective_manager.get_perspective("games")
    designGW = GameWidget(GameModel(), perspective)
    if isDesignGWShown():
        return
    getWidgets()["show_sidepanels"].set_active(True)
    getWidgets()["show_sidepanels"].set_sensitive(False)
    perspective.attachGameWidget(designGW)
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
def getheadbook():
    if len(key2gmwidg) == 0:
        return None
    perspective = perspective_manager.get_perspective("games")
    headbook = perspective.widget.get_children()[0].get_children(
    )[0].get_child()
    # to help StoryText create widget description
    headbook.get_tab_label_text = customGetTabLabelText
    return headbook
Ejemplo n.º 17
0
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", _("You"))
    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")
        asyncio.async(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")
    asyncio.async(perspective.generalStart(gamemodel, p0, p1))
Ejemplo n.º 18
0
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))
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 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:
                 create_task(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)
Ejemplo n.º 21
0
 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)
Ejemplo n.º 22
0
 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)
Ejemplo n.º 23
0
    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)
Ejemplo n.º 24
0
def start_lesson_from(filename, index=None):
    if filename.startswith("lichess_study"):
        chessfile = PGNFile(
            protoopen(addDataPrefix("learn/lessons/%s" % filename),
                      encoding="utf-8"))
    else:
        chessfile = PGNFile(
            protoopen(addDataPrefix("learn/lessons/%s" % filename)))
    chessfile.limit = 1000
    chessfile.init_tag_database()
    records, plys = chessfile.get_records()

    progress = lessons_solving_progress.get(filename, [0] * chessfile.count)

    if index is None:
        index = progress.index(0)

    rec = records[index]

    timemodel = TimeModel(0, 0)
    gamemodel = LearnModel(timemodel)
    gamemodel.set_learn_data(LESSON, filename, index, len(records))

    chessfile.loadToModel(rec, -1, gamemodel)

    color = gamemodel.boards[0].color
    player_name = conf.get("firstName", _("You"))

    w_name = player_name if color == WHITE else "PyChess"
    b_name = "PyChess" if color == WHITE else player_name

    p0 = (LOCAL, Human, (WHITE, w_name), w_name)
    p1 = (LOCAL, Human, (BLACK, b_name), b_name)

    def learn_success(gamemodel):
        chessfile.loadToModel(rec, -1, gamemodel)
        progress = lessons_solving_progress[gamemodel.source]
        progress[gamemodel.current_index] = 1
        lessons_solving_progress[gamemodel.source] = progress
        asyncio. async (gamemodel.restart_analyzer(HINT))

    gamemodel.connect("learn_success", learn_success)

    def on_game_started(gamemodel):
        perspective.activate_panel("annotationPanel")
        asyncio. async (gamemodel.start_analyzer(
            HINT, force_engine=discoverer.getEngineLearn()))

    gamemodel.connect("game_started", on_game_started)

    gamemodel.status = WAITING_TO_START
    perspective = perspective_manager.get_perspective("games")
    asyncio. async (perspective.generalStart(gamemodel, p0, p1))
Ejemplo n.º 25
0
    def start_lecture_game(self):
        timemodel = TimeModel(0, 0)
        gamemodel = GameModel(timemodel)
        gamemodel.set_offline_lecture()
        white_name = black_name = "pychessbot"
        p0 = (LOCAL, Human, (WHITE, white_name), white_name)
        p1 = (LOCAL, Human, (BLACK, black_name), black_name)

        perspective = perspective_manager.get_perspective("games")
        asyncio.async(perspective.generalStart(gamemodel, p0, p1))

        return gamemodel
Ejemplo n.º 26
0
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)))
Ejemplo n.º 27
0
    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)
Ejemplo n.º 28
0
 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)
Ejemplo n.º 29
0
    def learnClicked(self, button):
        perspective = perspective_manager.get_perspective("learn")
        perspective.activate()

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

        start_puzzle_from(filename)
Ejemplo n.º 30
0
 def on_rotate_board1_activate(self, widget):
     board_control = newGameDialog.SetupPositionExtension.board_control
     persp = perspective_manager.get_perspective("games")
     if board_control is not None and board_control.view.is_visible():
         view = newGameDialog.SetupPositionExtension.board_control.view
     elif persp.cur_gmwidg() is not None:
         view = persp.cur_gmwidg().board.view
     else:
         return
     if view.rotation:
         view.rotation = 0
     else:
         view.rotation = math.pi
Ejemplo n.º 31
0
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")
    asyncio. async (perspective.generalStart(gamemodel, p0, p1,
                                             (uri, loader, 0, -1)))
Ejemplo n.º 32
0
 def on_analyzer_check_toggled(check):
     self.widgets["analyzers_vbox"].set_sensitive(check.get_active())
     from pychess.widgets.gamewidget import widgets
     perspective = perspective_manager.get_perspective("games")
     if len(perspective.gamewidgets) != 0:
         if check.get_active():
             for gmwidg in perspective.gamewidgets:
                 create_task(gmwidg.gamemodel.restart_analyzer(HINT))
                 if not widgets["hint_mode"].get_active():
                     gmwidg.gamemodel.pause_analyzer(HINT)
         else:
             for gmwidg in perspective.gamewidgets:
                 gmwidg.gamemodel.remove_analyzer(HINT)
Ejemplo n.º 33
0
 def on_rotate_board1_activate(self, widget):
     board_control = newGameDialog.SetupPositionExtension.board_control
     persp = perspective_manager.get_perspective("games")
     if board_control is not None and board_control.view.is_visible():
         view = newGameDialog.SetupPositionExtension.board_control.view
     elif persp.cur_gmwidg() is not None:
         view = persp.cur_gmwidg().board.view
     else:
         return
     if view.rotation:
         view.rotation = 0
     else:
         view.rotation = math.pi
Ejemplo n.º 34
0
 def on_analyzer_check_toggled(check):
     self.widgets["analyzers_vbox"].set_sensitive(check.get_active())
     from pychess.widgets.gamewidget import widgets
     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(HINT))
                 if not widgets["hint_mode"].get_active():
                     gmwidg.gamemodel.pause_analyzer(HINT)
         else:
             for gmwidg in perspective.gamewidgets:
                 gmwidg.gamemodel.remove_analyzer(HINT)
Ejemplo n.º 35
0
    def onPlayGameCreated(self, bm, ficsgame):
        log.debug("FICS.onPlayGameCreated: %s" % ficsgame)

        for message in self.messages:
            message.dismiss()
        del self.messages[:]

        if self.connection.ICC:
            for button in self.quick_seek_buttons:
                button.set_active(False)

        timemodel = TimeModel(ficsgame.minutes * 60, ficsgame.inc)

        gamemodel = ICGameModel(self.connection, ficsgame, timemodel)
        gamemodel.connect("game_started", self.onGameModelStarted, ficsgame)

        wplayer, bplayer = ficsgame.wplayer, ficsgame.bplayer

        # We start
        if wplayer.name.lower() == self.connection.getUsername().lower():
            player0tup = (LOCAL, Human, (WHITE, wplayer.long_name(),
                                         wplayer.name,
                                         wplayer.getRatingForCurrentGame()),
                          wplayer.long_name())
            player1tup = (REMOTE, ICPlayer,
                          (gamemodel, bplayer.name, ficsgame.gameno, BLACK,
                           bplayer.long_name(),
                           bplayer.getRatingForCurrentGame()),
                          bplayer.long_name())

        # She starts
        else:
            player1tup = (LOCAL, Human, (BLACK, bplayer.long_name(),
                                         bplayer.name,
                                         bplayer.getRatingForCurrentGame()),
                          bplayer.long_name())
            player0tup = (REMOTE, ICPlayer,
                          (gamemodel, wplayer.name, ficsgame.gameno, WHITE,
                           wplayer.long_name(),
                           wplayer.getRatingForCurrentGame()),
                          wplayer.long_name())

        perspective = perspective_manager.get_perspective("games")
        if not ficsgame.board.fen:
            create_task(
                perspective.generalStart(gamemodel, player0tup, player1tup))
        else:
            create_task(
                perspective.generalStart(
                    gamemodel, player0tup, player1tup,
                    (StringIO(ficsgame.board.fen), fen, 0, -1)))
    def find_in_database(self):
        persp = perspective_manager.get_perspective("database")
        if persp.chessfile is None:
            dialogue = Gtk.MessageDialog(
                pychess.widgets.mainwindow(),
                type=Gtk.MessageType.ERROR,
                buttons=Gtk.ButtonsType.OK,
                message_format=_("No database is currently opened."),
            )
            dialogue.run()
            dialogue.destroy()
            return

        view = self.board.view
        shown_board = self.gamemodel.getBoardAtPly(view.shown, view.shown_variation_idx)
        fen = shown_board.asFen()

        tool, found = persp.chessfile.has_position(fen)
        if not found:
            dialogue = Gtk.MessageDialog(
                pychess.widgets.mainwindow(),
                type=Gtk.MessageType.WARNING,
                buttons=Gtk.ButtonsType.OK,
                message_format=_("The position does not exist in the database."),
            )
            dialogue.run()
            dialogue.destroy()
        else:
            if tool == TOOL_CHESSDB:
                persp.chessfile.set_fen_filter(fen)
            elif tool == TOOL_SCOUTFISH:
                dialogue = Gtk.MessageDialog(
                    pychess.widgets.mainwindow(),
                    type=Gtk.MessageType.QUESTION,
                    buttons=Gtk.ButtonsType.YES_NO,
                    message_format=_(
                        "An approximate position has been found. Do you want to display it ?"
                    ),
                )
                response = dialogue.run()
                dialogue.destroy()
                if response != Gtk.ResponseType.YES:
                    return

                persp.chessfile.set_scout_filter({"sub-fen": fen})
            else:
                raise RuntimeError("Internal error")
            persp.gamelist.ply = view.shown
            persp.gamelist.load_games()
            perspective_manager.activate_perspective("database")
Ejemplo n.º 37
0
    def on_load_game1_activate(self, widget):
        opendialog = get_open_dialog()

        d = NestedFileChooserDialog(opendialog)
        filenames = d.run()
        opendialog.destroy()
        if filenames is not None:
            for filename in filenames:
                if filename.lower().endswith(".fen"):
                    newGameDialog.loadFileAndRun(filename)
                else:
                    perspective = perspective_manager.get_perspective(
                        "database")
                    perspective.open_chessfile(filename)
Ejemplo n.º 38
0
 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:
         if len(gmwidg.gamemodel.boards) == 1:
             ply = 0
         else:
             ply = gmwidg.board.view.shown
         fen = gmwidg.gamemodel.boards[ply].asFen()
     else:
         fen = None
     newGameDialog.SetupPositionExtension.run(fen)
Ejemplo n.º 39
0
 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():
             try:
                 analyzer = gmwidg.gamemodel.spectators[HINT]
             except KeyError:
                 continue
             if widget.get_active():
                 gmwidg.show_arrow(analyzer, SPY)
             else:
                 gmwidg.hide_arrow(analyzer, SPY)
Ejemplo n.º 40
0
 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():
             try:
                 analyzer = gmwidg.gamemodel.spectators[HINT]
             except KeyError:
                 continue
             if widget.get_active():
                 gmwidg.show_arrow(analyzer, SPY)
             else:
                 gmwidg.hide_arrow(analyzer, SPY)
Ejemplo n.º 41
0
    def onConnected(self, connection):
        self.main_connected_event.set()
        if connection.ICC:
            self.connection.start_helper_manager(True)

        self.lounge = perspective_manager.get_perspective("fics")
        self.lounge.open_lounge(connection, self.helperconn, self.host)
        self.hide()
        self.lounge.show()
        self.lounge.connect("logout",
                            lambda iclounge: self.onLogout(connection))
        self.cids[self.lounge].append(self.lounge.connect(
            "autoLogout", lambda lounge: self.onAutologout(connection)))

        self.showNormal()
        self.widgets["messagePanel"].hide()
Ejemplo n.º 42
0
    def set_sensitives(self, on):
        self.import_button.set_sensitive(on)
        self.widgets["import_chessfile"].set_sensitive(on)
        self.widgets["database_save_as"].set_sensitive(on)
        self.widgets["create_book"].set_sensitive(on)
        self.widgets["import_endgame_nl"].set_sensitive(on)
        self.widgets["import_twic"].set_sensitive(on)

        if on:
            gamewidget.getWidgets()["copy_pgn"].set_property("sensitive", on)
            gamewidget.getWidgets()["copy_fen"].set_property("sensitive", on)
        else:
            persp = perspective_manager.get_perspective("games")
            if persp.cur_gmwidg() is None:
                gamewidget.getWidgets()["copy_pgn"].set_property("sensitive", on)
                gamewidget.getWidgets()["copy_fen"].set_property("sensitive", on)
Ejemplo n.º 43
0
    def __set_panel_active(self, panel, active):
        name = panel.__name__

        from pychess.widgets.pydock import EAST

        persp = perspective_manager.get_perspective("games")
        if active:
            leaf = persp.notebooks["board"].get_parent().get_parent()
            leaf.dock(persp.docks[name][1], EAST, persp.docks[name][0], name)
        else:
            try:
                persp.notebooks[name].get_parent().get_parent().undock(persp.notebooks[name])
            except AttributeError:
                # A new panel appeared in the panels directory
                leaf = persp.notebooks["board"].get_parent().get_parent()
                leaf.dock(persp.docks[name][1], EAST, persp.docks[name][0], name)
Ejemplo n.º 44
0
    def onConnected(self, connection):
        self.main_connected_event.set()
        if connection.ICC:
            self.connection.start_helper_manager(True)

        self.lounge = perspective_manager.get_perspective("fics")
        self.lounge.open_lounge(connection, self.helperconn, self.host)
        self.hide()
        self.lounge.show()
        self.lounge.connect("logout",
                            lambda iclounge: self.onLogout(connection))
        self.cids[self.lounge].append(self.lounge.connect(
            "autoLogout", lambda lounge: self.onAutologout(connection)))

        self.showNormal()
        self.widgets["messagePanel"].hide()
Ejemplo n.º 45
0
    def set_sensitives(self, on):
        self.import_button.set_sensitive(on)
        self.widgets["import_chessfile"].set_sensitive(on)
        self.widgets["database_save_as"].set_sensitive(on)
        self.widgets["create_book"].set_sensitive(on)
        self.widgets["import_endgame_nl"].set_sensitive(on)
        self.widgets["import_twic"].set_sensitive(on)

        if on:
            gamewidget.getWidgets()["copy_pgn"].set_property('sensitive', on)
            gamewidget.getWidgets()["copy_fen"].set_property('sensitive', on)
        else:
            persp = perspective_manager.get_perspective("games")
            if persp.cur_gmwidg() is None:
                gamewidget.getWidgets()["copy_pgn"].set_property('sensitive', on)
                gamewidget.getWidgets()["copy_fen"].set_property('sensitive', on)
    def onGamePreview(self, adm, ficsgame):
        log.debug("Archived panel onGamePreview: %s" % ficsgame)

        timemodel = TimeModel(ficsgame.minutes * 60, ficsgame.inc)

        gamemodel = ICGameModel(self.connection, ficsgame, timemodel)

        # The players need to start listening for moves IN this method if they
        # want to be noticed of all moves the FICS server sends us from now on.
        # Hence the lazy loading is skipped.
        wplayer, bplayer = ficsgame.wplayer, ficsgame.bplayer
        player0tup = (
            REMOTE,
            ICPlayer,
            (
                gamemodel,
                wplayer.name,
                -1,
                WHITE,
                wplayer.long_name(),
                wplayer.getRatingByGameType(ficsgame.game_type),
            ),
            wplayer.long_name(),
        )
        player1tup = (
            REMOTE,
            ICPlayer,
            (
                gamemodel,
                bplayer.name,
                -1,
                BLACK,
                bplayer.long_name(),
                bplayer.getRatingByGameType(ficsgame.game_type),
            ),
            bplayer.long_name(),
        )

        perspective = perspective_manager.get_perspective("games")
        create_task(
            perspective.generalStart(
                gamemodel,
                player0tup,
                player1tup,
                (StringIO(ficsgame.board.pgn), pgn, 0, -1),
            ))
        gamemodel.connect("game_started", self.on_game_start, ficsgame)
Ejemplo n.º 47
0
 def on_quit1_activate(self, widget, *args):
     perspective = perspective_manager.get_perspective("games")
     if isinstance(widget, Gdk.Event):
         if len(perspective.gamewidgets) == 1 and conf.get("hideTabs"):
             gmwidg = perspective.cur_gmwidg()
             perspective.closeGame(gmwidg, gmwidg.gamemodel)
             return True
         elif len(perspective.gamewidgets) >= 1 and conf.get("closeAll"):
             perspective.closeAllGames(perspective.gamewidgets)
             return True
     if perspective.closeAllGames(perspective.gamewidgets) in (
             Gtk.ResponseType.OK, Gtk.ResponseType.YES):
         ICLogon.stop()
         self.app.loop.stop()
         self.app.quit()
     else:
         return True
Ejemplo n.º 48
0
 def on_quit1_activate(self, widget, *args):
     perspective = perspective_manager.get_perspective("games")
     if isinstance(widget, Gdk.Event):
         if len(perspective.gamewidgets) == 1 and conf.get("hideTabs"):
             gmwidg = perspective.cur_gmwidg()
             perspective.closeGame(gmwidg, gmwidg.gamemodel)
             return True
         elif len(perspective.gamewidgets) >= 1 and conf.get("closeAll"):
             perspective.closeAllGames(perspective.gamewidgets)
             return True
     if perspective.closeAllGames(perspective.gamewidgets) in (
             Gtk.ResponseType.OK, Gtk.ResponseType.YES):
         ICLogon.stop()
         self.app.loop.stop()
         self.app.quit()
     else:
         return True
Ejemplo n.º 49
0
    def onPlayGameCreated(self, bm, ficsgame):
        log.debug("FICS.onPlayGameCreated: %s" % ficsgame)

        for message in self.messages:
            message.dismiss()
        del self.messages[:]

        if self.connection.ICC:
            for button in self.quick_seek_buttons:
                button.set_active(False)

        timemodel = TimeModel(ficsgame.minutes * 60, ficsgame.inc)

        gamemodel = ICGameModel(self.connection, ficsgame, timemodel)
        gamemodel.connect("game_started", self.onGameModelStarted, ficsgame)

        wplayer, bplayer = ficsgame.wplayer, ficsgame.bplayer

        # We start
        if wplayer.name.lower() == self.connection.getUsername().lower():
            player0tup = (LOCAL, Human,
                          (WHITE, wplayer.long_name(), wplayer.name,
                           wplayer.getRatingForCurrentGame()),
                          wplayer.long_name())
            player1tup = (REMOTE, ICPlayer, (
                gamemodel, bplayer.name, ficsgame.gameno, BLACK,
                bplayer.long_name(), bplayer.getRatingForCurrentGame()),
                bplayer.long_name())

        # She starts
        else:
            player1tup = (LOCAL, Human,
                          (BLACK, bplayer.long_name(), bplayer.name,
                           bplayer.getRatingForCurrentGame()),
                          bplayer.long_name())
            player0tup = (REMOTE, ICPlayer, (
                gamemodel, wplayer.name, ficsgame.gameno, WHITE,
                wplayer.long_name(), wplayer.getRatingForCurrentGame()),
                wplayer.long_name())

        perspective = perspective_manager.get_perspective("games")
        if not ficsgame.board.fen:
            create_task(perspective.generalStart(gamemodel, player0tup, player1tup))
        else:
            create_task(perspective.generalStart(gamemodel, player0tup, player1tup, (
                StringIO(ficsgame.board.fen), fen, 0, -1)))
Ejemplo n.º 50
0
    def on_load_game1_activate(self, widget):
        dialog = get_open_dialog()

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filenames = dialog.get_filenames()
        else:
            filenames = None

        dialog.destroy()

        if filenames is not None:
            for filename in filenames:
                if filename.lower().endswith(".fen"):
                    newGameDialog.loadFileAndRun(filename)
                else:
                    perspective = perspective_manager.get_perspective("database")
                    perspective.open_chessfile(filename)
Ejemplo n.º 51
0
    def accept_new_properties(button, *args):
        persp = perspective_manager.get_perspective("games")
        gamemodel = persp.cur_gmwidg().gamemodel
        gamemodel.tags["Event"] = widgets["event_entry"].get_text()
        gamemodel.tags["Site"] = widgets["site_entry"].get_text()
        gamemodel.tags["Round"] = widgets["round_entry"].get_text()
        gamemodel.tags["White"] = widgets["white_entry"].get_text()
        gamemodel.tags["Black"] = widgets["black_entry"].get_text()
        gamemodel.tags["Year"] = widgets["game_info_calendar"].get_date()[0]
        gamemodel.tags["Month"] = widgets["game_info_calendar"].get_date()[
            1] + 1
        gamemodel.tags["Day"] = widgets["game_info_calendar"].get_date()[2]
        widgets["game_info"].hide()

        gamemodel.players[BLACK].setName(gamemodel.tags["Black"])
        gamemodel.players[WHITE].setName(gamemodel.tags["White"])
        gamemodel.emit("players_changed")
        return True
Ejemplo n.º 52
0
    def on_load_game1_activate(self, widget):
        dialog = get_open_dialog()

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            filenames = dialog.get_filenames()
        else:
            filenames = None

        dialog.destroy()

        if filenames is not None:
            for filename in filenames:
                if filename.lower().endswith(".fen"):
                    newGameDialog.loadFileAndRun(filename)
                else:
                    perspective = perspective_manager.get_perspective("database")
                    perspective.open_chessfile(filename)
Ejemplo n.º 53
0
    def __set_panel_active(self, panel, active):
        name = panel.__name__

        from pychess.widgets.pydock import EAST

        persp = perspective_manager.get_perspective("games")
        if active:
            leaf = persp.notebooks["board"].get_parent().get_parent()
            leaf.dock(persp.docks[name][1], EAST, persp.docks[name][0], name)
        else:
            try:
                persp.notebooks[name].get_parent().get_parent().undock(
                    persp.notebooks[name])
            except AttributeError:
                # A new panel appeared in the panels directory
                leaf = persp.notebooks["board"].get_parent().get_parent()
                leaf.dock(persp.docks[name][1], EAST, persp.docks[name][0],
                          name)
Ejemplo n.º 54
0
def start_lesson_game(gamemodel, filename, chessfile, records, index, rec):
    gamemodel.set_learn_data(LESSON, filename, index, len(records))

    # Lichess doesn't export some study data to .pgn like
    # Orientation, Analysis mode, Chapter pinned comment, move hint comments, general fail comment
    if filename.startswith(
            "lichess_study_beta-lichess-practice-checkmating-with-a-knight-and-bishop"
    ):
        if index in (4, 6, 8, 9):
            gamemodel.tags["Orientation"] = "White"
            print(index, '[Orientation "White"]')

    color = gamemodel.boards[0].color
    player_name = conf.get("firstName")

    w_name = player_name if color == WHITE else "PyChess"
    b_name = "PyChess" if color == WHITE else player_name

    p0 = (LOCAL, Human, (WHITE, w_name), w_name)
    p1 = (LOCAL, Human, (BLACK, b_name), b_name)

    def learn_success(gamemodel):
        gamemodel.scores = {}
        chessfile.loadToModel(rec, -1, gamemodel)
        progress = lessons_solving_progress[gamemodel.source]
        progress[gamemodel.current_index] = 1
        lessons_solving_progress[gamemodel.source] = progress
        if "FEN" in gamemodel.tags:
            create_task(gamemodel.restart_analyzer(HINT))

    gamemodel.connect("learn_success", learn_success)

    def on_game_started(gamemodel):
        perspective.activate_panel("annotationPanel")
        if "FEN" in gamemodel.tags:
            create_task(
                gamemodel.start_analyzer(
                    HINT, force_engine=discoverer.getEngineLearn()))

    gamemodel.connect("game_started", on_game_started)

    gamemodel.status = WAITING_TO_START
    perspective = perspective_manager.get_perspective("games")
    create_task(perspective.generalStart(gamemodel, p0, p1))
Ejemplo n.º 55
0
    def learnClicked(self, button):
        perspective = perspective_manager.get_perspective("learn")
        perspective.activate()

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

        if self.category == LECTURE:
            start_lecture_from(source)
        elif self.category == LESSON:
            start_lesson_from(source)
        elif self.category == PUZZLE:
            start_puzzle_from(source)
        elif self.category == ENDGAME:
            start_endgame_from(source)
Ejemplo n.º 56
0
    def __init__(self, widgets):
        # Put panels in trees
        self.widgets = widgets
        persp = perspective_manager.get_perspective("games")
        sidePanels = persp.sidePanels
        dockLocation = persp.dockLocation

        saved_panels = []
        xmlOK = os.path.isfile(dockLocation)
        if xmlOK:
            doc = minidom.parse(dockLocation)
            for elem in doc.getElementsByTagName("panel"):
                saved_panels.append(elem.getAttribute("id"))

        store = Gtk.ListStore(bool, GdkPixbuf.Pixbuf, str, object)
        for panel in sidePanels:
            checked = True if not xmlOK else panel.__name__ in saved_panels
            panel_icon = get_pixbuf(panel.__icon__, 32)
            text = "<b>%s</b>\n%s" % (panel.__title__, panel.__desc__)
            store.append((checked, panel_icon, text, panel))

        self.tv = widgets["panels_treeview"]
        self.tv.set_model(store)

        self.widgets['panel_about_button'].connect('clicked', self.panel_about)
        self.widgets['panel_enable_button'].connect('toggled',
                                                    self.panel_toggled)
        self.tv.get_selection().connect('changed', self.selection_changed)

        pixbuf = Gtk.CellRendererPixbuf()
        pixbuf.props.yalign = 0
        pixbuf.props.ypad = 3
        pixbuf.props.xpad = 3
        self.tv.append_column(Gtk.TreeViewColumn("Icon",
                                                 pixbuf,
                                                 pixbuf=1,
                                                 sensitive=0))

        uistuff.appendAutowrapColumn(self.tv, "Name", markup=2, sensitive=0)

        widgets['preferences_notebook'].connect("switch-page", self.__on_switch_page)
        widgets["preferences_dialog"].connect("show", self.__on_show_window)
        widgets["preferences_dialog"].connect("hide", self.__on_hide_window)
Ejemplo n.º 57
0
    def learnClicked(self, button):
        perspective = perspective_manager.get_perspective("learn")
        perspective.activate()

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

        if self.category == LECTURE:
            start_lecture_from(source)
        elif self.category == LESSON:
            start_lesson_from(source)
        elif self.category == PUZZLE:
            start_puzzle_from(source)
        elif self.category == ENDGAME:
            start_endgame_from(source)
Ejemplo n.º 58
0
def start_lesson_from(filename, index=None):
    chessfile = PGNFile(protoopen(addDataPrefix("learn/lessons/%s" % filename)))
    chessfile.limit = 1000
    chessfile.init_tag_database()
    records, plys = chessfile.get_records()

    progress = lessons_solving_progress.get(filename, [0] * chessfile.count)

    if index is None:
        index = progress.index(0)

    rec = records[index]

    timemodel = TimeModel(0, 0)
    gamemodel = LearnModel(timemodel)
    gamemodel.set_learn_data(LESSON, filename, index, len(records))

    chessfile.loadToModel(rec, -1, gamemodel)

    color = gamemodel.boards[0].color
    player_name = conf.get("firstName", _("You"))

    w_name = player_name if color == WHITE else "PyChess"
    b_name = "PyChess" if color == WHITE else player_name

    p0 = (LOCAL, Human, (WHITE, w_name), w_name)
    p1 = (LOCAL, Human, (BLACK, b_name), b_name)

    def learn_success(gamemodel):
        progress = lessons_solving_progress[gamemodel.source]
        progress[gamemodel.current_index] = 1
        lessons_solving_progress[gamemodel.source] = progress
        asyncio.async(gamemodel.restart_analyzer(HINT))
    gamemodel.connect("learn_success", learn_success)

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

    gamemodel.status = WAITING_TO_START
    perspective = perspective_manager.get_perspective("games")
    asyncio.async(perspective.generalStart(gamemodel, p0, p1))
Ejemplo n.º 59
0
def run(widgets):
    persp = perspective_manager.get_perspective("games")
    gamemodel = persp.cur_gmwidg().gamemodel
    widgets["event_entry"].set_text(gamemodel.tags["Event"])
    widgets["site_entry"].set_text(gamemodel.tags["Site"])
    widgets["round_entry"].set_text(str(gamemodel.tags["Round"]))
    widgets["white_entry"].set_text(gamemodel.tags["White"])
    widgets["black_entry"].set_text(gamemodel.tags["Black"])

    # Notice: GtkCalender month goes from 0 to 11, but gamemodel goes from
    # 1 to 12
    widgets["game_info_calendar"].clear_marks()
    widgets["game_info_calendar"].select_month(
        int(gamemodel.tags["Month"]) - 1, int(gamemodel.tags["Year"]))
    widgets["game_info_calendar"].select_day(int(gamemodel.tags["Day"]))

    global firstRun
    if firstRun:
        initialize(widgets)
        firstRun = False
    widgets["game_info"].show()