def configurar(self): menu = QTVarios.LCMenu(self) menu.opcion("formula", _("Formula to calculate elo"), Iconos.STS()) resp = menu.lanza() if resp: X = self.sts.X K = self.sts.K while True: liGen = [(None, None)] liGen.append((None, "X * %s + K" % _("Result"))) config = FormLayout.Editbox("X", 100, tipo=float, decimales=4) liGen.append((config, X)) config = FormLayout.Editbox("K", 100, tipo=float, decimales=4) liGen.append((config, K)) resultado = FormLayout.fedit( liGen, title=_("Formula to calculate elo"), parent=self, icon=Iconos.Elo(), siDefecto=True) if resultado: resp, valor = resultado if resp == 'defecto': X = self.sts.Xdefault K = self.sts.Kdefault else: x, k = valor self.sts.formulaChange(x, k) self.grid.refresh() return else: return
def grabarTema(self, tema): liGen = [(None, None)] nombre = tema["NOMBRE"] if tema else "" config = FormLayout.Editbox(_("Name"), ancho=160) liGen.append((config, nombre)) seccion = tema.get("SECCION", "") if tema else "" config = FormLayout.Editbox(_("Section"), ancho=160) liGen.append((config, seccion)) ico = Iconos.Grabar() if tema else Iconos.GrabarComo() resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self, icon=ico) if resultado: accion, liResp = resultado nombre = liResp[0] seccion = liResp[1] if nombre: tema["NOMBRE"] = nombre if seccion: tema["SECCION"] = seccion self.confTablero.png64Thumb(base64.b64encode(self.tablero.thumbnail(64))) tema["TEXTO"] = self.confTablero.grabaTema() tema["BASE"] = self.confTablero.grabaBase() self.temaActual = tema self.ponSecciones() return tema
def set_password(procesador): configuration = procesador.configuration npos = 0 user = configuration.user li_usuarios = Usuarios.Usuarios().list_users if user: number = int(user) for n, usu in enumerate(li_usuarios): if usu.number == number: npos = n break if npos == 0: return else: if not li_usuarios: usuario = Usuarios.User() usuario.number = 0 usuario.password = "" usuario.name = configuration.x_player li_usuarios = [usuario] usuario = li_usuarios[npos] while True: li_gen = [FormLayout.separador] config = FormLayout.Editbox(_("Current"), ancho=120, siPassword=True) li_gen.append((config, "")) config = FormLayout.Editbox(_("New"), ancho=120, siPassword=True) li_gen.append((config, "")) config = FormLayout.Editbox(_("Repeat"), ancho=120, siPassword=True) li_gen.append((config, "")) resultado = FormLayout.fedit(li_gen, title=_("Set password"), parent=procesador.main_window, icon=Iconos.Password()) if resultado: previa, nueva, repite = resultado[1] error = "" if previa != usuario.password: error = _("Current password is not correct") else: if nueva != repite: error = _("New password and repetition are not the same") if error: QTUtil2.message_error(procesador.main_window, error) else: usuario.password = nueva Usuarios.Usuarios().save_list(li_usuarios) return else: return
def setPassword(procesador): configuracion = procesador.configuracion npos = 0 user = configuracion.user liUsuarios = Usuarios.Usuarios().lista if user: numero = int(user) for n, usu in enumerate(liUsuarios): if usu.numero == numero: npos = n break if npos == 0: return else: if not liUsuarios: usuario = Usuarios.Usuario() usuario.numero = 0 usuario.password = "" usuario.nombre = configuracion.jugador liUsuarios = [usuario] usuario = liUsuarios[npos] while True: liGen = [FormLayout.separador] config = FormLayout.Editbox(_("Current"), ancho=120, siPassword=True) liGen.append((config, "")) config = FormLayout.Editbox(_("New"), ancho=120, siPassword=True) liGen.append((config, "")) config = FormLayout.Editbox(_("Repeat"), ancho=120, siPassword=True) liGen.append((config, "")) resultado = FormLayout.fedit(liGen, title=_("Set password"), parent=procesador.pantalla, icon=Iconos.Password()) if resultado: previa, nueva, repite = resultado[1] error = "" if previa != usuario.password: error = _("Current password is not correct") else: if nueva != repite: error = _("New password and repetition are not the same") if error: QTUtil2.mensError(procesador.pantalla, error) else: usuario.password = nueva Usuarios.Usuarios().guardaLista(liUsuarios) return
def formBlundersBrilliancies(alm, configuracion): liBlunders = [SEPARADOR] liBlunders.append(( FormLayout.Editbox(_("Is considered wrong move when the loss of points is greater than"), tipo=int, ancho=50), alm.kblunders)) liBlunders.append(SEPARADOR) def fileNext(base, ext): return Util.fileNext(configuracion.dirPersonalTraining, base, ext) path_pgn = fileNext("Blunders", "pgn") liBlunders.append((None, _("Generate a training file with these moves"))) config = FormLayout.Editbox(_("Tactics name"), rx="[^\\\:/|?*^%><()]*") liBlunders.append((config, "")) config = FormLayout.Fichero(_("PGN Format"), "%s (*.pgn)" % _("PGN Format"), True, anchoMinimo=280, ficheroDefecto=path_pgn) liBlunders.append((config, "")) liBlunders.append((_("Also add complete game to PGN") + ":", False)) liBlunders.append(SEPARADOR) eti = '"%s"' % _("Find best move") liBlunders.append((_X(_("Add to the training %1 with the name"), eti) + ":", "")) liBrilliancies = [SEPARADOR] liBrilliancies.append((FormLayout.Spinbox(_("Minimum depth"), 3, 30, 50), alm.dpbrilliancies)) liBrilliancies.append((FormLayout.Spinbox(_("Minimum gain points"), 30, 30000, 50), alm.ptbrilliancies)) liBrilliancies.append(SEPARADOR) path_fns = fileNext("Brilliancies", "fns") path_pgn = fileNext("Brilliancies", "pgn") liBrilliancies.append((None, _("Generate a training file with these moves"))) config = FormLayout.Fichero(_("List of FENs"), "%s (*.fns)" % _("List of FENs"), True, anchoMinimo=280, ficheroDefecto=path_fns) liBrilliancies.append((config, "")) config = FormLayout.Fichero(_("PGN Format"), "%s (*.pgn)" % _("PGN Format"), True, anchoMinimo=280, ficheroDefecto=path_pgn) liBrilliancies.append((config, "")) liBrilliancies.append((_("Also add complete game to PGN"), False)) liBrilliancies.append(SEPARADOR) eti = '"%s"' % _("Find best move") liBrilliancies.append((_X(_("Add to the training %1 with the name"), eti) + ":", "")) return liBlunders, liBrilliancies
def __init__(self, owner, regSVG, xml=None, nombre=None): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Image")) self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = VarGen.configuracion if not regSVG: regSVG = TabVisual.PSVG() regSVG.xml = xml if nombre: regSVG.nombre = nombre liAcciones = [(_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.Tablero(self, confTablero, siDirector=False) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del svg que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regSVG.nombre)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regSVG.opacidad * 100))) # ( "psize", "n", 100 ), config = FormLayout.Spinbox(_("Size") + " %", 1, 1600, 50) liGen.append((config, regSVG.psize)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regSVG.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control(self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regSVG.a1h8 = a1h8 regSVG.siMovible = True svg = self.tablero.creaSVG(regSVG, siEditando=True) self.liEjemplos.append(svg)
def scanner_more(self): name = "" while True: liGen = [] config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, name)) resultado = FormLayout.fedit(liGen, title=_("New scanner"), parent=self, anchoMinimo=200, icon=Iconos.Scanner()) if resultado: accion, liGen = resultado name = liGen[0].strip() if name: fich = os.path.join(self.configuration.carpetaScanners, "%s.scn" % name) if Util.exist_file(fich): QTUtil2.message_error( self, _("This scanner already exists.")) continue try: with open(fich, "w") as f: f.write("") self.scanner_reread(name) return except: QTUtil2.message_error( self, _("This name is not valid to create a scanner file." )) continue return
def MoverTiempo(self): if self.siReloj: self.siReloj = False else: menu = QTVarios.LCMenu(self) menu.opcion("previo", "%s: %0.02f" % (_("Duration of interval (secs)"), self.intervalo / 1000.0), Iconos.MoverTiempo()) menu.opcion("otro", _("Change interval"), Iconos.Configurar()) resp = menu.lanza() if not resp: return if resp == "otro": liGen = [(None, None)] config = FormLayout.Editbox(_("Duration of interval (secs)"), 40, tipo=float) liGen.append((config, self.intervalo / 1000.0)) resultado = FormLayout.fedit(liGen, title=_("Interval"), parent=self, icon=Iconos.MoverTiempo()) if resultado is None: return accion, liResp = resultado tiempo = liResp[0] if tiempo > 0.01: self.intervalo = int(tiempo * 1000) else: return self.siReloj = True self.MoverInicio() self.lanzaReloj()
def borrar(self): tam_dbop = len(self.dbop) if tam_dbop == 0: return current = self.glines.recno()//2 li = [] if 0 <= current < tam_dbop: li.append(["current", _("Remove line %d") % (current+1,), Iconos.Mover()]) if tam_dbop > 1: li.append(["lines", _("Remove a list of lines"), Iconos.MoverLibre()]) if len(li) > 0: menu = QTVarios.LCMenu(self) for key, title, ico in li: menu.opcion(key, title, ico) menu.separador() resp = menu.lanza() if resp == "current": del self.dbop[current] self.goto_inilinea() else: liGen = [FormLayout.separador] config = FormLayout.Editbox("<div align=\"right\">" + _("Lines") + "<br>" + _("By example:") + " -5,8-12,14,19-", rx="[0-9,\-,\,]*") liGen.append((config, "")) resultado = FormLayout.fedit(liGen, title=_("Remove a list of lines"), parent=self, anchoMinimo=460, icon=Iconos.OpeningLines()) if resultado: accion, liResp = resultado clista = liResp[0] if clista: ln = Util.ListaNumerosImpresion(clista) li = ln.selected(range(1, tam_dbop+1)) sli = [] cad = "" for num in li: if cad: cad += "," + str(num) else: cad = str(num) if len(cad) > 80: sli.append(cad) cad = "" if cad: sli.append(cad) cli = "\n".join(sli) if QTUtil2.pregunta(self, _("Do you want to remove the next lines ?") + "\n\n" + cli): li.sort(reverse=True) um = QTUtil2.unMomento(self, _("Working...")) for num in li: del self.dbop[num-1] self.glines.refresh() self.goto_inilinea() um.final()
def ggrabarGuion(self): liGen = [(None, None)] config = FormLayout.Editbox(_("Name"), ancho=160) liGen.append((config, self.nomGuion)) resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self) if resultado: resp = resultado[1][0].strip() if resp: self.dbGuiones[resp] = self.guion.guarda()
def editaNombre(self, nombre): liGen = [(None, None)] config = FormLayout.Editbox(_("Name"), ancho=160) liGen.append((config, nombre )) ico = Iconos.Grabar() resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self, icon=ico) if resultado: accion, liResp = resultado nombre = liResp[0] return nombre return None
def editaComentario(self, item, mov): liGen = [(None, None)] config = FormLayout.Editbox(_("Comments"), ancho=230) liGen.append((config, mov.comentario )) resultado = FormLayout.fedit(liGen, title=_("Comments") + " " + mov.titulo, parent=self, anchoMinimo=200, icon=Iconos.ComentarioEditar()) if resultado is None: return accion, liResp = resultado mov.comentario = liResp[0] item.setText(2, mov.comentario)
def comment_edit(self): li_variation_move = self.selected_link.split("|") variation, var_move = self.det_variation_move(li_variation_move) previo = var_move.comment form = FormLayout.FormLayout(self, _("Comments"), Iconos.ComentarioEditar(), anchoMinimo=640) form.separador() config = FormLayout.Editbox(_("Comment"), alto=5) form.base(config, previo) resultado = form.run() if resultado: accion, resp = resultado comment = resp[0].strip() var_move.comment = comment self.link_variation_pressed(self.selected_link)
def paramAnalisis(parent, configuracion, siModoAmpliado, siTodosMotores=False): alm = leeDicParametros(configuracion) # Datos liGen = [SEPARADOR] # # Tutor if siTodosMotores: li = configuracion.ayudaCambioCompleto(alm.engine) else: li = configuracion.ayudaCambioTutor() li[0] = alm.engine liGen.append((_("Engine") + ":", li)) # # Time liGen.append(SEPARADOR) config = FormLayout.Editbox(_("Duration of engine analysis (secs)"), 40, tipo=float) liGen.append((config, alm.vtime / 1000.0)) # Depth liDepths = [("--", 0)] for x in range(1, 51): liDepths.append((str(x), x)) config = FormLayout.Combobox(_("Depth"), liDepths) liGen.append((config, alm.depth)) # Time+Depth liGen.append(("%s+%s:" % (_("Time"), _("Depth")), alm.timedepth)) # MultiPV liGen.append(SEPARADOR) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) config = FormLayout.Combobox(_("Number of moves evaluated by engine(MultiPV)"), li) liGen.append((config, alm.multiPV)) # Priority liGen.append(SEPARADOR) config = FormLayout.Combobox(_("Process priority"), Priorities.priorities.combo()) liGen.append((config, alm.priority)) # Completo if siModoAmpliado: liGen.append(SEPARADOR) liJ = [(_("White"), "WHITE"), (_("Black"), "BLACK"), (_("White & Black"), "BOTH")] config = FormLayout.Combobox(_("Analyze only color"), liJ) if alm.white and alm.black: color = "BOTH" elif alm.black: color = "BLACK" elif alm.white: color = "WHITE" else: color = "BOTH" liGen.append((config, color)) config = FormLayout.Editbox('<div align="right">' + _("Moves") + "<br>" + _("By example:") + " -5,8-12,14,19-", rx="[0-9,\-,\,]*") liGen.append((config, "")) fvar = configuracion.ficheroBooks listaLibros = Books.ListaLibros() listaLibros.restore_pickle(fvar) # Comprobamos que todos esten accesibles listaLibros.comprueba() li = [("--", None)] defecto = listaLibros.lista[0] if alm.book_name else None for book in listaLibros.lista: if alm.book_name == book.name: defecto = book li.append((book.name, book)) config = FormLayout.Combobox(_("Do not scan the opening moves based on book"), li) liGen.append((config, defecto)) liGen.append(SEPARADOR) liGen.append((_("Redo any existing prior analyses (if they exist)") + ":", alm.delete_previous)) liGen.append((_("Start from the end of the game") + ":", alm.from_last_move)) liGen.append(SEPARADOR) liGen.append((_("Show graphics") + ":", alm.show_graphs)) liVar = form_variations(alm) liBlunders, liBrilliancies = formBlundersBrilliancies(alm, configuracion) liST = [SEPARADOR] liST.append((_("Activate") + ":", alm.stability)) liST.append(SEPARADOR) liST.append((FormLayout.Spinbox(_("Last depths to control same best move"), 2, 10, 40), alm.st_depths)) liST.append(SEPARADOR) liST.append((FormLayout.Spinbox(_("Maximum difference among last evaluations"), 0, 99999, 60), alm.st_centipawns)) liST.append(SEPARADOR) liST.append((FormLayout.Spinbox(_("Additional time limit"), 0, 99999, 60), alm.st_timelimit)) lista = [] lista.append((liGen, _("General options"), "")) lista.append((liVar, _("Variations"), "")) lista.append((liBlunders, _("Wrong moves"), "")) lista.append((liBrilliancies, _("Brilliancies"), "")) lista.append((liST, _("Stability control"), "")) else: lista = liGen reg = Util.Record() reg.form = None def dispatchR(valor): if reg.form is None: if isinstance(valor, FormLayout.FormTabWidget): reg.form = valor reg.wtime = valor.getWidget(0, 1) reg.wdepth = valor.getWidget(0, 2) reg.wdt = valor.getWidget(0, 3) elif isinstance(valor, FormLayout.FormWidget): reg.form = valor reg.wtime = valor.getWidget(1) reg.wdepth = valor.getWidget(2) reg.wdt = valor.getWidget(3) else: sender = reg.form.sender() if not reg.wdt.isChecked(): if sender == reg.wtime: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif sender == reg.wdepth: if reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) elif sender == reg.wdt: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) QTUtil.refresh_gui() resultado = FormLayout.fedit(lista, title=_("Analysis Configuration"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones(), dispatch=dispatchR) if resultado: accion, liResp = resultado if siModoAmpliado: liGen, liVar, liBlunders, liBrilliancies, liST = liResp else: liGen = liResp alm.engine = liGen[0] alm.vtime = int(liGen[1] * 1000) alm.depth = liGen[2] alm.timedepth = liGen[3] alm.multiPV = liGen[4] alm.priority = liGen[5] if siModoAmpliado: color = liGen[6] alm.white = color != "BLACK" alm.black = color != "WHITE" alm.num_moves = liGen[7] alm.book = liGen[8] alm.book_name = alm.book.name if alm.book else None alm.delete_previous = liGen[9] alm.from_last_move = liGen[10] alm.show_graphs = liGen[11] (alm.include_variations, alm.limit_include_variations, alm.best_variation, alm.info_variation, alm.si_pdt, alm.one_move_variation) = liVar (alm.kblunders, alm.tacticblunders, alm.pgnblunders, alm.oriblunders, alm.bmtblunders) = liBlunders (alm.dpbrilliancies, alm.ptbrilliancies, alm.fnsbrilliancies, alm.pgnbrilliancies, alm.oribrilliancies, alm.bmtbrilliancies) = liBrilliancies (alm.stability, alm.st_depths, alm.st_centipawns, alm.st_timelimit) = liST dic = {} for x in dir(alm): if not x.startswith("__"): dic[x] = getattr(alm, x) Util.save_pickle(configuracion.file_param_analysis(), dic) return alm else: return None
def file(self): menu = QTVarios.LCMenu(self) menu.opcion("saveas", _("Save a copy"), Iconos.GrabarComo()) menu.separador() menu.opcion("restorefrom", _("Restore from"), Iconos.Recuperar()) menu.separador() submenu = menu.submenu(_("Create new"), Iconos.Nuevo()) submenu.opcion("new_UNED", _("UNED chess school"), Iconos.Uned()) submenu.separador() submenu.opcion("new_UWE", _("Uwe Auerswald"), Iconos.Uwe()) submenu.separador() submenu.opcion("new_SM", _("Singular moves"), Iconos.Singular()) menu.separador() submenu = menu.submenu(_("Export to"), Iconos.DatabaseMas()) submenu.opcion("save_pgn", _("A PGN file"), Iconos.FichPGN()) submenu.separador() submenu.opcion("save_db", _("Database"), Iconos.DatabaseC()) resp = menu.lanza() if resp is None: return if resp == "saveas": liGen = [(None, None)] config = FormLayout.Editbox(_("Name"), ancho=160) liGen.append((config, "")) resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self, icon=Iconos.GrabarComo()) if resultado: accion, liResp = resultado fich = nombre = liResp[0] if nombre.lower()[-4:] != ".wsm": fich += ".wsm" path = os.path.join(self.configuracion.carpeta, fich) ok = True if Util.existeFichero(path): ok = QTUtil2.pregunta( self, _X( _("The file %1 already exists, what do you want to do?" ), fich), etiSi=_("Overwrite"), etiNo=_("Cancel")) if ok: shutil.copy(self.dbwashing.file, path) elif resp == "restorefrom": li = [] for fich in os.listdir(self.configuracion.carpeta): if fich.endswith(".wsm") and fich != self.dbwashing.filename: li.append(fich[:-4]) if not li: QTUtil2.mensaje(self, _("There is no file")) return menu = QTVarios.LCMenu(self) for fich in li: menu.opcion(fich, fich, Iconos.PuntoRojo()) resp = menu.lanza() if resp: if QTUtil2.pregunta( self, "%s\n%s" % (_("Current data will be removed and overwritten."), _("Are you sure?"))): shutil.copy( os.path.join(self.configuracion.carpeta, resp + ".wsm"), self.dbwashing.file) self.wreload = True self.guardarVideo() self.accept() elif resp.startswith("new_"): tactic = resp[4:] if QTUtil2.pregunta( self, "%s\n%s" % (_("Current data will be removed and overwritten."), _("Are you sure?"))): self.dbwashing.new(tactic) self.wreload = True self.guardarVideo() self.accept() elif resp.startswith("save_"): def other_pc(): for engine in self.washing.liEngines: if engine.state == Washing.ENDED: game = self.dbwashing.restoreGame(engine) pc = Partida.PartidaCompleta() pc.leeOtra(game) dt = engine.date if engine.date else Util.hoy() if engine.color: white = self.configuracion.jugador black = engine.nombre result = "1-0" whiteelo = str(self.configuracion.elo) blackelo = engine.elo else: black = self.configuracion.jugador white = engine.nombre result = "0-1" blackelo = str(self.configuracion.elo) whiteelo = engine.elo tags = [ ["Site", "Lucas Chess"], ["Event", _("The Washing Machine")], ["Date", "%d-%d-%d" % (dt.year, dt.month, dt.day)], ["White", white], ["Black", black], ["WhiteElo", whiteelo], ["BlackElo", blackelo], ["Result", result], ] ap = game.apertura if ap: tags.append(["ECO", ap.eco]) tags.append(["Opening", ap.trNombre]) pc.setTags(tags) yield pc if resp == "save_db": ext = "lcg" path = QTUtil2.salvaFichero( self, _("Database of complete games"), self.configuracion.ficheroDBgames, _("File") + " %s (*.%s)" % (ext, ext), False) if path: if not path.lower().endswith(".lcg"): path += ".lcg" me = QTUtil2.mensEspera.inicio(self, _("Saving...")) dbn = DBgames.DBgames(path) for pc in other_pc(): dbn.inserta(pc) me.final() QTUtil2.mensaje(self, _X(_("Saved to %1"), path)) else: w = PantallaSavePGN.WSaveVarios(self, self.configuracion) if w.exec_(): ws = PantallaSavePGN.FileSavePGN(self, w.dic_result) if ws.open(): ws.um() for n, pc in enumerate(other_pc()): if n or not ws.is_new: ws.write("\n\n") ws.write(pc.pgn()) ws.close() ws.um_final()
def paramAnalisis(parent, configuracion, siModoAmpliado, siTodosMotores=False): alm = leeDicParametros(configuracion) # Datos liGen = [SEPARADOR] # # Tutor if siTodosMotores: li = configuracion.ayudaCambioCompleto(alm.motor) else: li = configuracion.ayudaCambioTutor() li[0] = alm.motor liGen.append((_("Engine") + ":", li)) # # Time liGen.append(SEPARADOR) config = FormLayout.Editbox(_("Duration of engine analysis (secs)"), 40, tipo=float) liGen.append((config, alm.tiempo / 1000.0)) # Depth liDepths = [("--", 0)] for x in range(1, 51): liDepths.append((str(x), x)) config = FormLayout.Combobox(_("Depth"), liDepths) liGen.append((config, alm.depth)) # Time+Depth liGen.append(("%s+%s:" % (_("Time"), _("Depth")), alm.timedepth)) # MultiPV liGen.append(SEPARADOR) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) config = FormLayout.Combobox( _("Number of moves evaluated by engine(MultiPV)"), li) liGen.append((config, alm.multiPV)) # Priority liGen.append(SEPARADOR) li = [(_("Normal"), EngineThread.PRIORITY_NORMAL), (_("Low"), EngineThread.PRIORITY_LOW), (_("Very low"), EngineThread.PRIORITY_VERYLOW), (_("High"), EngineThread.PRIORITY_HIGH), (_("Very high"), EngineThread.PRIORITY_VERYHIGH)] config = FormLayout.Combobox(_("Process priority"), li) liGen.append((config, alm.priority)) # Completo if siModoAmpliado: liGen.append(SEPARADOR) liJ = [(_("White"), "BLANCAS"), (_("Black"), "NEGRAS"), (_("White & Black"), "AMBOS")] config = FormLayout.Combobox(_("Analyze only color"), liJ) liGen.append((config, "AMBOS")) config = FormLayout.Editbox("<div align=\"right\">" + _("Moves") + "<br>" + _("By example:") + " -5,8-12,14,19-", rx="[0-9,\-,\,]*") liGen.append((config, "")) fvar = configuracion.ficheroBooks listaLibros = Books.ListaLibros() listaLibros.recuperaVar(fvar) # Comprobamos que todos esten accesibles listaLibros.comprueba() li = [("--", None)] defecto = listaLibros.lista[0] if alm.libro else None for libro in listaLibros.lista: if alm.libro == libro.nombre: defecto = libro li.append((libro.nombre, libro)) config = FormLayout.Combobox( _("Do not scan the opening moves based on book"), li) liGen.append((config, defecto)) liGen.append(SEPARADOR) liGen.append( (_("To redo any existing prior analyses (if they exist)") + ":", alm.siBorrarPrevio)) liGen.append( (_("Start from the end of the game") + ":", alm.desdeelfinal)) liGen.append(SEPARADOR) liGen.append((_("Show graphics") + ":", alm.showGraphs)) liVar = [SEPARADOR] liVar.append((_("Add analysis to variants") + ":", alm.masvariantes)) liVar.append(SEPARADOR) liVar.append((FormLayout.Spinbox(_("Minimum points lost"), 0, 1000, 60), alm.limitemasvariantes)) liVar.append(SEPARADOR) liVar.append((_("Only add better variant") + ":", alm.mejorvariante)) liVar.append(SEPARADOR) liVar.append((_("Include info about engine") + ":", alm.infovariante)) liVar.append(SEPARADOR) liVar.append( ("%s %s/%s/%s:" % (_("Format"), _("Points"), _("Depth"), _("Time")), alm.siPDT)) liVar.append(SEPARADOR) liVar.append( (_("Only one move of each variant") + ":", alm.unmovevariante)) liBlunders, liBrilliancies = formBlundersBrilliancies( alm, configuracion) liST = [SEPARADOR] liST.append((_("Activate") + ":", alm.stability)) liST.append(SEPARADOR) liST.append( (FormLayout.Spinbox(_("Last depths to control same best move"), 2, 10, 40), alm.st_depths)) liST.append(SEPARADOR) liST.append( (FormLayout.Spinbox(_("Maximum difference among last evaluations"), 0, 99999, 60), alm.st_centipawns)) liST.append(SEPARADOR) liST.append((FormLayout.Spinbox(_("Additional time limit"), 0, 99999, 60), alm.st_timelimit)) lista = [] lista.append((liGen, _("General options"), "")) lista.append((liVar, _("Variants"), "")) lista.append((liBlunders, _("Wrong moves"), "")) lista.append((liBrilliancies, _("Brilliancies"), "")) lista.append((liST, _("Stability control"), "")) else: lista = liGen reg = Util.Almacen() reg.form = None def dispatchR(valor): if reg.form is None: if isinstance(valor, FormLayout.FormTabWidget): reg.form = valor reg.wtime = valor.getWidget(0, 1) reg.wdepth = valor.getWidget(0, 2) reg.wdt = valor.getWidget(0, 3) elif isinstance(valor, FormLayout.FormWidget): reg.form = valor reg.wtime = valor.getWidget(1) reg.wdepth = valor.getWidget(2) reg.wdt = valor.getWidget(3) else: sender = reg.form.sender() if not reg.wdt.isChecked(): if sender == reg.wtime: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif sender == reg.wdepth: if reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) elif sender == reg.wdt: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) QTUtil.refreshGUI() resultado = FormLayout.fedit(lista, title=_("Analysis Configuration"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones(), dispatch=dispatchR) if resultado: accion, liResp = resultado if siModoAmpliado: liGen, liVar, liBlunders, liBrilliancies, liST = liResp else: liGen = liResp alm.motor = liGen[0] alm.tiempo = int(liGen[1] * 1000) alm.depth = liGen[2] alm.timedepth = liGen[3] alm.multiPV = liGen[4] alm.priority = liGen[5] if siModoAmpliado: color = liGen[6] alm.blancas = color != "NEGRAS" alm.negras = color != "BLANCAS" alm.jugadas = liGen[7] alm.libroAperturas = liGen[8] alm.libro = alm.libroAperturas.nombre if alm.libroAperturas else None alm.siBorrarPrevio = liGen[9] alm.desdeelfinal = liGen[10] alm.showGraphs = liGen[11] (alm.masvariantes, alm.limitemasvariantes, alm.mejorvariante, alm.infovariante, alm.siPDT, alm.unmovevariante) = liVar (alm.kblunders, alm.tacticblunders, alm.pgnblunders, alm.oriblunders, alm.bmtblunders) = liBlunders (alm.dpbrilliancies, alm.ptbrilliancies, alm.fnsbrilliancies, alm.pgnbrilliancies, alm.oribrilliancies, alm.bmtbrilliancies) = liBrilliancies (alm.stability, alm.st_depths, alm.st_centipawns, alm.st_timelimit) = liST dic = {} for x in dir(alm): if not x.startswith("__"): dic[x.upper()] = getattr(alm, x) Util.guardaVar(configuracion.ficheroAnalisis, dic) return alm else: return None
def paramAnalisisMasivo(parent, configuracion, siVariosSeleccionados): alm = leeDicParametros(configuracion) # Datos liGen = [SEPARADOR] # # Tutor li = configuracion.ayudaCambioTutor() li[0] = alm.motor liGen.append((_("Engine") + ":", li)) liGen.append(SEPARADOR) # # Time config = FormLayout.Editbox(_("Duration of engine analysis (secs)"), 40, tipo=float) liGen.append((config, alm.tiempo / 1000.0)) # Depth liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) config = FormLayout.Combobox(_("Depth"), liDepths) liGen.append((config, alm.depth)) # Time+Depth liGen.append(("%s+%s:" % (_("Time"), _("Depth")), alm.timedepth)) # MultiPV liGen.append(SEPARADOR) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) config = FormLayout.Combobox( _("Number of moves evaluated by engine(MultiPV)"), li) liGen.append((config, alm.multiPV)) liGen.append(SEPARADOR) liJ = [(_("White"), "BLANCAS"), (_("Black"), "NEGRAS"), (_("White & Black"), "AMBOS")] config = FormLayout.Combobox(_("Analyze only color"), liJ) liGen.append((config, "AMBOS")) liGen.append( ("<div align=\"right\">" + _("Only player moves") + ":<br>%s</div>" % _("(You can add multiple aliases separated by ; and wildcard * )"), "")) fvar = configuracion.ficheroBooks listaLibros = Books.ListaLibros() listaLibros.recuperaVar(fvar) # Comprobamos que todos esten accesibles listaLibros.comprueba() defecto = listaLibros.lista[0] li = [("--", None)] for libro in listaLibros.lista: if libro.nombre == alm.libro: defecto = libro li.append((libro.nombre, libro)) config = FormLayout.Combobox( _("Do not scan the opening moves based on book"), li) liGen.append((config, defecto)) liGen.append((_("Start from the end of the game") + ":", alm.desdeelfinal)) liGen.append(SEPARADOR) liGen.append((_("Only selected games") + ":", siVariosSeleccionados)) liBlunders, liBrilliancies = formBlundersBrilliancies(alm, configuracion) lista = [] lista.append((liGen, _("General options"), "")) lista.append((liBlunders, _("Wrong moves"), "")) lista.append((liBrilliancies, _("Brilliancies"), "")) reg = Util.Almacen() reg.form = None def dispatchR(valor): if reg.form is None: if isinstance(valor, FormLayout.FormTabWidget): reg.form = valor reg.wtime = valor.getWidget(0, 1) reg.wdepth = valor.getWidget(0, 2) reg.wdt = valor.getWidget(0, 3) elif isinstance(valor, FormLayout.FormWidget): reg.form = valor reg.wtime = valor.getWidget(1) reg.wdepth = valor.getWidget(2) reg.wdt = valor.getWidget(3) else: sender = reg.form.sender() if not reg.wdt.isChecked(): if sender == reg.wtime: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif sender == reg.wdepth: if reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) elif sender == reg.wdt: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) QTUtil.refreshGUI() resultado = FormLayout.fedit(lista, title=_("Mass analysis"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones(), dispatch=dispatchR) if resultado: accion, liResp = resultado liGen, liBlunders, liBrilliancies = liResp alm.motor = liGen[0] alm.tiempo = int(liGen[1] * 1000) alm.depth = liGen[2] alm.timedepth = liGen[3] alm.multiPV = liGen[4] color = liGen[5] alm.blancas = color != "NEGRAS" alm.negras = color != "BLANCAS" cjug = liGen[6].strip() alm.liJugadores = cjug.upper().split(";") if cjug else None alm.libroAperturas = liGen[7] alm.libro = alm.libroAperturas.nombre alm.desdeelfinal = liGen[8] alm.siVariosSeleccionados = liGen[9] alm.kblunders = liBlunders[0] alm.tacticblunders = liBlunders[1] alm.pgnblunders = liBlunders[2] alm.oriblunders = liBlunders[3] alm.bmtblunders = liBlunders[4] alm.dpbrilliancies = liBrilliancies[0] alm.ptbrilliancies = liBrilliancies[1] alm.fnsbrilliancies = liBrilliancies[2] alm.pgnbrilliancies = liBrilliancies[3] alm.oribrilliancies = liBrilliancies[4] alm.bmtbrilliancies = liBrilliancies[5] dic = {} for x in dir(alm): if not x.startswith("__"): dic[x.upper()] = getattr(alm, x) Util.guardaVar(configuracion.ficheroAnalisis, dic) if not (alm.tacticblunders or alm.pgnblunders or alm.bmtblunders or alm.fnsbrilliancies or alm.pgnbrilliancies or alm.bmtbrilliancies): QTUtil2.mensError(parent, _("No file was specified where to save results")) return return alm else: return None
def borrar(self): tam_dbop = len(self.dbop) if tam_dbop == 0: return menu = QTVarios.LCMenu(self) current = self.glines.recno() // 2 if 0 <= current < tam_dbop: menu.opcion("current", _("Remove line %d") % (current + 1, ), Iconos.Mover()) menu.separador() if tam_dbop > 1: menu.opcion("lines", _("Remove a list of lines"), Iconos.MoverLibre()) menu.separador() menu.opcion("worst", _("Remove worst lines"), Iconos.Borrar()) menu.separador() submenu = menu.submenu(_("Remove last move if the line ends with"), Iconos.Final()) submenu.opcion("last_white", _("White"), Iconos.Blancas()) submenu.separador() submenu.opcion("last_black", _("Black"), Iconos.Negras()) resp = menu.lanza() if resp == "current": self.dbop.saveHistory(_("Remove line %d") % (current + 1, )) del self.dbop[current] self.goto_inilinea() elif resp == "lines": liGen = [FormLayout.separador] config = FormLayout.Editbox("<div align=\"right\">" + _("Lines") + "<br>" + _("By example:") + " -5,8-12,14,19-", rx="[0-9,\-,\,]*") liGen.append((config, "")) resultado = FormLayout.fedit(liGen, title=_("Remove a list of lines"), parent=self, anchoMinimo=460, icon=Iconos.OpeningLines()) if resultado: accion, liResp = resultado clista = liResp[0] if clista: ln = Util.ListaNumerosImpresion(clista) li = ln.selected(range(1, tam_dbop + 1)) sli = [] cad = "" for num in li: if cad: cad += "," + str(num) else: cad = str(num) if len(cad) > 80: if len(sli) == 4: sli.append("...") elif len(sli) < 4: sli.append(cad) cad = "" if cad: sli.append(cad) cli = "\n".join(sli) if QTUtil2.pregunta( self, _("Do you want to remove the next lines?") + "\n\n" + cli): um = QTUtil2.unMomento(self, _("Working...")) self.dbop.removeLines([x - 1 for x in li], cli) self.glines.refresh() self.goto_inilinea() um.final() elif resp == "worst": self.remove_worst() elif resp == "last_white": self.remove_lastmove(True) elif resp == "last_black": self.remove_lastmove(False) self.show_lines()
def paramAnalisisMasivo(parent, configuracion, siVariosSeleccionados, siDatabase=False): alm = leeDicParametros(configuracion) # Datos liGen = [SEPARADOR] # # Tutor li = configuracion.ayudaCambioTutor() li[0] = alm.engine liGen.append((_("Engine") + ":", li)) liGen.append(SEPARADOR) # # Time config = FormLayout.Editbox(_("Duration of engine analysis (secs)"), 40, tipo=float) liGen.append((config, alm.vtime / 1000.0)) # Depth liDepths = [("--", 0)] for x in range(1, 31): liDepths.append((str(x), x)) config = FormLayout.Combobox(_("Depth"), liDepths) liGen.append((config, alm.depth)) # Time+Depth liGen.append(("%s+%s:" % (_("Time"), _("Depth")), alm.timedepth)) # MultiPV liGen.append(SEPARADOR) li = [(_("Default"), "PD"), (_("Maximum"), "MX")] for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200): li.append((str(x), str(x))) config = FormLayout.Combobox(_("Number of moves evaluated by engine(MultiPV)"), li) liGen.append((config, alm.multiPV)) liGen.append(SEPARADOR) liJ = [(_("White"), "WHITE"), (_("Black"), "BLACK"), (_("White & Black"), "BOTH")] config = FormLayout.Combobox(_("Analyze only color"), liJ) if alm.white and alm.black: color = "BOTH" elif alm.black: color = "BLACK" elif alm.white: color = "WHITE" else: color = "BOTH" liGen.append((config, color)) liGen.append(('<div align="right">' + _("Only player moves") + ":<br>%s</div>" % _("(You can add multiple aliases separated by ; and wildcard * )"), "")) fvar = configuracion.ficheroBooks listaLibros = Books.ListaLibros() listaLibros.restore_pickle(fvar) # Comprobamos que todos esten accesibles listaLibros.comprueba() defecto = listaLibros.lista[0] li = [("--", None)] for book in listaLibros.lista: if book.name == alm.book_name: defecto = book li.append((book.name, book)) config = FormLayout.Combobox(_("Do not scan the opening moves based on book"), li) liGen.append((config, defecto)) liGen.append((_("Start from the end of the game") + ":", alm.from_last_move)) liGen.append(SEPARADOR) liGen.append((_("Redo any existing prior analyses (if they exist)") + ":", alm.delete_previous)) liGen.append(SEPARADOR) liGen.append((_("Only selected games") + ":", siVariosSeleccionados)) liVar = form_variations(alm) liBlunders, liBrilliancies = formBlundersBrilliancies(alm, configuracion) lista = [] lista.append((liGen, _("General options"), "")) lista.append((liVar, _("Variations"), "")) lista.append((liBlunders, _("Wrong moves"), "")) lista.append((liBrilliancies, _("Brilliancies"), "")) reg = Util.Record() reg.form = None def dispatchR(valor): if reg.form is None: if isinstance(valor, FormLayout.FormTabWidget): reg.form = valor reg.wtime = valor.getWidget(0, 1) reg.wdepth = valor.getWidget(0, 2) reg.wdt = valor.getWidget(0, 3) elif isinstance(valor, FormLayout.FormWidget): reg.form = valor reg.wtime = valor.getWidget(1) reg.wdepth = valor.getWidget(2) reg.wdt = valor.getWidget(3) else: sender = reg.form.sender() if not reg.wdt.isChecked(): if sender == reg.wtime: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif sender == reg.wdepth: if reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) elif sender == reg.wdt: if reg.wtime.textoFloat() > 0: reg.wdepth.setCurrentIndex(0) elif reg.wdepth.currentIndex() > 0: reg.wtime.ponFloat(0.0) QTUtil.refresh_gui() resultado = FormLayout.fedit(lista, title=_("Mass analysis"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones(), dispatch=dispatchR) if resultado: accion, liResp = resultado liGen, liVar, liBlunders, liBrilliancies = liResp alm.engine, vtime, alm.depth, alm.timedepth, alm.multiPV, color, cjug, alm.book, alm.from_last_move, alm.delete_previous, alm.siVariosSeleccionados = liGen alm.vtime = int(vtime * 1000) alm.white = color != "BLACK" alm.black = color != "WHITE" cjug = cjug.strip() alm.li_players = cjug.upper().split(";") if cjug else None alm.book_name = alm.book.name if alm.book else None alm.kblunders, alm.tacticblunders, alm.pgnblunders, alm.oriblunders, alm.bmtblunders = liBlunders alm.include_variations, alm.limiteinclude_variations, alm.best_variation, alm.info_variation, alm.si_pdt, alm.one_move_variation = liVar alm.dpbrilliancies, alm.ptbrilliancies, alm.fnsbrilliancies, alm.pgnbrilliancies, alm.oribrilliancies, alm.bmtbrilliancies = liBrilliancies dic = {} for x in dir(alm): if not x.startswith("__"): dic[x.upper()] = getattr(alm, x) Util.save_pickle(configuracion.file_param_analysis(), dic) if not (alm.tacticblunders or alm.pgnblunders or alm.bmtblunders or alm.fnsbrilliancies or alm.pgnbrilliancies or alm.bmtbrilliancies or siDatabase): QTUtil2.message_error(parent, _("No file was specified where to save results")) return return alm else: return None
def __init__(self, owner, regMarker, xml=None, nombre=None): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Marker")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.configuracion = VarGen.configuracion if not regMarker: regMarker = TabVisual.PMarker() regMarker.xml = xml if nombre: regMarker.nombre = nombre liAcciones = [ (_("Save"), Iconos.Aceptar(), self.grabar), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None, ] tb = Controles.TBrutina(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.TableroVisual(self, confTablero) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del svg que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regMarker.nombre)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regMarker.opacidad * 100))) # ( "psize", "n", 100 ), config = FormLayout.Spinbox(_("Size") + " %", 1, 1600, 50) liGen.append((config, regMarker.psize)) # ( "poscelda", "n", 1 ), li = ( ("%s-%s" % (_("Top"), _("Left")), 0), ("%s-%s" % (_("Top"), _("Right")), 1), ("%s-%s" % (_("Bottom"), _("Left")), 2), ("%s-%s" % (_("Bottom"), _("Right")), 3), ) config = FormLayout.Combobox(_("Position in the square"), li) liGen.append((config, regMarker.poscelda)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regMarker.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regMarker.a1h8 = a1h8 regMarker.siMovible = True marker = self.tablero.creaMarker(regMarker, siEditando=True) self.liEjemplos.append(marker)
def __init__(self, owner, regMarco): QtWidgets.QDialog.__init__(self, owner) self.setWindowTitle(_("Box")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) if not regMarco: regMarco = TabVisual.PMarco() liAcciones = [ (_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero self.tablero = Tablero.Tablero(self, confTablero, siDirector=False) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] # nombre del marco que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regMarco.nombre)) # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas()) liGen.append((config, regMarco.tipo)) # ( "color", "n", 0 ), config = FormLayout.Colorbox(_("Color"), 80, 20) liGen.append((config, regMarco.color)) # ( "colorinterior", "n", -1 ), config = FormLayout.Colorbox(_("Internal color"), 80, 20, siChecked=True) liGen.append((config, regMarco.colorinterior)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regMarco.opacidad * 100))) # ( "grosor", "n", 1 ), # ancho del trazo config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50) liGen.append((config, regMarco.grosor)) # ( "redEsquina", "n", 0 ), config = FormLayout.Spinbox(_("Rounded corners"), 0, 100, 50) liGen.append((config, regMarco.redEsquina)) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regMarco.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["b4c4", "e2e2", "e4g7"] self.liEjemplos = [] for a1h8 in liMovs: regMarco.a1h8 = a1h8 regMarco.siMovible = True marco = self.tablero.creaMarco(regMarco) self.liEjemplos.append(marco)
def xconfig(label, value): config = FormLayout.Editbox(label, 80, tipo=float, decimales=3) liGen.append((config, value))
def gmCrear(self): if self.torneo.numEngines() < 2: QTUtil2.mensError(self, _("You must create at least two engines")) return dicValores = self.configuracion.leeVariables("crear_torneo") get = dicValores.get liGen = [(None, None)] config = FormLayout.Spinbox(_("Rounds"), 1, 999, 50) liGen.append((config, get("ROUNDS", 1))) liGen.append((None, None)) config = FormLayout.Editbox(_("Total minutes"), 40, tipo=float, decimales=2) liGen.append((config, get("MINUTES", 10.00))) config = FormLayout.Spinbox(_("Seconds added per move"), 0, 999, 50) liGen.append((config, get("SECONDS", 0))) liGen.append((None, _("Engines"))) liEngines = self.torneo.liEngines() for pos, en in enumerate(liEngines): liGen.append((en.alias, get(en.huella(), True))) liGen.append((None, None)) liGen.append((_("Select all"), False)) liGen.append((None, None)) liGen.append((_("Random order"), True)) reg = Util.Almacen() reg.form = None def dispatch(valor): if reg.form is None or not hasattr(reg, "selectall"): if hasattr(valor, "getWidget"): reg.form = valor reg.liEngines = [] leng = len(liEngines) for x in range(leng): reg.liEngines.append(valor.getWidget(x + 3)) reg.selectall = valor.getWidget(leng + 3) reg.valorall = False else: QTUtil.refreshGUI() select = reg.selectall.isChecked() if select != reg.valorall: for uno in reg.liEngines: uno.setChecked(select) reg.valorall = select QTUtil.refreshGUI() resultado = FormLayout.fedit(liGen, title=_("Games"), parent=self, icon=Iconos.Torneos(), dispatch=dispatch) if resultado is None: return accion, liResp = resultado dicValores["ROUNDS"] = rounds = liResp[0] dicValores["MINUTES"] = minutos = liResp[1] dicValores["SECONDS"] = segundos = liResp[2] liSel = [] for num in range(self.torneo.numEngines()): en = liEngines[num] dicValores[en.huella()] = si = liResp[3 + num] if si: liSel.append(en.huella()) rnd = liResp[-1] self.configuracion.escVariables("crear_torneo", dicValores) nSel = len(liSel) if nSel < 2: QTUtil2.mensError(self, _("You must create at least two engines")) return for r in range(rounds): for x in range(0, nSel - 1): for y in range(x + 1, nSel): self.torneo.nuevoGame(liSel[x], liSel[y], minutos, segundos) self.torneo.nuevoGame(liSel[y], liSel[x], minutos, segundos) if rnd: self.torneo.randomize() self.gridGames.refresh() self.gridGames.gobottom() self.borraResult()
def mas(self): path_pgn = QTVarios.select_pgn(self) if not path_pgn: return path_db = self.configuration.ficheroTemporal("lcdb") db = DBgames.DBgames(path_db) dlTmp = QTVarios.ImportarFicheroPGN(self) dlTmp.show() db.import_pgns([path_pgn], dlTmp=dlTmp) db.close() dlTmp.close() db = DBgames.DBgames(path_db) nreccount = db.all_reccount() if nreccount == 0: return plant = "" shuffle = False reverse = False todos = range(1, nreccount + 1) li_regs = [] max_moves = 0 while True: sep = FormLayout.separador liGen = [] liGen.append((None, "%s: %d" % (_("Total games"), nreccount))) liGen.append(sep) config = FormLayout.Editbox(_("Select games") + "<br>" + _("By example:") + " -5,7-9,14,19-" + "<br>" + _("Empty means all games"), rx="[0-9,\-,\,]*") liGen.append((config, plant)) liGen.append(sep) liGen.append((_("Shuffle") + ":", shuffle)) liGen.append(sep) liGen.append((_("Reverse") + ":", reverse)) liGen.append(sep) config = FormLayout.Spinbox(_("Max moves"), 0, 999, 50) liGen.append((config, 0)) resultado = FormLayout.fedit(liGen, title=_("Select games"), parent=self, anchoMinimo=200, icon=Iconos.Opciones()) if resultado: accion, liResp = resultado plant, shuffle, reverse, max_moves = liResp if plant: ln = Util.ListaNumerosImpresion(plant) li_regs = ln.selected(todos) else: li_regs = todos nregs = len(li_regs) if 12 <= nregs <= 500: break else: QTUtil2.message_error( self, "%s (%d)" % (_("Number of games must be in range 12-500"), nregs)) li_regs = None else: break if li_regs: if shuffle: random.shuffle(li_regs) if reverse: li_regs.sort(reverse=True) li_regs = [x - 1 for x in li_regs] # 0 init dic = {} dic["TOURNEY"] = os.path.basename(path_pgn)[:-4] games = dic["GAMES"] = [] for recno in li_regs: g = db.read_game_recno(recno) pv = g.pv() if max_moves: lipv = pv.strip().split(" ") if len(lipv) > max_moves: pv = " ".join(lipv[:max_moves]) dt = {"LABELS": g.li_tags, "XPV": FasterCode.pv_xpv(pv)} games.append(dt) self.litourneys.append(dic) li = [("%s (%d)" % (tourney["TOURNEY"], len(tourney["GAMES"])), tourney) for tourney in self.litourneys] self.cbtourney.rehacer(li, dic) db.close()
def editar(self, fila): if fila is None: nombre = "" eco = "" pgn = "" estandar = True titulo = _("New opening") else: reg = self.lista[fila] nombre = reg["NOMBRE"] eco = reg["ECO"] pgn = reg["PGN"] estandar = reg["ESTANDAR"] titulo = nombre # Datos liGen = [(None, None)] liGen.append((_("Name") + ":", nombre)) config = FormLayout.Editbox("ECO", ancho=30, rx="[A-Z, a-z][0-9][0-9]") liGen.append((config, eco)) liGen.append((_("Add to standard list") + ":", estandar)) # Editamos resultado = FormLayout.fedit(liGen, title=titulo, parent=self, anchoMinimo=460, icon=Iconos.Apertura()) if resultado is None: return accion, liResp = resultado nombre = liResp[0].strip() if not nombre: return eco = liResp[1].upper() estandar = liResp[2] fen = ControlPosicion.FEN_INICIAL self.procesador.procesador = self.procesador # ya que editaVariante espera un gestor resp = Variantes.editaVariante(self.procesador, self.procesador, fen, pgn, titulo=nombre, siBlancasAbajo=True) if resp: pgn, a1h8 = resp reg = {} reg["NOMBRE"] = nombre reg["ECO"] = eco reg["PGN"] = pgn reg["A1H8"] = a1h8 reg["ESTANDAR"] = estandar if fila is None: self.lista.append(reg) self.grid.refresh() self.grabar() else: self.lista[fila] = reg self.grid.refresh() self.grabar()
def editar(self, una, icono): if una is None: una = {} # Datos basicos liGen = [(None, None)] liGen.append((FormLayout.Editbox(_("Name")), una.get("NOMBRE", ""))) liGen.append((None, None)) config = FormLayout.Fichero(_("Debug file"), "txt", True) liGen.append((config, una.get("DEBUG", ""))) liGen.append((None, None)) liGen.append((None, _("Serious errors, select the best move if:"))) liGen.append((FormLayout.Editbox(_("Mate is less than or equal to"), tipo=int, ancho=50), una.get("MAXMATE", 0))) liGen.append(( FormLayout.Editbox(_("The loss of points is greater than"), tipo=int, ancho=50), una.get("MINDIFPUNTOS", 0), )) liGen.append((None, None)) liGen.append(( FormLayout.Editbox( _("Max. loss of points per move by the <br> engine to reach a leveled evaluation" ), tipo=int, ancho=50, ), una.get("ATERRIZAJE", 50), )) # Apertura liA = [(None, None)] config = FormLayout.Fichero(_("Polyglot book"), "bin", False) liA.append((config, una.get("BOOK", ""))) # Medio juego liMJ = [(None, None)] # # Ajustar liMJ.append((FormLayout.Combobox(_("Strength"), self.listaAjustes(False)), una.get("AJUSTAR", ADJUST_BETTER))) # Movimiento siguiente liMJ.append((None, _("In the next move"))) trlistaSG = [ _("To move a pawn"), _("Advance piece"), _("Make check"), _("Capture") ] listaSG = ["MOVERPEON", "AVANZARPIEZA", "JAQUE", "CAPTURAR"] for n, opcion in enumerate(listaSG): liMJ.append((FormLayout.Spinbox(trlistaSG[n], -2000, +2000, 50), una.get(opcion, 0))) # Movimientos previstos liMJ.append((None, _("In the expected moves"))) trlistaPR = [ _("Keep the two bishops"), _("Advance"), _("Make check"), _("Capture") ] listaPR = ["2B", "AVANZAR", "JAQUE", "CAPTURAR"] for n, opcion in enumerate(listaPR): liMJ.append((FormLayout.Spinbox(trlistaPR[n], -2000, +2000, 50), una.get(opcion + "PR", 0))) # Final liF = [(None, None)] # Ajustar liF.append((FormLayout.Combobox(_("Strength"), self.listaAjustes(False)), una.get("AJUSTARFINAL", ADJUST_BETTER))) liF.append((FormLayout.Spinbox(_("Maximum pieces at this stage"), 0, 32, 50), una.get("MAXPIEZASFINAL", 0))) liF.append((None, None)) # Movimiento siguiente liF.append((None, _("In the next move"))) for n, opcion in enumerate(listaSG): liF.append((FormLayout.Spinbox(trlistaSG[n], -2000, +2000, 50), una.get(opcion + "F", 0))) # Movimientos previstos liF.append((None, _("In the expected moves"))) for n, opcion in enumerate(listaPR): liF.append((FormLayout.Spinbox(trlistaPR[n], -2000, +2000, 50), una.get(opcion + "PRF", 0))) while True: lista = [] lista.append((liGen, _("Basic data"), "")) lista.append((liA, _("Opening"), "")) lista.append((liMJ, _("Middlegame"), "")) lista.append((liF, _("Endgame"), "")) resultado = FormLayout.fedit(lista, title=_("Personalities"), parent=self.owner, anchoMinimo=460, icon=icono) if resultado: accion, liResp = resultado liGenR, liAR, liMJR, liFR = liResp name = liGenR[0].strip() if not name: QTUtil2.message_error(self.owner, _("Missing name")) continue una = {} # Base una["NOMBRE"] = name una["DEBUG"] = liGenR[1] una["MAXMATE"] = liGenR[2] una["MINDIFPUNTOS"] = liGenR[3] una["ATERRIZAJE"] = liGenR[4] # Apertura una["BOOK"] = liAR[0] # Medio una["AJUSTAR"] = liMJR[0] for num, opcion in enumerate(listaSG): una[opcion] = liMJR[num + 1] nSG = len(listaSG) + 1 for num, opcion in enumerate(listaPR): una[opcion + "PR"] = liMJR[num + nSG] # Final una["AJUSTARFINAL"] = liFR[0] una["MAXPIEZASFINAL"] = liFR[1] for num, opcion in enumerate(listaSG): una[opcion + "F"] = liFR[num + 2] nSG = len(listaSG) + 2 for num, opcion in enumerate(listaPR): una[opcion + "PRF"] = liFR[num + nSG] return una return None
def edit(self, row): if row is None: name = "" eco = "" pgn = "" estandar = True titulo = _("New opening") else: reg = self.lista[row] name = reg["NOMBRE"] eco = reg["ECO"] pgn = reg["PGN"] estandar = reg["ESTANDAR"] titulo = name # Datos liGen = [(None, None)] liGen.append((_("Name") + ":", name)) config = FormLayout.Editbox("ECO", ancho=30, rx="[A-Z, a-z][0-9][0-9]") liGen.append((config, eco)) liGen.append((_("Add to standard list") + ":", estandar)) # Editamos resultado = FormLayout.fedit(liGen, title=titulo, parent=self, anchoMinimo=460, icon=Iconos.Opening()) if resultado is None: return accion, liResp = resultado name = liResp[0].strip() if not name: return eco = liResp[1].upper() estandar = liResp[2] fen = FEN_INITIAL self.procesador.procesador = self.procesador # ya que edit_variation espera un manager if pgn: ok, game = Game.pgn_game(pgn) if not ok: game = Game.Game() else: game = Game.Game() resp = Variations.edit_variation(self.procesador, game, titulo=name, is_white_bottom=True) if resp: game = resp reg = {} reg["NOMBRE"] = name reg["ECO"] = eco reg["PGN"] = game.pgnBaseRAW() reg["A1H8"] = game.pv() reg["ESTANDAR"] = estandar if row is None: self.lista.append(reg) self.grid.refresh() self.grabar() else: self.lista[row] = reg self.grid.refresh() self.grabar()
def gm_crear_queued(self): if self.torneo.num_engines() < 2: QTUtil2.message_error(self, _("You must create at least two engines")) return dicValores = self.configuracion.leeVariables("crear_torneo") get = dicValores.get liGen = [FormLayout.separador] config = FormLayout.Spinbox(_("Rounds"), 1, 999, 50) liGen.append((config, get("ROUNDS", 1))) liGen.append(FormLayout.separador) config = FormLayout.Editbox(_("Total minutes"), 40, tipo=float, decimales=2) liGen.append((config, get("MINUTES", 10.00))) config = FormLayout.Editbox(_("Seconds added per move"), 40, tipo=float, decimales=2) liGen.append((config, get("SECONDS", 0.0))) liGen.append((None, _("Engines"))) li_engines = self.torneo.list_engines() for pos, en in enumerate(li_engines): liGen.append((en.clave, get(en.huella, True))) liGen.append(FormLayout.separador) resultado = FormLayout.fedit(liGen, title=_("Games"), parent=self, icon=Iconos.Torneos()) if resultado is None: return accion, liResp = resultado dicValores["ROUNDS"] = rounds = liResp[0] dicValores["MINUTES"] = minutos = liResp[1] dicValores["SECONDS"] = segundos = liResp[2] liSel = [] for num in range(self.torneo.num_engines()): en = li_engines[num] dicValores[en.huella] = si = liResp[3 + num] if si: liSel.append(en.huella) self.configuracion.escVariables("crear_torneo", dicValores) nSel = len(liSel) if nSel < 2: QTUtil2.message_error(self, _("You must use at least two engines")) return for r in range(rounds): for x in range(0, nSel - 1): for y in range(x + 1, nSel): self.torneo.nuevoGame(liSel[x], liSel[y], minutos, segundos) self.torneo.nuevoGame(liSel[y], liSel[x], minutos, segundos) self.gridGamesQueued.refresh() self.gridGamesQueued.gobottom() self.rotulos_tabs()
def __init__(self, owner, regFlecha, siNombre): QtGui.QDialog.__init__(self, owner) self.setWindowTitle(_("Arrow")) self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint) self.siNombre = siNombre if not regFlecha: regFlecha = TabVisual.PFlecha() liAcciones = [ (_("Save"), Iconos.Aceptar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "reject"), None, ] tb = Controles.TB(self, liAcciones) # Tablero confTablero = owner.tablero.confTablero.copia( owner.tablero.confTablero.id()) confTablero.anchoPieza(32) self.tablero = Tablero.TableroVisual(self, confTablero) self.tablero.crea() self.tablero.copiaPosicionDe(owner.tablero) # Datos generales liGen = [] if siNombre: # nombre de la flecha que se usara en los menus del tutorial config = FormLayout.Editbox(_("Name"), ancho=120) liGen.append((config, regFlecha.nombre)) # ( "forma", "t", "a" ), # a = abierta -> , c = cerrada la cabeza, p = poligono cuadrado, liFormas = ( (_("Opened"), "a"), (_("Head closed"), "c"), (_("Polygon 1"), "1"), (_("Polygon 2"), "2"), (_("Polygon 3"), "3"), ) config = FormLayout.Combobox(_("Form"), liFormas) liGen.append((config, regFlecha.forma)) # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas()) liGen.append((config, regFlecha.tipo)) # liGen.append( (None,None) ) # ( "color", "n", 0 ), config = FormLayout.Colorbox(_("Color"), 80, 20) liGen.append((config, regFlecha.color)) # ( "colorinterior", "n", -1 ), # si es cerrada config = FormLayout.Colorbox(_("Internal color"), 80, 20, siChecked=True) liGen.append((config, regFlecha.colorinterior)) # ( "opacidad", "n", 1.0 ), config = FormLayout.Dial(_("Degree of transparency"), 0, 99) liGen.append((config, 100 - int(regFlecha.opacidad * 100))) # liGen.append( (None,None) ) # ( "redondeos", "l", False ), liGen.append((_("Rounded edges"), regFlecha.redondeos)) # ( "grosor", "n", 1 ), # ancho del trazo config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50) liGen.append((config, regFlecha.grosor)) # liGen.append( (None,None) ) # ( "altocabeza", "n", 1 ), # altura de la cabeza config = FormLayout.Spinbox(_("Head height"), 0, 100, 50) liGen.append((config, regFlecha.altocabeza)) # ( "ancho", "n", 10 ), # ancho de la base de la flecha si es un poligono config = FormLayout.Spinbox(_("Base width"), 1, 100, 50) liGen.append((config, regFlecha.ancho)) # ( "vuelo", "n", 5 ), # vuelo de la flecha respecto al ancho de la base config = FormLayout.Spinbox( _("Additional width of the base of the head"), 1, 100, 50) liGen.append((config, regFlecha.vuelo)) # ( "descuelgue", "n", 2 ), # vuelo hacia arriba config = FormLayout.Spinbox(_("Height of the base angle of the head"), -100, 100, 50) liGen.append((config, regFlecha.descuelgue)) # liGen.append( (None,None) ) # ( "destino", "t", "c" ), # c = centro, m = minimo config = FormLayout.Combobox(_("Target position"), tiposDestino()) liGen.append((config, regFlecha.destino)) # liGen.append( (None,None) ) # orden config = FormLayout.Combobox(_("Order concerning other items"), QTUtil2.listaOrdenes()) liGen.append((config, regFlecha.posicion.orden)) self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios) # Layout layout = Colocacion.H().control(self.form).relleno().control( self.tablero) layout1 = Colocacion.V().control(tb).otro(layout) self.setLayout(layout1) # Ejemplos liMovs = ["d2d6", "a8h8", "h5b7"] self.liEjemplos = [] for a1h8 in liMovs: regFlecha.a1h8 = a1h8 regFlecha.siMovible = True flecha = self.tablero.creaFlecha(regFlecha) self.liEjemplos.append(flecha)
def mas(self): path = QTVarios.select_pgn(self) if not path: return fpgn = PGN.PGN() dicDB = fpgn.leeFichero(self, path) if dicDB is None: return bd = SQLBase.DBBase(dicDB["PATHDB"]) dClavesTam = dicDB["DCLAVES"] dbf = bd.dbf("GAMES", ",".join(dClavesTam.keys())) dbf.leer() nreccount = dbf.reccount() plant = "" shuffle = False reverse = False todos = range(1, nreccount + 1) li_regs = None while True: sep = FormLayout.separador liGen = [] liGen.append((None, "%s: %d" % (_("Total games"), nreccount))) liGen.append(sep) config = FormLayout.Editbox(_("Select games") + "<br>" + _("By example:") + " -5,7-9,14,19-" + "<br>" + _("Empty means all games"), rx="[0-9,\-,\,]*") liGen.append((config, plant)) liGen.append(sep) liGen.append((_("Shuffle") + ":", shuffle)) liGen.append(sep) liGen.append((_("Reverse") + ":", reverse)) liGen.append(sep) config = FormLayout.Spinbox(_("Max moves"), 0, 999, 50) liGen.append((config, 0)) resultado = FormLayout.fedit(liGen, title=_("Select games"), parent=self, anchoMinimo=200, icon=Iconos.Opciones()) if resultado: accion, liResp = resultado plant, shuffle, reverse, max_moves = liResp if plant: ln = Util.ListaNumerosImpresion(plant) li_regs = ln.selected(todos) else: li_regs = todos nregs = len(li_regs) if 12 <= nregs <= 500: break else: QTUtil2.mensError( self, "%s (%d)" % (_("Number of games must be in range 12-500"), nregs)) li_regs = None else: break if li_regs: if shuffle: random.shuffle(li_regs) if reverse: li_regs.sort(reverse=True) li_regs = [x - 1 for x in li_regs] # 0 init dic = {} dic["TOURNEY"] = os.path.basename(path)[:-4] games = dic["GAMES"] = [] for recno in li_regs: pgn = dbf.leeOtroCampo(recno, "PGN") g = PGNReader.read1Game(pgn) pv = g.pv() if max_moves: lipv = pv.strip().split(" ") if len(lipv) > max_moves: pv = " ".join(lipv[:max_moves]) dt = { "LABELS": [(k, v) for k, v in g.labels.items()], "XPV": LCEngine.pv2xpv(pv) } games.append(dt) self.litourneys.append(dic) li = [("%s (%d)" % (tourney["TOURNEY"], len(tourney["GAMES"])), tourney) for tourney in self.litourneys] self.cbtourney.rehacer(li, dic) dbf.cerrar() bd.cerrar()