def add_engine(self, widget, data=None):
dialog = Gtk.FileChooserDialog(
_("Add UCI Engine.."),
gv.gui.get_window(),
Gtk.FileChooserAction.OPEN,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
)
dialog.set_default_response(Gtk.ResponseType.OK)
dialog.set_current_folder(os.path.expanduser("~"))
response = dialog.run()
if response == Gtk.ResponseType.OK:
fname = dialog.get_filename()
# print "attempting to add new engine"
path = dialog.get_filename()
# use a new uci object so not to mess with main game engine
u = uci.Uci("0")
u.set_engine("addengine", path)
errmsg, name = u.test_engine(path)
if errmsg != "":
err_dialog = Gtk.Dialog(_("Error Adding Engine"), None, 0,
(Gtk.STOCK_OK, Gtk.ResponseType.OK))
err_dialog.set_default_size(380, -1)
lbl = Gtk.Label(label=errmsg)
lbl.show()
al = Gtk.Alignment.new(xalign=0.0, yalign=0.5,
xscale=0.0, yscale=0.0)
al.set_padding(20, 20, 20, 20)
al.add(lbl)
al.show()
err_dialog.vbox.pack_start(al, True, False, 0)
response = err_dialog.run()
err_dialog.destroy()
else:
self.liststore.append([name, path])
self.add_engine_to_list([name, path, {}])
dialog.destroy()
# Called from this module by clicking 'configure' button
# or from gui.py by selecting configure engine from menu
评论列表
文章目录