def nuevo_engine(self): form = FormLayout.FormLayout(self, _("Kibitzer"), Iconos.Kibitzer(), anchoMinimo=340) form.edit(_("Name"), "") form.separador() form.combobox(_("Engine"), self.configuration.comboMotores(), "stockfish") form.separador() liTipos = Kibitzers.Tipos().comboSinIndices() form.combobox(_("Type"), liTipos, Kibitzers.KIB_CANDIDATES) form.separador() form.combobox(_("Process priority"), Priorities.priorities.combo(), Priorities.priorities.normal) form.separador() form.combobox(_("Point of view"), Kibitzers.cb_pointofview_options(), Kibitzers.KIB_AFTER_MOVE) form.separador() resultado = form.run() if resultado: accion, resp = resultado name, engine, tipo, prioridad, pointofview = resp # Indexes only with Rodent II if tipo == "I": engine = "rodentII" if not name: # para que no repita rodent II name = _("Indexes") + " - RodentII" name = name.strip() if not name: for label, key in liTipos: if key == tipo: name = "%s: %s" % (label, engine) num = self.kibitzers.nuevo_engine(name, engine, tipo, prioridad, pointofview) self.goto(num)
def me_set_editor(self, parent): recno = self.gridValores.recno() key = self.liKibActual[recno][2] nk = self.krecno() kibitzer = self.kibitzers.kibitzer(nk) valor = control = lista = minimo = maximo = None if key is None: return None elif key == "name": control = "ed" valor = kibitzer.name elif key == "prioridad": control = "cb" lista = Priorities.priorities.combo() valor = kibitzer.prioridad elif key == "pointofview": control = "cb" lista = Kibitzers.cb_pointofview_options() valor = kibitzer.pointofview elif key == "visible": kibitzer.visible = not kibitzer.visible self.kibitzers.save() self.goto(nk) elif key == "info": control = "ed" valor = kibitzer.id_info elif key.startswith("opcion"): opcion = kibitzer.li_uci_options_editable()[int(key[7:])] tipo = opcion.tipo valor = opcion.valor if tipo == "spin": control = "sb" minimo = opcion.minimo maximo = opcion.maximo elif tipo in ("check", "button"): opcion.valor = not valor self.kibitzers.save() self.goto(nk) elif tipo == "combo": lista = [(var, var) for var in opcion.li_vars] control = "cb" elif tipo == "string": control = "ed" self.me_control = control self.me_key = key if control == "ed": return Controles.ED(parent, valor) elif control == "cb": return Controles.CB(parent, lista, valor) elif control == "sb": return Controles.SB(parent, valor, minimo, maximo) return None
def procesa(self, orden): key = orden.key if key == KIBRUN_CONFIGURATION: user = orden.dv["USER"] self.configuration = Configuration.Configuration(user) self.configuration.lee() self.configuration.leeConfBoards() Code.configuration = self.configuration OpeningsStd.reset() kibitzers = Kibitzers.Kibitzers() self.numkibitzer = kibitzers.number(orden.dv["HUELLA"]) self.kibitzer = kibitzers.kibitzer(self.numkibitzer) prioridad = self.kibitzer.prioridad priorities = Priorities.priorities if prioridad != priorities.normal: self.prioridad = priorities.value(prioridad) else: self.prioridad = None self.titulo = self.kibitzer.name self.key_video = "Kibitzers%s" % self.kibitzer.huella self.dic_video = self.configuration.restore_video(self.key_video) self.tipo = self.kibitzer.tipo self.lanzaVentana() elif key == KIBRUN_GAME: game = Game.Game() game.restore(orden.dv["GAME"]) if self.kibitzer.pointofview == KIB_BEFORE_MOVE: game.anulaSoloUltimoMovimiento() if self.tipo == KIB_THREATS: last_position = game.last_position last_position.is_white = not last_position.is_white game_thread = Game.Game(ini_posicion=last_position) self.ventana.orden_game(game_thread) else: self.ventana.orden_game(game) elif key == KIBRUN_STOP: self.ventana.stop() elif key == KIBRUN_CLOSE: self.ipc.close() self.ventana.finalizar() self.ventana.reject()
def procesa(self, orden): key = orden.key if key == KIBRUN_CONFIGURACION: user = orden.dv["USER"] self.configuracion = Configuracion.Configuracion(user) self.configuracion.lee() self.configuracion.leeConfTableros() Code.configuracion = self.configuracion AperturasStd.reset() self.numkibitzer = orden.dv["NUMKIBITZER"] kibitzers = Kibitzers.Kibitzers() self.kibitzer = kibitzers.kibitzer(self.numkibitzer) prioridad = self.kibitzer.prioridad priorities = Priorities.priorities if prioridad != priorities.normal: self.prioridad = priorities.value(prioridad) else: self.prioridad = None self.titulo = self.kibitzer.name self.key_video = "Kibitzers%s" % self.kibitzer.huella self.dic_video = self.configuracion.restore_video(self.key_video) self.tipo = self.kibitzer.tipo self.position_before = self.kibitzer.position_before self.lanzaVentana() elif key == KIBRUN_FEN: self.fen, self.fenBase = orden.dv["FEN"].split("|") fen = self.fenBase if self.position_before else self.fen if self.tipo == KIB_THREATS: li = fen.split(" ") li[1] = "w" if li[1] == "b" else "b" li[3] = "-" # Hay que tener cuidado con la captura al paso, stockfish crash. fen = " ".join(li) self.ventana.ponFen(fen) elif key == KIBRUN_STOP: self.ventana.stop() elif key == KIBRUN_CLOSE: self.ipc.close() self.ventana.finalizar() self.ventana.reject()
def __init__(self, w_parent, configuration, numkibitzer): self.kibitzers = Kibitzers.Kibitzers() self.kibitzer = self.kibitzers.kibitzer(numkibitzer) titulo = self.kibitzer.name icono = Iconos.Kibitzer() extparam = "kibitzerlive" QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam) self.configuration = configuration self.li_options = self.leeOpciones() self.liOriginal = self.leeOpciones() li_acciones = ( (_("Save"), Iconos.Grabar(), self.grabar), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None, ) tb = Controles.TBrutina(self, li_acciones) o_columns = Columnas.ListaColumnas() o_columns.nueva("CAMPO", _("Label"), 152, siDerecha=True) o_columns.nueva("VALOR", _("Value"), 390, edicion=Delegados.MultiEditor(self)) self.gridValores = Grid.Grid(self, o_columns, siSelecFilas=False, xid="val", siEditable=True) self.gridValores.tipoLetra(puntos=self.configuration.x_pgn_fontpoints) self.register_grid(self.gridValores) ly = Colocacion.V().control(tb).control(self.gridValores) self.setLayout(ly) self.restore_video(anchoDefecto=600, altoDefecto=400) self.gridValores.gotop()
def me_set_editor(self, parent): recno = self.gridValores.recno() key = self.li_options[recno][2] control = lista = minimo = maximo = None if key == "prioridad": control = "cb" lista = Priorities.priorities.combo() valor = self.kibitzer.prioridad elif key == "pointofview": control = "cb" lista = Kibitzers.cb_pointofview_options() valor = self.kibitzer.pointofview else: opcion = self.kibitzer.li_uci_options_editable()[int(key)] tipo = opcion.tipo valor = opcion.valor if tipo == "spin": control = "sb" minimo = opcion.minimo maximo = opcion.maximo elif tipo in ("check", "button"): opcion.valor = not valor self.li_options[recno][1] = opcion.valor self.gridValores.refresh() elif tipo == "combo": lista = [(var, var) for var in opcion.li_vars] control = "cb" elif tipo == "string": control = "ed" self.me_control = control self.me_key = key if control == "ed": return Controles.ED(parent, valor) elif control == "cb": return Controles.CB(parent, lista, valor) elif control == "sb": return Controles.SB(parent, valor, minimo, maximo) return None
def __init__(self, w_parent, kibitzers_manager): titulo = _("Kibitzers") icono = Iconos.Kibitzer() extparam = "kibitzer" QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam) self.kibitzers_manager = kibitzers_manager self.configuration = kibitzers_manager.configuration self.procesador = kibitzers_manager.procesador self.tipos = Kibitzers.Tipos() self.kibitzers = Kibitzers.Kibitzers() self.liKibActual = [] self.grid_kibitzers = None li_acciones = ( (_("Close"), Iconos.MainMenu(), self.terminar), None, (_("New"), Iconos.Nuevo(), self.nuevo), None, (_("Remove"), Iconos.Borrar(), self.remove), None, (_("Copy"), Iconos.Copiar(), self.copy), None, (_("Up"), Iconos.Arriba(), self.up), None, (_("Down"), Iconos.Abajo(), self.down), None, (_("External engines"), Iconos.Motores(), self.ext_engines), None, ) tb = Controles.TBrutina(self, li_acciones) self.splitter = QtWidgets.QSplitter(self) self.register_splitter(self.splitter, "kibitzers") o_columns = Columnas.ListaColumnas() o_columns.nueva("TYPE", "", 30, centered=True, edicion=Delegados.PmIconosBMT( self, dicIconos=self.tipos.dicDelegado())) o_columns.nueva("NOMBRE", _("Kibitzer"), 209) self.grid_kibitzers = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True, xid="kib") self.grid_kibitzers.tipoLetra( puntos=self.configuration.x_pgn_fontpoints) self.register_grid(self.grid_kibitzers) w = QtWidgets.QWidget() ly = Colocacion.V().control(self.grid_kibitzers).margen(0) w.setLayout(ly) self.splitter.addWidget(w) o_columns = Columnas.ListaColumnas() o_columns.nueva("CAMPO", _("Label"), 152, siDerecha=True) o_columns.nueva("VALOR", _("Value"), 390, edicion=Delegados.MultiEditor(self)) self.gridValores = Grid.Grid(self, o_columns, siSelecFilas=False, xid="val", siEditable=True) self.gridValores.tipoLetra(puntos=self.configuration.x_pgn_fontpoints) self.register_grid(self.gridValores) w = QtWidgets.QWidget() ly = Colocacion.V().control(self.gridValores).margen(0) w.setLayout(ly) self.splitter.addWidget(w) self.splitter.setSizes([259, 562]) # por defecto ly = Colocacion.V().control(tb).control(self.splitter) self.setLayout(ly) self.restore_video(anchoDefecto=849, altoDefecto=400) self.grid_kibitzers.gotop()