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)
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)
def refresh_elo_rating_change(widgets): persp = perspective_manager.get_perspective("games") gamemodel = persp.cur_gmwidg().gamemodel 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)