本文整理汇总了Python中pychess.Players.engineNest.discoverer.connect_after函数的典型用法代码示例。如果您正苦于以下问题:Python connect_after函数的具体用法?Python connect_after怎么用?Python connect_after使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect_after函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handleArgs
def handleArgs(self, chess_file):
if chess_file:
def do(discoverer):
GLib.idle_add(newGameDialog.LoadFileExtension.run, chess_file)
discoverer.connect_after("all_engines_discovered", do)
开发者ID:TPNguyen,项目名称:pychess,代码行数:7,代码来源:Main.py
示例2: __init__
def __init__(self):
#GObject.GObject.__init__(self,0,0,0,0)
GObject.GObject.__init__(self)
self.widgets = widgets = uistuff.GladeWidgets("taskers.glade")
tasker = widgets["newGameTasker"]
tasker.unparent()
self.add(tasker)
combo = ToggleComboBox()
combo.addItem(_("White"), get_pixbuf("glade/white.png"))
combo.addItem(_("Black"), get_pixbuf("glade/black.png"))
combo.addItem(_("Random"), get_pixbuf("glade/random.png"))
combo.setMarkup("<b>", "</b>")
widgets["colorDock"].add(combo)
uistuff.keep(combo, "newgametasker_colorcombo")
widgets['yourColorLabel'].set_mnemonic_widget(combo)
# We need to wait until after engines have been discovered, to init the
# playerCombos. We use connect_after to make sure, that newGameDialog
# has also had time to init the constants we share with them.
self.playerCombo = ToggleComboBox()
widgets["opponentDock"].add(self.playerCombo)
discoverer.connect_after("all_engines_discovered",
self.__initPlayerCombo, widgets)
widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo)
def on_skill_changed(scale):
pix = newGameDialog.skillToIconLarge[int(scale.get_value())]
widgets["skillImage"].set_from_pixbuf(pix)
widgets["skillSlider"].connect("value-changed", on_skill_changed)
on_skill_changed(widgets["skillSlider"])
widgets["startButton"].connect("clicked", self.startClicked)
self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
开发者ID:vaj25,项目名称:pychess,代码行数:35,代码来源:TaskerManager.py
示例3: handleArgs
def handleArgs(self, chess_file):
if chess_file:
def do(discoverer):
perspective = perspective_manager.get_perspective("database")
perspective.open_chessfile(chess_file)
self.dd_task.cancel()
discoverer.connect_after("all_engines_discovered", do)
开发者ID:leogregianin,项目名称:pychess,代码行数:9,代码来源:Main.py
示例4: __init__
def __init__(self):
GObject.GObject.__init__(self)
self.widgets = widgets = uistuff.GladeWidgets("taskers.glade")
tasker = widgets["newGameTasker"]
tasker.unparent()
self.add(tasker)
startButton = self.widgets["startButton"]
startButton.set_name("startButton")
combo = Gtk.ComboBox()
uistuff.createCombo(combo, [
(get_pixbuf("glade/white.png"), _("White")),
(get_pixbuf("glade/black.png"), _("Black")),
(get_pixbuf("glade/random.png"), _("Random"))])
widgets["colorDock"].add(combo)
if combo.get_active() < 0:
combo.set_active(0)
uistuff.keep(combo, "newgametasker_colorcombo")
widgets['yourColorLabel'].set_mnemonic_widget(combo)
# We need to wait until after engines have been discovered, to init the
# playerCombos. We use connect_after to make sure, that newGameDialog
# has also had time to init the constants we share with them.
self.playerCombo = Gtk.ComboBox()
widgets["opponentDock"].add(self.playerCombo)
discoverer.connect_after("all_engines_discovered",
self.__initPlayerCombo, widgets)
widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo)
def on_skill_changed(scale):
# Just to make sphinx happy...
try:
pix = newGameDialog.skillToIconLarge[int(scale.get_value())]
widgets["skillImage"].set_from_pixbuf(pix)
except TypeError:
pass
widgets["skillSlider"].connect("value-changed", on_skill_changed)
on_skill_changed(widgets["skillSlider"])
widgets["startButton"].connect("clicked", self.startClicked)
self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:42,代码来源:TaskerManager.py
示例5: do_activate
def do_activate(self):
# create_task(self.print_tasks())
self.add_window(self.window)
self.window.show_all()
gamewidget.getWidgets()["player_rating1"].hide()
gamewidget.getWidgets()["leave_fullscreen1"].hide()
# Externals download dialog
if not conf.get("dont_show_externals_at_startup"):
externals_dialog = ExternalsDialog()
externals_dialog.show()
# Tip of the day dialog
if conf.get("show_tip_at_startup"):
tip_of_the_day = TipOfTheDay()
tip_of_the_day.show()
preferencesDialog.run(gamewidget.getWidgets())
def on_all_engine_discovered(discoverer):
engine = discoverer.getEngineByName(discoverer.getEngineLearn())
if engine is None:
engine = discoverer.getEngineN(-1)
default_engine = engine.get("md5")
conf.set("ana_combobox", default_engine)
conf.set("inv_ana_combobox", default_engine)
# Try to set conf analyzer engine on very first start of pychess
if conf.get("ana_combobox") == 0:
discoverer.connect_after("all_engines_discovered", on_all_engine_discovered)
dd = DiscovererDialog(discoverer)
self.dd_task = create_task(dd.start())
style_ctxt = gamewidget.getWidgets()["main_window"].get_style_context()
LIGHT = hexcol(style_ctxt.lookup_color("p_light_color")[1])
DARK = hexcol(style_ctxt.lookup_color("p_dark_color")[1])
conf.set("lightcolour", LIGHT)
conf.set("darkcolour", DARK)
开发者ID:leogregianin,项目名称:pychess,代码行数:39,代码来源:Main.py
示例6: protocol_changed
def protocol_changed(widget):
if self.cur_engine is not None and not self.add and not self.selection:
active = self.widgets["engine_protocol_combo"].get_active()
new_protocol = "uci" if active==0 else "xboard"
engine = discoverer.getEngineByName(self.cur_engine)
old_protocol = engine["protocol"]
if new_protocol != old_protocol:
engine_command = engine_chooser_dialog.get_filename()
# is the new protocol supported by the engine?
if new_protocol == "uci":
ok = is_uci(engine_command)
else:
ok = is_cecp(engine_command)
if ok:
# discover engine options for new protocol
engine["protocol"] = new_protocol
engine["recheck"] = True
discoverer.connect_after("engine_discovered", update_options)
discoverer.discover()
else:
# restore the original protocol
widgets["engine_protocol_combo"].set_active(0 if old_protocol=="uci" else 1)
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:22,代码来源:enginesDialog.py
示例7: _init
def _init(cls):
cls.white = get_pixbuf("glade/white.png")
cls.black = get_pixbuf("glade/black.png")
cls.widgets = uistuff.GladeWidgets("newInOut.glade")
cls.widgets["newgamedialog"].set_transient_for(mainwindow())
def on_exchange_players(widget, button_event):
white = cls.widgets["whitePlayerCombobox"].get_active()
black = cls.widgets["blackPlayerCombobox"].get_active()
whiteLevel = cls.widgets["skillSlider1"].get_value()
blackLevel = cls.widgets["skillSlider2"].get_value()
cls.widgets["whitePlayerCombobox"].set_active(black)
cls.widgets["blackPlayerCombobox"].set_active(white)
cls.widgets["skillSlider1"].set_value(blackLevel)
cls.widgets["skillSlider2"].set_value(whiteLevel)
cls.widgets["whitePlayerButton"].set_image(Gtk.Image.new_from_pixbuf(cls.white))
cls.widgets["whitePlayerButton"].connect("button-press-event", on_exchange_players)
cls.widgets["blackPlayerButton"].set_image(Gtk.Image.new_from_pixbuf(cls.black))
cls.widgets["blackPlayerButton"].connect("button-press-event", on_exchange_players)
uistuff.createCombo(cls.widgets["whitePlayerCombobox"], name="whitePlayerCombobox")
uistuff.createCombo(cls.widgets["blackPlayerCombobox"], name="blackPlayerCombobox")
cls.widgets["playersIcon"].set_from_pixbuf(big_people)
cls.widgets["timeIcon"].set_from_pixbuf(big_time)
def on_playerCombobox_changed(widget, skill_hbox, skill_level):
position = widget.get_active()
skill_hbox.props.visible = position > 0
if position > 0:
tree_iter = widget.get_active_iter()
if tree_iter is not None:
engine_name = widget.get_model()[tree_iter][1]
engine = discoverer.getEngineByName(engine_name)
if engine:
pref_level = engine.get("level")
if pref_level:
skill_level.set_value(pref_level)
cls.widgets["whitePlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox1"], cls.widgets["skillSlider1"])
cls.widgets["blackPlayerCombobox"].connect("changed", on_playerCombobox_changed, cls.widgets["skillHbox2"], cls.widgets["skillSlider2"])
cls.widgets["whitePlayerCombobox"].set_active(0)
cls.widgets["blackPlayerCombobox"].set_active(1)
def on_skill_changed(scale, image):
image.set_from_pixbuf(skillToIcon[int(scale.get_value())])
cls.widgets["skillSlider1"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon1"])
cls.widgets["skillSlider2"].connect("value-changed", on_skill_changed, cls.widgets["skillIcon2"])
cls.widgets["skillSlider1"].set_value(3)
cls.widgets["skillSlider2"].set_value(3)
cls.__initTimeRadio("ngblitz", cls.widgets["blitzRadio"], cls.widgets["configImageBlitz"], 5, 0, 0)
cls.__initTimeRadio("ngrapid", cls.widgets["rapidRadio"], cls.widgets["configImageRapid"], 15, 5, 0)
cls.__initTimeRadio("ngnormal", cls.widgets["normalRadio"], cls.widgets["configImageNormal"], 45, 15, 0)
cls.__initTimeRadio("ngclassical", cls.widgets["classicalRadio"], cls.widgets["configImageClassical"], 3, 0, 40)
cls.__initVariantRadio("ngvariant1", cls.widgets["playVariant1Radio"], cls.widgets["configImageVariant1"])
cls.__initVariantRadio("ngvariant2", cls.widgets["playVariant2Radio"], cls.widgets["configImageVariant2"])
def updateCombos(*args):
if cls.widgets["playNormalRadio"].get_active():
variant = NORMALCHESS
elif cls.widgets["playVariant1Radio"].get_active():
variant = conf.get("ngvariant1")
else:
variant = conf.get("ngvariant2")
variant1 = conf.get("ngvariant1")
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
variant2 = conf.get("ngvariant2")
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
data = [(item[0], item[1]) for item in playerItems[variant]]
uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data)
uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data)
discoverer.connect_after("all_engines_discovered", updateCombos)
updateCombos(discoverer)
conf.notify_add("ngvariant1", updateCombos)
conf.notify_add("ngvariant2", updateCombos)
cls.widgets["playNormalRadio"].connect("toggled", updateCombos)
cls.widgets["playNormalRadio"].set_tooltip_text(variants[NORMALCHESS].__desc__)
cls.widgets["playVariant1Radio"].connect("toggled", updateCombos)
variant1 = conf.get("ngvariant1")
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
cls.widgets["playVariant2Radio"].connect("toggled", updateCombos)
variant2 = conf.get("ngvariant2")
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
# The "variant" has to come before players, because the engine positions
# in the user comboboxes can be different in different variants
for key in ("whitePlayerCombobox", "blackPlayerCombobox",
"skillSlider1", "skillSlider2", "notimeRadio",
"blitzRadio", "rapidRadio", "normalRadio", "classicalRadio",
"playNormalRadio", "playVariant1Radio", "playVariant2Radio"):
uistuff.keep(cls.widgets[key], key)
# We don't want the dialog to deallocate when closed. Rather we hide
#.........这里部分代码省略.........
开发者ID:leogregianin,项目名称:pychess,代码行数:101,代码来源:newGameDialog.py
示例8: initialize
def initialize(gameDic):
uistuff.keep(widgets["fromCurrent"], "fromCurrent", first_value=True)
uistuff.keep(widgets["threatPV"], "threatPV")
uistuff.keep(widgets["showEval"], "showEval")
uistuff.keep(widgets["showBlunder"], "showBlunder", first_value=True)
uistuff.keep(widgets["max_analysis_spin"], "max_analysis_spin", first_value=3)
uistuff.keep(widgets["variation_thresold_spin"], "variation_thresold_spin", first_value=50)
# Analyzing engines
uistuff.createCombo(widgets["ana_combobox"])
from pychess.widgets import newGameDialog
@idle_add
def update_analyzers_store(discoverer):
data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
uistuff.updateCombo(widgets["ana_combobox"], data)
discoverer.connect_after("all_engines_discovered", update_analyzers_store)
update_analyzers_store(discoverer)
uistuff.keep(widgets["ana_combobox"], "ana_combobox", anal_combo_get_value,
lambda combobox, value: anal_combo_set_value(combobox, value, "hint_mode",
"analyzer_check", HINT))
def hide_window(button, *args):
widgets["analyze_game"].hide()
return True
def abort ():
stop_event.set()
widgets["analyze_game"].hide()
def run_analyze(button, *args):
gmwidg = gamewidget.cur_gmwidg()
gamemodel = gameDic[gmwidg]
old_check_value = conf.get("analyzer_check", True)
conf.set("analyzer_check", True)
analyzer = gamemodel.spectators[HINT]
gmwidg.menuitems["hint_mode"].active = True
threat_PV = conf.get("ThreatPV", False)
if threat_PV:
old_inv_check_value = conf.get("inv_analyzer_check", True)
conf.set("inv_analyzer_check", True)
inv_analyzer = gamemodel.spectators[SPY]
gmwidg.menuitems["spy_mode"].active = True
title = _("Game analyzing in progress...")
text = _("Do you want to abort it?")
content = InfoBar.get_message_content(title, text, Gtk.STOCK_DIALOG_QUESTION)
def response_cb (infobar, response, message):
message.dismiss()
abort()
message = InfoBarMessage(Gtk.MessageType.QUESTION, content, response_cb)
message.add_button(InfoBarMessageButton(_("Abort"), Gtk.ResponseType.CANCEL))
gmwidg.showMessage(message)
def analyse_moves():
from_current = conf.get("fromCurrent", True)
start_ply = gmwidg.board.view.shown if from_current else 0
move_time = int(conf.get("max_analysis_spin", 3))
thresold = int(conf.get("variation_thresold_spin", 50))
for board in gamemodel.boards[start_ply:]:
if stop_event.is_set():
break
@idle_add
def do():
gmwidg.board.view.setShownBoard(board)
do()
analyzer.setBoard(board)
inv_analyzer.setBoard(board)
time.sleep(move_time+0.1)
ply = board.ply
if ply-1 in gamemodel.scores and ply in gamemodel.scores:
color = (ply-1) % 2
oldmoves, oldscore, olddepth = gamemodel.scores[ply-1]
score_str = prettyPrintScore(oldscore, olddepth)
oldscore = oldscore * -1 if color == BLACK else oldscore
moves, score, depth = gamemodel.scores[ply]
score = score * -1 if color == WHITE else score
diff = score-oldscore
if (diff > thresold and color==BLACK) or (diff < -1*thresold and color==WHITE):
if threat_PV:
try:
if ply-1 in gamemodel.spy_scores:
oldmoves0, oldscore0, olddepth0 = gamemodel.spy_scores[ply-1]
score_str0 = prettyPrintScore(oldscore0, olddepth0)
pv0 = listToMoves(gamemodel.boards[ply-1], ["--"] + oldmoves0, validate=True)
if len(pv0) > 2:
gamemodel.add_variation(gamemodel.boards[ply-1], pv0, comment="Treatening", score=score_str0)
except ParsingError as e:
# ParsingErrors may happen when parsing "old" lines from
# analyzing engines, which haven't yet noticed their new tasks
log.debug("__parseLine: Ignored (%s) from analyzer: ParsingError%s" % \
(' '.join(oldmoves),e))
try:
pv = listToMoves(gamemodel.boards[ply-1], oldmoves, validate=True)
gamemodel.add_variation(gamemodel.boards[ply-1], pv, comment="Better is", score=score_str)
except ParsingError as e:
#.........这里部分代码省略.........
开发者ID:metiscus,项目名称:pychess,代码行数:101,代码来源:analyzegameDialog.py
示例9: _init
def _init (cls):
cls.widgets = uistuff.GladeWidgets ("newInOut.glade")
uistuff.createCombo(cls.widgets["whitePlayerCombobox"], name="whitePlayerCombobox")
uistuff.createCombo(cls.widgets["blackPlayerCombobox"], name="blackPlayerCombobox")
cls.widgets["playersIcon"].set_from_pixbuf(big_people)
cls.widgets["timeIcon"].set_from_pixbuf(big_time)
def on_playerCombobox_changed (widget, skillHbox):
skillHbox.props.visible = widget.get_active() > 0
cls.widgets["whitePlayerCombobox"].connect(
"changed", on_playerCombobox_changed, cls.widgets["skillHbox1"])
cls.widgets["blackPlayerCombobox"].connect(
"changed", on_playerCombobox_changed, cls.widgets["skillHbox2"])
cls.widgets["whitePlayerCombobox"].set_active(0)
cls.widgets["blackPlayerCombobox"].set_active(1)
def on_skill_changed (scale, image):
image.set_from_pixbuf(skillToIcon[int(scale.get_value())])
cls.widgets["skillSlider1"].connect("value-changed", on_skill_changed,
cls.widgets["skillIcon1"])
cls.widgets["skillSlider2"].connect("value-changed", on_skill_changed,
cls.widgets["skillIcon2"])
cls.widgets["skillSlider1"].set_value(3)
cls.widgets["skillSlider2"].set_value(3)
cls.__initTimeRadio(_("Blitz"), "ngblitz", cls.widgets["blitzRadio"],
cls.widgets["configImageBlitz"], 5, 0)
cls.__initTimeRadio(_("Rapid"), "ngrapid", cls.widgets["rapidRadio"],
cls.widgets["configImageRapid"], 15, 5)
cls.__initTimeRadio(_("Normal"), "ngnormal", cls.widgets["normalRadio"],
cls.widgets["configImageNormal"], 40, 15)
cls.__initVariantRadio("ngvariant1", cls.widgets["playVariant1Radio"],
cls.widgets["configImageVariant1"],
FISCHERRANDOMCHESS)
cls.__initVariantRadio("ngvariant2", cls.widgets["playVariant2Radio"],
cls.widgets["configImageVariant2"], LOSERSCHESS)
#@idle_add
def updateCombos(*args):
if cls.widgets["playNormalRadio"].get_active():
variant = NORMALCHESS
elif cls.widgets["playVariant1Radio"].get_active():
variant = conf.get("ngvariant1", FISCHERRANDOMCHESS)
else:
variant = conf.get("ngvariant2", LOSERSCHESS)
variant1 = conf.get("ngvariant1", FISCHERRANDOMCHESS)
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
variant2 = conf.get("ngvariant2", LOSERSCHESS)
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
data = [(item[0], item[1]) for item in playerItems[variant]]
uistuff.updateCombo(cls.widgets["blackPlayerCombobox"], data)
uistuff.updateCombo(cls.widgets["whitePlayerCombobox"], data)
discoverer.connect_after("all_engines_discovered", updateCombos)
updateCombos(discoverer)
conf.notify_add("ngvariant1", updateCombos)
conf.notify_add("ngvariant2", updateCombos)
cls.widgets["playNormalRadio"].connect("toggled", updateCombos)
cls.widgets["playNormalRadio"].set_tooltip_text(variants[NORMALCHESS].__desc__)
cls.widgets["playVariant1Radio"].connect("toggled", updateCombos)
variant1 = conf.get("ngvariant1", FISCHERRANDOMCHESS)
cls.widgets["playVariant1Radio"].set_tooltip_text(variants[variant1].__desc__)
cls.widgets["playVariant2Radio"].connect("toggled", updateCombos)
variant2 = conf.get("ngvariant2", LOSERSCHESS)
cls.widgets["playVariant2Radio"].set_tooltip_text(variants[variant2].__desc__)
# The "variant" has to come before players, because the engine positions
# in the user comboboxes can be different in different variants
for key in ("whitePlayerCombobox", "blackPlayerCombobox",
"skillSlider1", "skillSlider2",
"notimeRadio", "blitzRadio", "rapidRadio", "normalRadio",
"playNormalRadio", "playVariant1Radio", "playVariant2Radio"):
uistuff.keep(cls.widgets[key], key)
# We don't want the dialog to deallocate when closed. Rather we hide
# it on respond
cls.widgets["newgamedialog"].connect("delete_event", lambda *a: True)
开发者ID:jcoffee,项目名称:pychess,代码行数:84,代码来源:newGameDialog.py
示例10: __init__
def __init__(self, widgets):
self.widgets = widgets
# Options on by default
for key in ("opening_check", "endgame_check", "online_egtb_check",
"analyzer_check", "inv_analyzer_check"):
uistuff.keep(widgets[key], key, first_value=True)
# Opening book
default_path = os.path.join(addDataPrefix("pychess_book.bin"))
path = conf.get("opening_file_entry", default_path)
conf.set("opening_file_entry", path)
book_chooser_dialog = Gtk.FileChooserDialog(
_("Select book file"), None, Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
Gtk.ResponseType.OK))
book_chooser_button = Gtk.FileChooserButton.new_with_dialog(
book_chooser_dialog)
filter = Gtk.FileFilter()
filter.set_name(_("Opening books"))
filter.add_pattern("*.bin")
book_chooser_dialog.add_filter(filter)
book_chooser_button.set_filename(path)
self.widgets["bookChooserDock"].add(book_chooser_button)
book_chooser_button.show()
def select_new_book(button):
new_book = book_chooser_dialog.get_filename()
if new_book:
conf.set("opening_file_entry", new_book)
else:
# restore the original
book_chooser_dialog.set_filename(path)
book_chooser_button.connect("file-set", select_new_book)
def on_opening_check_toggled(check):
self.widgets["opening_hbox"].set_sensitive(check.get_active())
self.widgets["opening_check"].connect_after("toggled",
on_opening_check_toggled)
# Endgame
default_path = os.path.join(getDataPrefix())
egtb_path = conf.get("egtb_path", default_path)
conf.set("egtb_path", egtb_path)
egtb_chooser_dialog = Gtk.FileChooserDialog(
_("Select Gaviota TB path"), None,
Gtk.FileChooserAction.SELECT_FOLDER,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
Gtk.ResponseType.OK))
egtb_chooser_button = Gtk.FileChooserButton.new_with_dialog(
egtb_chooser_dialog)
egtb_chooser_button.set_current_folder(egtb_path)
self.widgets["egtbChooserDock"].add(egtb_chooser_button)
egtb_chooser_button.show()
def select_egtb(button):
new_directory = egtb_chooser_dialog.get_filename()
if new_directory != egtb_path:
conf.set("egtb_path", new_directory)
egtb_chooser_button.connect("current-folder-changed", select_egtb)
def on_endgame_check_toggled(check):
self.widgets["endgame_hbox"].set_sensitive(check.get_active())
self.widgets["endgame_check"].connect_after("toggled",
on_endgame_check_toggled)
# Analyzing engines
from pychess.widgets import newGameDialog
data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
uistuff.createCombo(widgets["ana_combobox"], data, name="ana_combobox")
uistuff.createCombo(widgets["inv_ana_combobox"], data, name="inv_ana_combobox")
def update_analyzers_store(discoverer):
data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
uistuff.updateCombo(widgets["ana_combobox"], data)
uistuff.updateCombo(widgets["inv_ana_combobox"], data)
discoverer.connect_after("all_engines_discovered",
update_analyzers_store)
update_analyzers_store(discoverer)
# Save, load and make analyze combos active
# Let Stockfish to be default analyzer in Windows installer
default = discoverer.getEngineN(-1).get("md5")
conf.set("ana_combobox", conf.get("ana_combobox", default))
conf.set("inv_ana_combobox", conf.get("inv_ana_combobox", default))
def on_analyzer_check_toggled(check):
self.widgets["analyzers_vbox"].set_sensitive(check.get_active())
from pychess.widgets.gamewidget import widgets
#.........这里部分代码省略.........
开发者ID:bboutkov,项目名称:pychess,代码行数:101,代码来源:preferencesDialog.py
示例11: __init__
def __init__(self, widgets):
self.widgets = widgets
self.dialog = self.widgets["manage_engines_dialog"]
self.cur_engine = None
self.default_workdir = getEngineDataPrefix()
uistuff.keepWindowSize("engineswindow", self.dialog, defaultSize=(1, 500))
# Put engines into tree store
allstore = Gtk.ListStore(Pixbuf, str)
self.tv = self.widgets["engines_treeview"]
self.tv.set_model(allstore)
self.tv.append_column(Gtk.TreeViewColumn(
"Flag", Gtk.CellRendererPixbuf(), pixbuf=0))
name_renderer = Gtk.CellRendererText()
name_renderer.set_property("editable", True)
self.tv.append_column(Gtk.TreeViewColumn("Name", name_renderer, text=1))
def name_edited(renderer, path, new_name):
if self.cur_engine is not None:
old_name = self.cur_engine
if new_name and new_name != old_name:
names = [engine["name"] for engine in discoverer.getEngines()]
if new_name not in names:
engine = discoverer.getEngineByName(self.cur_engine)
engine["name"] = new_name
discoverer.save()
self.cur_engine = new_name
update_store()
# Notify playerCombos in NewGameTasker
discoverer.emit("all_engines_discovered")
name_renderer.connect("edited", name_edited)
# Add cell renderer to protocol combo column
protocol_combo = self.widgets["engine_protocol_combo"]
cell = Gtk.CellRendererText()
protocol_combo.pack_start(cell, True)
protocol_combo.add_attribute(cell, "text", 0)
# Add columns and cell renderers to options treeview
self.options_store = Gtk.ListStore(str, GObject.TYPE_PYOBJECT)
optv = self.widgets["options_treeview"]
optv.set_model(self.options_store)
optv.append_column(Gtk.TreeViewColumn(
"Option", Gtk.CellRendererText(), text=0))
optv.append_column(Gtk.TreeViewColumn(
"Data", KeyValueCellRenderer(self.options_store), data=1))
def update_options(*args):
if self.cur_engine is not None:
engines = discoverer.getEngines()
names = [engine["name"] for engine in engines]
# After deleting an engine we will select first
if self.cur_engine not in names:
self.cur_engine = engines[0]["name"]
engine = discoverer.getEngineByName(self.cur_engine)
options = engine.get("options")
if options:
self.options_store.clear()
for option in options:
key = option["name"]
val = option
if option["type"] != "button":
val["default"] = option.get("default")
val["value"] = option.get("value", val["default"])
self.options_store.append([key, val])
def update_store(*args):
newGameDialog.createPlayerUIGlobals(discoverer)
engine_names = [row[1] for row in allstore]
new_items = []
# don't add the very first (Human) player to engine store
for item in newGameDialog.playerItems[0][1:]:
if item[1] not in engine_names:
new_items.append(item)
iter = None
for item in new_items:
iter = allstore.append(item)
if iter is not None:
ts = self.tv.get_selection()
ts.select_iter(iter)
update_options()
update_store()
def do_update_store(*args):
GLib.idle_add(update_store)
discoverer.connect_after("engine_discovered", do_update_store)
################################################################
# remove button
################################################################
def remove(button):
if self.cur_engine is not None:
self.widgets['remove_engine_button'].set_sensitive(False)
engine = discoverer.getEngineByName(self.cur_engine)
discoverer.removeEngine(self.cur_engine)
discoverer.save()
selection = self.tv.get_selection()
#.........这里部分代码省略.........
开发者ID:sally0813,项目名称:pychess,代码行数:101,代码来源:enginesDialog.py
示例12: __init__
def __init__(self):
self.widgets = uistuff.GladeWidgets("analyze_game.glade")
self.widgets["analyze_game"].set_transient_for(mainwindow())
self.stop_event = asyncio.Event()
uistuff.keep(self.widgets["fromCurrent"], "fromCurrent")
uistuff.keep(self.widgets["shouldBlack"], "shouldBlack")
uistuff.keep(self.widgets["shouldWhite"], "shouldWhite")
uistuff.keep(self.widgets["threatPV"], "threatPV")
uistuff.keep(self.widgets["showEval"], "showEval")
uistuff.keep(self.widgets["showBlunder"], "showBlunder")
uistuff.keep(self.widgets["max_analysis_spin"], "max_analysis_spin")
uistuff.keep(self.widgets["variation_threshold_spin"], "variation_threshold_spin")
# Analyzing engines
uistuff.createCombo(self.widgets["ana_combobox"], name="ana_combobox")
from pychess.widgets import newGameDialog
def update_analyzers_store(discoverer):
data = [(item[0], item[1]) for item in newGameDialog.analyzerItems]
uistuff.updateCombo(self.widgets["ana_combobox"], data)
discoverer.connect_after("all_engines_discovered", update_analyzers_store)
update_analyzers_store(discoverer)
uistuff.keep(self.widgets["ana_combobox"], "ana_combobox", anal_combo_get_value,
lambda combobox, value: anal_combo_set_value(combobox, value, "hint_mode", HINT))
def hide_window(button, *args):
self.widgets["analyze_game"].destroy()
def abort():
self.stop_event.set()
self.widgets["analyze_game"].destroy()
def run_analyze(button, *args):
@asyncio.coroutine
def coro():
persp = perspective_manager.get_perspective("games")
gmwidg = persp.cur_gmwidg()
gamemodel = gmwidg.gamemodel
old_check_value = conf.get("analyzer_check")
conf.set("analyzer_check", True)
if HINT not in gamemodel.spectators:
try:
yield from asyncio.wait_for(gamemodel.start_analyzer(HINT), 5.0)
except asyncio.TimeoutError:
log.error("Got timeout error while starting hint analyzer")
return
except Exception:
log.error("Unknown error while starting hint analyzer")
return
analyzer = gamemodel.spectators[HINT]
gmwidg.menuitems["hint_mode"].active = True
threat_PV = conf.get("ThreatPV")
if threat_PV:
old_inv_check_value = conf.get("inv_analyzer_check")
conf.set("inv_analyzer_check", True)
if SPY not in gamemodel.spectators:
try:
yield from asyncio.wait_for(gamemodel.start_analyzer(SPY), 5.0)
except asyncio.TimeoutError:
log.error("Got timeout error while starting spy analyzer")
return
except Exception:
log.error("Unknown error while starting spy analyzer")
return
inv_analyzer = gamemodel.spectators[SPY]
gmwidg.menuitems["spy_mode"].active = True
title = _("Game analyzing in progress...")
text = _("Do you want to abort it?")
content = InfoBar.get_message_content(title, text, Gtk.STOCK_DIALOG_QUESTION)
def response_cb(infobar, response, message):
conf.set("analyzer_check", old_check_value)
if threat_PV:
conf.set("inv_analyzer_check", old_inv_check_value)
message.dismiss()
abort()
message = InfoBarMessage(Gtk.MessageType.QUESTION, content, response_cb)
message.add_button(InfoBarMessageButton(_("Abort"), Gtk.ResponseType.CANCEL))
gmwidg.replaceMessages(message)
@asyncio.coroutine
def analyse_moves():
should_black = conf.get("shouldBlack")
should_white = conf.get("shouldWhite")
from_current = conf.get("fromCurrent")
start_ply = gmwidg.board.view.shown if from_current else 0
move_time = int(conf.get("max_analysis_spin"))
threshold = int(conf.get("variation_threshold_spin"))
for board in gamemodel.boards[start_ply:]:
if self.stop_event.is_set():
break
gmwidg.board.view.setShownBoard(board)
analyzer.setBoard(board)
if threat_PV:
#.........这里部分代码省略.........
开发者ID:leogregianin,项目名称:pychess,代码行数:101,代码来源:analyzegameDialog.py
示例13: __init__
def __init__(self, widgets):
self.widgets = widgets
self.dialog = self.widgets["manage_engines_dialog"]
self.cur_engine = None
self.default_workdir = getEngineDataPrefix()
uistuff.keepWindowSize("engineswindow", self.dialog)
# Put engines into tree store
allstore = Gtk.ListStore(Pixbuf, str)
self.tv = self.widgets["engines_treeview"]
self.tv.set_model(allstore)
self.tv.append_column(Gtk.TreeViewColumn("Flag",
Gtk.CellRendererPixbuf(),
pixbuf=0))
name_renderer = Gtk.CellRendererText()
name_renderer.set_property("editable", False)
self.tv.append_column(Gtk.TreeViewColumn("Name",
name_renderer,
text=1))
def name_edited(renderer, path, new_name):
if self.cur_engine is not None:
old_name = self.cur_engine
if new_name and new_name != old_name:
names = [engine["name"]
for engine in discoverer.getEngines()]
if new_name not in names:
engine = discoverer.getEngineByName(self.cur_engine)
engine["name"] = new_name
discoverer.save()
self.cur_engine = new_name
update_store()
# Notify playerCombos in NewGameTasker
discoverer.emit("all_engines_discovered")
name_renderer.connect("edited", name_edited)
# Add cell renderer to protocol combo column
protocol_combo = self.widgets["engine_protocol_combo"]
protocol_combo.set_name("engine_protocol_combo")
cell = Gtk.CellRendererText()
protocol_combo.pack_start(cell, True)
protocol_combo.add_attribute(cell, "text", 0)
# Add columns and cell renderers to options treeview
self.options_store = Gtk.ListStore(str, GObject.TYPE_PYOBJECT)
optv = self.widgets["options_treeview"]
optv.set_model(self.options_store)
optv.append_column(Gtk.TreeViewColumn("Option",
Gtk.CellRendererText(),
text=0))
optv.append_column(Gtk.TreeViewColumn("Data",
KeyValueCellRenderer(
self.options_store),
data=1))
def update_options(*args):
if self.cur_engine is not None:
engines = discoverer.getEngines()
names = [engine["name"] for engine in engines]
# After deleting an engine we will select first
if self.cur_engine not in names:
self.cur_engine = engines[0]["name"]
engine = discoverer.getEngineByName(self.cur_engine)
options = engine.get("options")
self.options_store.clear()
if options:
options.sort(key=lambda obj: obj['name'].lower() if 'name' in obj else '')
for option in options:
key = option["name"]
val = option
if option["type"] != "button":
val["default"] = option.get("default")
val["value"] = option.get("value", val["default"])
self.options_store.append([key, val])
def update_store(*args):
newGameDialog.createPlayerUIGlobals(discoverer)
engine_names = [row[1] for row in allstore]
new_items = []
# don't add the very first (Human) player to engine store
for item in newGameDialog.allEngineItems:
if item[1] not in engine_names:
new_items.append(item)
ts_iter = None
for item in new_items:
ts_iter = allstore.append(item)
if ts_iter is not None:
text_select = self.tv.get_selection()
text_select.select_iter(ts_iter)
update_options()
update_store()
def do_update_store(*args):
GLib.idle_add(update_store)
discoverer.connect_after("engine_discovered", do_update_store)
#.........这里部分代码省略.........
开发者ID:teacoffee2017,项目名称:pychess,代码行数:101,代码来源:enginesDialog.py
|
请发表评论