示例#1
0
    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
            if self.siMoves and (self.posHistoria >= len(self.historia) - 1):
                self.MoverInicio()
            self.lanzaReloj()
示例#2
0
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
示例#3
0
    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()
示例#4
0
    def reindexar(self, depth=None):
        if depth is None or self.wb_database.is_temporary:
            # if not QTUtil2.pregunta(self, _("Do you want to rebuild stats?")):
            #     return

            li_gen = [(None, None)]
            li_gen.append((None, _("Select the number of moves <br> for each game to be considered")))
            li_gen.append((None, None))

            config = FormLayout.Spinbox(_("Depth"), 0, 255, 50)
            li_gen.append((config, self.dbGames.depth_stat()))

            resultado = FormLayout.fedit(li_gen, title=_("Rebuild"), parent=self, icon=Iconos.Reindexar())
            if resultado is None:
                return None

            accion, li_resp = resultado

            depth = li_resp[0]

        self.RECCOUNT = 0

        bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding"))
        bpTmp.mostrar()

        def dispatch(recno, reccount):
            if reccount != self.RECCOUNT:
                self.RECCOUNT = reccount
                bpTmp.ponTotal(reccount)
            bpTmp.pon(recno)
            return not bpTmp.is_canceled()

        self.dbGames.rebuild_stat(dispatch, depth)
        bpTmp.cerrar()
        self.start()
示例#5
0
    def importarLeeParam(self, titulo, dicData):
        liGen = [FormLayout.separador]

        liGen.append((
            None,
            _("Select a maximum number of moves (plies)<br> to consider from each game"
              )))
        liGen.append((FormLayout.Spinbox(_("Depth"), 3, 99,
                                         50), dicData.get("DEPTH", 30)))
        liGen.append(FormLayout.separador)

        li = [(_("Only white best moves"), True),
              (_("Only black best moves"), False)]
        config = FormLayout.Combobox(_("Moves"), li)
        liGen.append((config, dicData.get("SIWHITE", True)))
        liGen.append(FormLayout.separador)

        liGen.append(
            (FormLayout.Spinbox(_("Minimum moves must have each line"), 0, 99,
                                50), dicData.get("MINMOVES", 0)))

        resultado = FormLayout.fedit(liGen,
                                     title=titulo,
                                     parent=self,
                                     anchoMinimo=360,
                                     icon=Iconos.PuntoNaranja())
        if resultado:
            accion, liResp = resultado
            depth, siWhite, minMoves = liResp
            dicData["DEPTH"] = depth
            dicData["SIWHITE"] = siWhite
            dicData["MINMOVES"] = minMoves
            self.configuracion.escVariables("WBG_MOVES", dicData)
            return dicData
        return None
示例#6
0
def numPosicion(wParent, titulo, nFEN, pos):

    liGen = [FormLayout.separador]

    label = "%s (1..%d)"%(_("Select position"), nFEN)
    liGen.append((FormLayout.Spinbox(label, 1, nFEN, 50), pos))

    liGen.append(FormLayout.separador)

    li = [   ( _("Sequential"), "s"),
             ( _("Random"), "r"),
             ( _("Random with same sequence based on position"), "rk" )
    ]
    liGen.append( (FormLayout.Combobox(_("Type"), li), "s") )

    liGen.append(FormLayout.separador)

    liGen.append( (_("Jump to the next after solve")+":", False))

    resultado = FormLayout.fedit(liGen, title=titulo, parent=wParent, anchoMinimo=200,
                                     icon=Iconos.Entrenamiento())
    if resultado:
        posicion, tipo, jump = resultado[1]
        return posicion, tipo, jump
    else:
        return None
示例#7
0
    def reindexar(self):
        if not QTUtil2.pregunta(self, _("Do you want to rebuild stats?")):
            return

        # Select depth
        liGen = [(None, None)]
        liGen.append((None, _("Select the number of moves <br> for each game to be considered")))
        liGen.append((None, None))

        config = FormLayout.Spinbox(_("Depth"), 3, 255, 50)
        liGen.append((config, self.dbGames.depthStat()))

        resultado = FormLayout.fedit(liGen, title=_("Rebuild"), parent=self, icon=Iconos.Reindexar())
        if resultado is None:
            return None

        accion, liResp = resultado

        depth = liResp[0]

        self.RECCOUNT = 0

        bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding"))
        bpTmp.mostrar()

        def dispatch(recno, reccount):
            if reccount != self.RECCOUNT:
                self.RECCOUNT = reccount
                bpTmp.ponTotal(reccount)
            bpTmp.pon(recno)
            return not bpTmp.siCancelado()

        self.dbGames.recrearSTAT(dispatch, depth)
        bpTmp.cerrar()
        self.inicio()
示例#8
0
    def tg_append_polyglot(self):

        previo = VarGen.configuracion.leeVariables("WBG_MOVES")
        carpeta = previo.get("CARPETABIN", "")

        ficheroBIN = QTUtil2.leeFichero(self, carpeta, "%s (*.bin)" % _("Polyglot book"), titulo=_("File to import"))
        if not ficheroBIN:
            return
        previo["CARPETABIN"] = os.path.dirname(ficheroBIN)
        VarGen.configuracion.escVariables("WBG_MOVES", previo)

        liGen = [(None, None)]

        liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game") ))

        liGen.append(( FormLayout.Spinbox(_("Depth"), 3, 99, 50), 30 ))
        liGen.append((None, None))

        liGen.append(( _("Only white best moves"), False ))
        liGen.append((None, None))

        liGen.append(( _("Only black best moves"), False ))
        liGen.append((None, None))

        resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroBIN), parent=self, anchoMinimo=360,
                                     icon=Iconos.PuntoNaranja())

        if resultado:
            accion, liResp = resultado
            depth, whiteBest, blackBest = liResp
            return self.bookGuide.grabarPolyglot(self, ficheroBIN, depth, whiteBest, blackBest)

        return False
示例#9
0
    def changeFolder(self):
        nof = _("New opening folder")
        base = self.configuration.folder_base_openings
        li = [x for x in os.listdir(base) if os.path.isdir(os.path.join(base, x))]
        menu = QTVarios.LCMenu(self)
        rondo = QTVarios.rondoPuntos()
        menu.opcion("", _("Home folder"), Iconos.Home())
        menu.separador()
        for x in li:
            menu.opcion(x, x, rondo.otro())
        menu.separador()
        menu.opcion(":n", nof, Iconos.Nuevo())
        if Code.is_windows:
            menu.separador()
            menu.opcion(":m", _("Direct maintenance"), Iconos.Configurar())

        resp = menu.lanza()
        if resp is not None:
            if resp == ":m":
                os.startfile(base)
                return

            elif resp == ":n":
                name = ""
                error = ""
                while True:
                    li_gen = [FormLayout.separador]
                    li_gen.append((nof + ":", name))
                    if error:
                        li_gen.append(FormLayout.separador)
                        li_gen.append((None, error))

                    resultado = FormLayout.fedit(li_gen, title=nof, parent=self, icon=Iconos.OpeningLines(), anchoMinimo=460)
                    if resultado:
                        accion, liResp = resultado
                        name = liResp[0].strip()
                        if name:
                            path = os.path.join(base, name)
                            try:
                                os.mkdir(path)
                            except:
                                error = _("Unable to create this folder")
                                continue
                            if not os.path.isdir(path):
                                continue
                            break
                    else:
                        return
            else:
                path = os.path.join(base, resp)

            path = Util.relative_path(path)
            self.configuration.set_folder_openings(path)
            self.configuration.graba()
            self.listaOpenings = OpeningLines.ListaOpenings(self.configuration)
            self.glista.refresh()
            self.glista.gotop()
            if len(self.listaOpenings) == 0:
                self.wtrain.setVisible(False)
            self.setWindowTitle(self.getTitulo())
示例#10
0
    def empezar(self):
        regBase = self.liIntentos[0] if self.liIntentos else {}

        liGen = [(None, None)]

        liGen.append((FormLayout.Spinbox(_("Level"), 0, self.partida.numJugadas(), 40), regBase.get("LEVEL", 0)))
        liGen.append((None, None))
        liGen.append((None, _("User play with") + ":"))
        liGen.append((_("White"), "w" in regBase.get("COLOR", "bw")))
        liGen.append((_("Black"), "b" in regBase.get("COLOR", "bw")))
        liGen.append((None, None))
        liGen.append((_("Show clock"), True))

        resultado = FormLayout.fedit(liGen, title=_("New try"), anchoMinimo=200, parent=self,
                                     icon=Iconos.TutorialesCrear())
        if resultado is None:
            return

        accion, liResp = resultado
        level = liResp[0]
        white = liResp[1]
        black = liResp[2]
        if not (white or black):
            return
        siClock = liResp[3]

        w = WLearnPuente(self, self.partida, level, white, black, siClock)
        w.exec_()
示例#11
0
    def cambiarJuego(self):
        mateg = self.controlMate.ultimoNivel()
        ult_nivel = mateg.nivel + 1
        ult_bloque = mateg.numBloqueSinHacer() + 1
        if mateg.siTerminado():
            ult_nivel += 1
            ult_bloque = 1

        liGen = [(None, None)]

        config = FormLayout.Spinbox(_("Level"), 1, ult_nivel, 50)
        liGen.append(( config, ult_nivel ))

        config = FormLayout.Spinbox(_("Block"), 1, 10, 50)
        liGen.append(( config, ult_bloque ))

        resultado = FormLayout.fedit(liGen, title=_("Level"), parent=self.pantalla, icon=Iconos.Jugar())

        if resultado:
            nv, bl = resultado[1]
            nv -= 1
            bl -= 1
            self.controlMate.ponNivel(nv)
            self.ponRotuloNivel()
            self.refresh()
            self.jugar(bl)
示例#12
0
 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
示例#13
0
def paramPelicula(configuracion, parent):

    nomVar = "PARAMPELICULA"
    dicVar = configuracion.leeVariables(nomVar)

    # Datos
    liGen = [(None, None)]

    # # Segundos
    liGen.append((_("Number of seconds between moves") + ":", dicVar.get("SECONDS", 2)))
    liGen.append(FormLayout.separador)

    # # Si desde el principio
    liGen.append((_("Start from first move") + ":", dicVar.get("START", True)))
    liGen.append(FormLayout.separador)

    liGen.append((_("Show PGN") + ":", dicVar.get("PGN", True)))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("Replay game"), parent=parent, anchoMinimo=460, icon=Iconos.Pelicula())

    if resultado:
        accion, liResp = resultado

        segundos, siPrincipio, siPGN = liResp
        dicVar["SECONDS"] = segundos
        dicVar["START"] = siPrincipio
        dicVar["PGN"] = siPGN
        configuracion.escVariables(nomVar, dicVar)
        return segundos, siPrincipio, siPGN
    else:
        return None
示例#14
0
    def data_new(self):
        menu = QTVarios.LCMenu(self)

        menu1 = menu.submenu(_("Checkmates in GM games"), Iconos.GranMaestro())
        menu1.opcion("mate_basic", _("Basic"), Iconos.PuntoAzul())
        menu1.separador()
        menu1.opcion("mate_easy", _("Easy"), Iconos.PuntoAmarillo())
        menu1.opcion("mate_medium", _("Medium"), Iconos.PuntoNaranja())
        menu1.opcion("mate_hard", _("Hard"), Iconos.PuntoRojo())

        menu.separador()
        menu.opcion("sts_basic", _("STS: Strategic Test Suite"), Iconos.STS())

        resp = menu.lanza()
        if resp:
            tipo, model = resp.split("_")
            if tipo == "sts":
                liGen = [(None, None)]
                liR = [(str(x), x) for x in range(1, 100)]
                config = FormLayout.Combobox(_("Model"), liR)
                liGen.append((config, "1"))
                resultado = FormLayout.fedit(
                    liGen,
                    title=_("STS: Strategic Test Suite"),
                    parent=self,
                    anchoMinimo=160,
                    icon=Iconos.Maps())
                if resultado is None:
                    return
                accion, liResp = resultado
                model = liResp[0]
            self.workmap.nuevo(tipo, model)
            self.activaWorkmap()
示例#15
0
def opcionesPrimeraVez(parent, configuracion):
    separador = (None, None)

    # Datos generales
    liGen = [separador]

    # # Nombre del jugador
    liGen.append((_("Player's name") + ":", configuracion.jugador))

    # Editamos
    resultado = FormLayout.fedit(liGen,
                                 title=_("Configuration"),
                                 parent=parent,
                                 anchoMinimo=560,
                                 icon=Iconos.Opciones())

    if resultado:
        accion, resp = resultado

        liGen = resp

        configuracion.jugador = liGen[0]

        return True
    else:
        return False
示例#16
0
def paramPelicula(parent):
    # Datos
    liGen = [(None, None)]

    # # Segundos
    liGen.append((_("Number of seconds between moves") + ":", 2))

    # # Si desde el principi
    liGen.append((_("Start from first move") + ":", True))

    # Editamos
    resultado = FormLayout.fedit(liGen,
                                 title=_("Replay game"),
                                 parent=parent,
                                 anchoMinimo=460,
                                 icon=Iconos.Pelicula())

    if resultado:
        accion, liResp = resultado

        segundos = liResp[0]
        siPrincipio = liResp[1]
        return segundos, siPrincipio
    else:
        return None
    def changePlayer(self, lp):
        liGen = []
        lista = [(player, player) for player in lp]
        config = FormLayout.Combobox(_("Name"), lista)
        liGen.append((config, self.leeVariable("PLAYER", "")))

        listaAlias = lista[:]
        listaAlias.insert(0, ("--", ""))
        for nalias in range(1, 4):
            liGen.append(FormLayout.separador)
            config = FormLayout.Combobox("%s %d" % (_("Alias"), nalias),
                                         listaAlias)
            liGen.append((config, self.leeVariable("ALIAS%d" % nalias, "")))

        resultado = FormLayout.fedit(liGen,
                                     title=_("Player"),
                                     parent=self,
                                     anchoMinimo=200,
                                     icon=Iconos.Player())
        if resultado is None:
            return
        accion, liGen = resultado
        nombre, alias1, alias2, alias3 = liGen
        self.escVariable("PLAYER", nombre)
        self.escVariable("ALIAS1", alias1)
        self.escVariable("ALIAS2", alias2)
        self.escVariable("ALIAS3", alias3)
        self.setPlayer(nombre)
        self.tw_rebuild()
    def empezar(self):
        regBase = self.liIntentos[0] if self.liIntentos else {}

        liGen = [(None, None)]

        liGen.append((FormLayout.Spinbox(_("Level"), 0,
                                         self.partida.numJugadas(),
                                         40), regBase.get("LEVEL", 0)))
        liGen.append((None, None))
        liGen.append((None, _("User play with") + ":"))
        liGen.append((_("White"), "w" in regBase.get("COLOR", "bw")))
        liGen.append((_("Black"), "b" in regBase.get("COLOR", "bw")))
        liGen.append((None, None))
        liGen.append((_("Show clock"), True))

        resultado = FormLayout.fedit(liGen,
                                     title=_("New try"),
                                     anchoMinimo=200,
                                     parent=self,
                                     icon=Iconos.TutorialesCrear())
        if resultado is None:
            return

        accion, liResp = resultado
        level = liResp[0]
        white = liResp[1]
        black = liResp[2]
        if not (white or black):
            return
        siClock = liResp[3]

        w = WLearnPuente(self, self.partida, level, white, black, siClock)
        w.exec_()
示例#19
0
    def importarPGN(self, game):
        previo = self.configuracion.leeVariables("OPENINGLINES")
        carpeta = previo.get("CARPETAPGN", "")

        ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import"))
        if not ficheroPGN:
            return
        previo["CARPETAPGN"] = os.path.dirname(ficheroPGN)

        liGen = [(None, None)]

        liGen.append((None, _("Select a maximum number of moves (plies)<br> to consider from each game")))

        liGen.append((FormLayout.Spinbox(_("Depth"), 3, 999, 50), previo.get("IPGN_DEPTH", 30)))
        liGen.append((None, None))

        liVariations = ((_("All"), "A"), (_("None"), "N"), (_("White"), "W"), (_("Black"), "B"))
        config = FormLayout.Combobox(_("Include variations"), liVariations)
        liGen.append((config, previo.get("IPGN_VARIATIONSMODE", "A")))
        liGen.append((None, None))

        resultado = FormLayout.fedit(
            liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460, icon=Iconos.PuntoNaranja()
        )

        if resultado:
            accion, liResp = resultado
            previo["IPGN_DEPTH"] = depth = liResp[0]
            previo["IPGN_VARIATIONSMODE"] = variations = liResp[1]

            self.dbop.importarPGN(self, game, ficheroPGN, depth, variations)
            self.glines.refresh()
            self.glines.gotop()
            self.configuracion.escVariables("OPENINGLINES", previo)
示例#20
0
 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
示例#21
0
def numPosicion(wParent, titulo, nFEN, pos):

    liGen = [FormLayout.separador]

    label = "%s (1..%d)" % (_("Select position"), nFEN)
    liGen.append((FormLayout.Spinbox(label, 1, nFEN, 50), pos))

    liGen.append(FormLayout.separador)

    li = [(_("Sequential"), "s"), (_("Random"), "r"),
          (_("Random with same sequence based on position"), "rk")]
    liGen.append((FormLayout.Combobox(_("Type"), li), "s"))

    liGen.append(FormLayout.separador)

    liGen.append((_("Jump to the next after solve") + ":", False))

    resultado = FormLayout.fedit(liGen,
                                 title=titulo,
                                 parent=wParent,
                                 anchoMinimo=200,
                                 icon=Iconos.Entrenamiento())
    if resultado:
        posicion, tipo, jump = resultado[1]
        return posicion, tipo, jump
    else:
        return None
示例#22
0
 def editarNombre(self, previo, siNuevo=False):
     while True:
         liGen = [(None, None)]
         liGen.append((_("Name") + ":", previo))
         resultado = FormLayout.fedit(liGen,
                                      title=_("STS: Strategic Test Suite"),
                                      parent=self,
                                      icon=Iconos.STS())
         if resultado:
             accion, liGen = resultado
             nombre = Util.validNomFichero(liGen[0].strip())
             if nombre:
                 if not siNuevo and previo == nombre:
                     return None
                 path = os.path.join(self.carpetaSTS, nombre + ".sts")
                 if os.path.isfile(path):
                     QTUtil2.mensError(
                         self,
                         _("The file %s already exist") % nombre)
                     continue
                 return nombre
             else:
                 return None
         else:
             return None
    def configurar(self):
        segundos, puntos, maxerror = self.resistance.actual()

        separador = FormLayout.separador

        liGen = [separador]

        config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80)
        liGen.append((config, segundos))

        liGen.append(separador)

        config = FormLayout.Spinbox(_("Max lost points in total"), 10, 99999,
                                    80)
        liGen.append((config, puntos))

        liGen.append(separador)

        config = FormLayout.Spinbox(
            _("Max lost points in a single move") + ":\n" +
            _("0 = not consider this limit"), 0, 1000, 80)
        liGen.append((config, maxerror))

        resultado = FormLayout.fedit(liGen,
                                     title=_("Config"),
                                     parent=self,
                                     icon=Iconos.Configurar())
        if resultado:
            accion, liResp = resultado
            segundos, puntos, maxerror = liResp
            self.resistance.cambiaconfiguration(segundos, puntos, maxerror)
            self.set_textAyuda()
            self.grid.refresh()
            return liResp[0]
示例#24
0
    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
示例#25
0
    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
示例#26
0
def cambioTutor(parent, configuracion):
    liGen = [(None, None)]

    # # Tutor
    liGen.append(( _("Engine") + ":", configuracion.ayudaCambioTutor() ))

    # # Decimas de segundo a pensar el tutor
    liGen.append(( _("Duration of engine analysis (secs)") + ":", float(configuracion.tiempoTutor / 1000.0) ))
    li = [( _("Maximum"), 0)]
    for x in ( 1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200 ):
        li.append((str(x), x))
    config = FormLayout.Combobox(_("Number of moves evaluated by engine(MultiPV)"), li)
    liGen.append(( config, configuracion.tutorMultiPV ))

    liGen.append(( None, _("Sensitivity") ))
    liGen.append((FormLayout.Spinbox(_("Minimum difference in points"), 0, 1000, 70), configuracion.tutorDifPts ))
    liGen.append((FormLayout.Spinbox(_("Minimum difference in %"), 0, 1000, 70), configuracion.tutorDifPorc ))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("Tutor change"), parent=parent, anchoMinimo=460, icon=Iconos.Opciones())

    if resultado:
        claveMotor, tiempo, multiPV, difpts, difporc = resultado[1]
        configuracion.tutor = configuracion.buscaTutor(claveMotor)
        configuracion.tiempoTutor = int(tiempo*1000)
        configuracion.tutorMultiPV = multiPV
        configuracion.tutorDifPts = difpts
        configuracion.tutorDifPorc = difporc
        configuracion.graba()
        return True
    else:
        return False
示例#27
0
    def cambiarJuego(self):
        mateg = self.controlMate.ultimoNivel()
        ult_nivel = mateg.nivel + 1
        ult_bloque = mateg.numBloqueSinHacer() + 1
        if mateg.siTerminado():
            ult_nivel += 1
            ult_bloque = 1

        liGen = [(None, None)]

        config = FormLayout.Spinbox(_("Level"), 1, ult_nivel, 50)
        liGen.append((config, ult_nivel))

        config = FormLayout.Spinbox(_("Block"), 1, 10, 50)
        liGen.append((config, ult_bloque))

        resultado = FormLayout.fedit(liGen,
                                     title=_("Level"),
                                     parent=self.pantalla,
                                     icon=Iconos.Jugar())

        if resultado:
            nv, bl = resultado[1]
            nv -= 1
            bl -= 1
            self.controlMate.ponNivel(nv)
            self.ponRotuloNivel()
            self.refresh()
            self.jugar(bl)
示例#28
0
    def new(self):
        si_expl = len(self.listaOpenings) < 4
        if si_expl:
            QTUtil2.mensaje(self, _("First you must select the initial moves."))
        w = PantallaAperturas.WAperturas(self, self.configuracion, None)
        if w.exec_():
            ap = w.resultado()
            pv = ap.a1h8 if ap else ""
            name = ap.nombre if ap else ""
        else:
            return

        if si_expl:
            QTUtil2.mensaje(self, _("Secondly you have to choose a name for this opening studio."))

        liGen = [(None, None)]
        liGen.append((_("Opening studio name") + ":", name))
        resultado = FormLayout.fedit(liGen, title=_("Opening studio name"), parent=self, icon=Iconos.OpeningLines(), anchoMinimo=460)
        if resultado:
            accion, liResp = resultado
            name = liResp[0]
            if name:
                file = self.listaOpenings.select_filename(name)
                self.listaOpenings.new(file, pv, name)
                self.resultado = self.listaOpenings[-1]
                self.guardarVideo()
                self.accept()
示例#29
0
    def getNewName(self, title, previous=""):
        name = previous

        while True:
            liGen = [(None, None)]
            liGen.append(( _("Name") + ":", name ))

            resultado = FormLayout.fedit(liGen, title=title, parent=self, anchoMinimo=460,
                                         icon=Iconos.TutorialesCrear())
            if resultado is None:
                return None

            accion, liResp = resultado
            name = liResp[0].strip()
            if not name:
                return None

            name = Util.validNomFichero(name)

            ok = True
            for k in self.bookGuide.getOtras():
                if k.lower() == name.lower():
                    QTUtil2.mensError(self, _("This name is repeated, please select other"))
                    ok = False
                    break
            if ok:
                return name
示例#30
0
    def importarPolyglot(self, partida):
        listaLibros = Books.ListaLibros()
        listaLibros.recuperaVar(self.configuracion.ficheroBooks)
        listaLibros.comprueba()

        liGen = [FormLayout.separador]

        li = [(book.nombre, book) for book in listaLibros.lista]
        config = FormLayout.Combobox(_("Book that plays white side"), li)
        liGen.append((config, listaLibros.lista[0]))
        liGen.append(FormLayout.separador)
        config = FormLayout.Combobox(_("Book that plays black side"), li)
        liGen.append((config, listaLibros.lista[0]))
        liGen.append(FormLayout.separador)

        resultado = FormLayout.fedit(liGen, title=_("Polyglot book"), parent=self, anchoMinimo=360, icon=Iconos.Libros())
        if resultado:
            accion, liResp = resultado
            bookW, bookB = liResp
        else:
            return

        bookW.polyglot()
        bookB.polyglot()

        titulo = bookW.nombre if bookW==bookB else "%s/%s" % (bookW.nombre, bookB.nombre)
        dicData = self.configuracion.leeVariables("OPENINGLINES")
        dicData = self.importarLeeParam(titulo, dicData)
        if dicData:
            depth, siWhite, minMoves = dicData["DEPTH"], dicData["SIWHITE"], dicData["MINMOVES"]
            self.dbop.importarPolyglot(self, partida, bookW, bookB, titulo, depth, siWhite, minMoves)
            self.glines.refresh()
            self.glines.gotop()
示例#31
0
    def tg_append_pgn(self):

        previo = VarGen.configuracion.leeVariables("WBG_MOVES")
        carpeta = previo.get("CARPETAPGN", "")

        ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import"))
        if not ficheroPGN:
            return
        previo["CARPETAPGN"] = os.path.dirname(ficheroPGN)
        VarGen.configuracion.escVariables("WBG_MOVES", previo)

        liGen = [(None, None)]

        liGen.append(( None, _("Select a maximum number of moves (plies)<br> to consider from each game") ))

        liGen.append(( FormLayout.Spinbox(_("Depth"), 3, 999, 50), 30 ))
        liGen.append((None, None))

        resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460,
                                     icon=Iconos.PuntoNaranja())

        if resultado:
            accion, liResp = resultado
            depth = liResp[0]
            return self.bookGuide.grabarPGN(self, ficheroPGN, depth)
        return False
示例#32
0
    def importarPGN(self, partida):
        previo = self.configuracion.leeVariables("OPENINGLINES")
        carpeta = previo.get("CARPETAPGN", "")

        ficheroPGN = QTUtil2.leeFichero(self, carpeta, "%s (*.pgn)" % _("PGN Format"), titulo=_("File to import"))
        if not ficheroPGN:
            return
        previo["CARPETAPGN"] = os.path.dirname(ficheroPGN)
        self.configuracion.escVariables("OPENINGLINES", previo)

        liGen = [(None, None)]

        liGen.append((None, _("Select a maximum number of moves (plies)<br> to consider from each game")))

        liGen.append((FormLayout.Spinbox(_("Depth"), 3, 999, 50), 30))
        liGen.append((None, None))

        resultado = FormLayout.fedit(liGen, title=os.path.basename(ficheroPGN), parent=self, anchoMinimo=460,
                                     icon=Iconos.PuntoNaranja())

        if resultado:
            accion, liResp = resultado
            depth = liResp[0]

            self.dbop.importarPGN(self, partida, ficheroPGN, depth)
            self.glines.refresh()
            self.glines.gotop()
示例#33
0
    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
示例#34
0
    def data_new(self):
        menu = QTVarios.LCMenu(self)

        menu1 = menu.submenu(_("Checkmates in GM games"), Iconos.GranMaestro())
        menu1.opcion( "mate_basic", _( "Basic" ), Iconos.PuntoAzul() )
        menu1.separador()
        menu1.opcion( "mate_easy", _( "Easy" ), Iconos.PuntoAmarillo() )
        menu1.opcion( "mate_medium", _( "Medium" ), Iconos.PuntoNaranja() )
        menu1.opcion( "mate_hard", _( "Hard" ), Iconos.PuntoRojo() )

        menu.separador()
        menu.opcion("sts_basic", _("STS: Strategic Test Suite"), Iconos.STS())

        resp = menu.lanza()
        if resp:
            tipo, model = resp.split("_")
            if tipo == "sts":
                liGen = [(None, None)]
                liR = [ (str(x), x) for x in range(1, 100) ]
                config = FormLayout.Combobox(_("Model"), liR)
                liGen.append((config, "1"))
                resultado = FormLayout.fedit(liGen, title=_("STS: Strategic Test Suite"), parent=self, anchoMinimo=160, icon=Iconos.Maps())
                if resultado is None:
                    return
                accion, liResp = resultado
                model = liResp[0]
            self.workmap.nuevo(tipo,model)
            self.activaWorkmap()
示例#35
0
    def configurations(self):
        dic = Code.configuration.read_variables("BLINDFOLD")
        dicConf = collections.OrderedDict()
        for k in dic:
            if k.startswith("_"):
                cl = k[1:]
                dicConf[cl] = dic[k]

        menu = QTVarios.LCMenu(self)
        for k in dicConf:
            menu.opcion((True, k), k, Iconos.PuntoAzul())
        menu.separador()
        menu.opcion((True, None), _("Save current configuration"),
                    Iconos.PuntoVerde())
        if dicConf:
            menu.separador()
            menudel = menu.submenu(_("Remove"), Iconos.Delete())
            for k in dicConf:
                menudel.opcion((False, k), k, Iconos.PuntoNegro())

        resp = menu.lanza()
        if resp is None:
            return

        si, cual = resp

        if si:
            if cual:
                dpz = dic["_" + cual]
                for pz in "kqrbnp":
                    lbPZw, cbPZw, lbPZ, lbPZb, cbPZb, tipoW, tipoB = self.dicWidgets[
                        pz]
                    cbPZw.ponValor(dpz[pz.upper()])
                    cbPZb.ponValor(dpz[pz])
                self.reset()
            else:
                liGen = [(None, None)]
                liGen.append((_("Name") + ":", ""))

                resultado = FormLayout.fedit(
                    liGen,
                    title=_("Save current configuration"),
                    parent=self,
                    anchoMinimo=460,
                    icon=Iconos.TutorialesCrear(),
                )
                if resultado is None:
                    return None

                accion, liResp = resultado
                name = liResp[0].strip()
                if not name:
                    return None
                dic["_%s" % name] = self.config.dicPiezas
                Code.configuration.write_variables("BLINDFOLD", dic)
        else:
            del dic["_%s" % cual]
            Code.configuration.write_variables("BLINDFOLD", dic)
示例#36
0
def polyglotUnir(owner):
    lista = [(None, None)]

    dict1 = {"FICHERO": "", "EXTENSION": "bin", "SISAVE": False}
    lista.append((_("File") + " 1 :", dict1))
    dict2 = {"FICHERO": "", "EXTENSION": "bin", "SISAVE": False}
    lista.append((_("File") + " 2 :", dict2))
    dictr = {"FICHERO": "", "EXTENSION": "bin", "SISAVE": True}
    lista.append((_("Book to create") + ":", dictr))

    while True:
        resultado = FormLayout.fedit(lista, title=_("Merge two books in one"), parent=owner, anchoMinimo=460, icon=Iconos.Libros())
        if resultado:
            resultado = resultado[1]
            error = None
            f1 = resultado[0]
            f2 = resultado[1]
            fr = resultado[2]

            if (not f1) or (not f2) or (not fr):
                error = _("Not indicated all files")
            elif f1 == f2:
                error = _("File") + " 1 = " + _("File") + " 2"
            elif f1 == fr:
                error = _("File") + " 1 = " + _("Book to create")
            elif f2 == fr:
                error = _("File") + " 2 = " + _("Book to create")

            if error:
                dict1["FICHERO"] = f1
                dict2["FICHERO"] = f2
                dictr["FICHERO"] = fr
                QTUtil2.message_error(owner, error)
                continue
        else:
            return

        exe = "%s/_tools/polyglot/polyglot" % Code.folder_engines

        li = [os.path.abspath(exe), "merge-book", "-in1", f1, "-in2", f2, "-out", fr]
        try:
            os.remove(fr)
        except:
            pass

        # Ejecutamos
        me = QTUtil2.unMomento(owner)

        process = subprocess.Popen(li, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

        # Mostramos el resultado
        txt = process.stdout.read()
        if os.path.isfile(fr):
            txt += "\n" + _X(_("Book created : %1"), fr)
        me.final()
        QTUtil2.message_bold(owner, txt)

        return
示例#37
0
def nuevaKibitzer(ventana, configuracion):
    # Datos generales
    liGen = [(None, None)]

    # # Nombre
    liGen.append((_("Kibitzer") + ":", ""))

    # Motor
    config = FormLayout.Combobox(_("Engine"), configuracion.comboMotoresCompleto())
    liGen.append((config, "stockfish"))

    # Tipo
    liTipos = ["M",
               ("M", _("Candidates")),
               ("I", _("Indexes") + " - RodentII" ),
               ("S", _("Best move")),
               ("L", _("Best move in one line")),
               ("J", _("Select move")),
               ("C", _("Threats")),
               ("E", _("Stockfish evaluation")),
               ]
    liGen.append((_("Type"), liTipos))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("New"), parent=ventana, anchoMinimo=460, icon=Iconos.Kibitzer())

    if resultado:
        accion, resp = resultado

        kibitzer = resp[0]
        motor = resp[1]
        tipo = resp[2]

        # Indexes only with Rodent II
        if tipo == "I":
            motor = "rodentII"
            if not kibitzer: # para que no repita rodent II
                kibitzer = _("Indexes") + " - RodentII"

        if not kibitzer:
            for xtipo, txt in liTipos[1:]:
                if xtipo == tipo:
                    kibitzer = "%s: %s" % (txt, motor)

        d = datetime.datetime.now()
        xid = "MOS" + d.isoformat()[2:].strip("0").replace("-", "").replace("T", "").replace(":", "").replace(".", "")
        fvideo = configuracion.plantillaVideo % xid

        dic = {"NOMBRE": kibitzer, "MOTOR": motor, "TIPO": tipo, "FVIDEO": fvideo}

        liKibitzers = listaKibitzersRecuperar(configuracion)
        liKibitzers.append(dic)

        listaKibitzersGrabar(configuracion, liKibitzers)

        return liKibitzers
    else:
        return None
示例#38
0
    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()
示例#39
0
    def reindexarPlayer(self):
        dic = VarGen.configuracion.leeVariables("reindexplayer")

        # Select depth
        liGen = [(None, None)]
        liGen.append(( _("Player (wildcards=*)"), dic.get("player", "")))
        liGen.append((None, None))
        liGen.append(( None, _("Select the number of moves <br> for each game to be considered") ))
        liGen.append((None, None))

        li = [(str(n), n) for n in range(3, 255)]
        config = FormLayout.Combobox(_("Depth"), li)
        liGen.append(( config, dic.get("depth", 30) ))

        resultado = FormLayout.fedit(liGen, title=_("Summary filtering by player"), parent=self,
                                     icon=Iconos.Reindexar())
        if resultado is None:
            return None

        accion, liResp = resultado

        dic["player"] = player = liResp[0]
        if not player:
            return
        dic["depth"] = depth = liResp[1]

        VarGen.configuracion.escVariables("reindexplayer", dic)

        class CLT:
            pass

        clt = CLT()
        clt.RECCOUNT = 0
        clt.SICANCELADO = False

        bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding"))
        bpTmp.mostrar()

        def dispatch(recno, reccount):
            if reccount != clt.RECCOUNT:
                clt.RECCOUNT = reccount
                bpTmp.ponTotal(reccount)
            bpTmp.pon(recno)
            if bpTmp.siCancelado():
                clt.SICANCELADO = True

            return not clt.SICANCELADO

        self.dbGames.recrearSTATplayer(dispatch, depth, player)
        bpTmp.cerrar()
        if clt.SICANCELADO:
            self.dbGames.ponSTATbase()
        self.grid.refresh()
示例#40
0
    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
示例#41
0
def dameMinutosExtra(pantalla):
    liGen = [(None, None)]

    config = FormLayout.Spinbox(_("Extra minutes for the player"), 1, 99, 50)
    liGen.append(( config, 5 ))

    resultado = FormLayout.fedit(liGen, title=_("Time"), parent=pantalla, icon=Iconos.MoverTiempo())
    if resultado:
        accion, liResp = resultado
        return liResp[0]

    return None
示例#42
0
def nuevaKibitzer(ventana, configuracion):
    # Datos generales
    liGen = [(None, None)]

    # # Nombre
    liGen.append(( _("Kibitzer") + ":", "" ))

    ## Motor
    config = FormLayout.Combobox(_("Engine"), configuracion.comboMotoresCompleto())
    liGen.append(( config, "stockfish" ))

    ## Tipo
    liTipos = ["M",
               ( "M", _("Candidates") ),
               ( "I", _("Indexes") ),
               ( "S", _("Best move") ),
               ( "L", _("Best move in one line") ),
               ( "J", _("Select move") ),
               ( "C", _("Threats") ),
               ( "E", _("Stockfish eval") ),
    ]
    liGen.append((_("Type"), liTipos))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("New"), parent=ventana, anchoMinimo=460, icon=Iconos.Kibitzer())

    if resultado:
        accion, resp = resultado

        kibitzer = resp[0]
        motor = resp[1]
        tipo = resp[2]
        if not kibitzer:
            for xtipo, txt in liTipos[1:]:
                if xtipo == tipo:
                    kibitzer = "%s: %s" % (txt, motor)

        d = datetime.datetime.now()
        xid = "MOS" + d.isoformat()[2:].strip("0").replace("-", "").replace("T", "").replace(":", "").replace(".", "")
        fvideo = configuracion.plantillaVideo % xid

        dic = {"NOMBRE": kibitzer, "MOTOR": motor, "TIPO": tipo, "FVIDEO": fvideo}

        liKibitzers = listaKibitzersRecuperar(configuracion)
        liKibitzers.append(dic)

        listaKibitzersGrabar(configuracion, liKibitzers)

        return liKibitzers
    else:
        return None
示例#43
0
    def configurations(self):
        dic = VarGen.configuracion.leeVariables("BLINDFOLD")
        dicConf = collections.OrderedDict()
        for k in dic:
            if k.startswith("_"):
                cl = k[1:]
                dicConf[cl] = dic[k]

        menu = QTVarios.LCMenu(self)
        for k in dicConf:
            menu.opcion((True, k), k, Iconos.PuntoAzul())
        menu.separador()
        menu.opcion((True, None), _("Save current configuration"), Iconos.PuntoVerde())
        if dicConf:
            menu.separador()
            menudel = menu.submenu(_("Remove"), Iconos.Delete())
            for k in dicConf:
                menudel.opcion((False, k), k, Iconos.PuntoNegro())

        resp = menu.lanza()
        if resp is None:
            return

        si, cual = resp

        if si:
            if cual:
                dpz = dic["_" + cual]
                for pz in "kqrbnp":
                    lbPZw, cbPZw, lbPZ, lbPZb, cbPZb, tipoW, tipoB = self.dicWidgets[pz]
                    cbPZw.ponValor(dpz[pz.upper()])
                    cbPZb.ponValor(dpz[pz])
                self.reset()
            else:
                liGen = [(None, None)]
                liGen.append(( _("Name") + ":", "" ))

                resultado = FormLayout.fedit(liGen, title=_("Save current configuration"), parent=self, anchoMinimo=460,
                                             icon=Iconos.TutorialesCrear())
                if resultado is None:
                    return None

                accion, liResp = resultado
                name = liResp[0].strip()
                if not name:
                    return None
                dic["_%s" % name] = self.config.dicPiezas
                VarGen.configuracion.escVariables("BLINDFOLD", dic)
        else:
            del dic["_%s" % cual]
            VarGen.configuracion.escVariables("BLINDFOLD", dic)
示例#44
0
    def newBookmark(self, move):

        comment = move.comment()
        allpgn = move.allPGN()
        siComment = len(comment) > 0

        txt = comment if siComment else allpgn

        liGen = [(None, None)]
        liGen.append(( _("Name") + ":", txt ))

        liGen.append(( _("Copy PGN") + ":", False ))
        if siComment:
            liGen.append(( _("Copy comment") + ":", False ))

        reg = KRegistro()
        reg.allpgn = allpgn
        reg.comment = comment.split("\n")[0].strip()
        reg.form = None

        def dispatch(valor):
            if reg.form is None:
                reg.form = valor
                reg.wname = valor.getWidget(0)
                reg.wpgn = valor.getWidget(1)
                reg.wcomment = valor.getWidget(2)
                reg.wpgn.setText(reg.allpgn)
                if reg.wcomment:
                    reg.wcomment.setText(reg.comment)
            else:
                QTUtil.refreshGUI()
                if reg.wpgn.isChecked():
                    reg.wname.setText(reg.allpgn)
                elif reg.wcomment and reg.wcomment.isChecked():
                    reg.wname.setText(reg.comment)
                if reg.wcomment:
                    reg.wcomment.setChecked(False)
                reg.wpgn.setChecked(False)
                QTUtil.refreshGUI()

        resultado = FormLayout.fedit(liGen, title=_("Bookmark"), parent=self.wmoves, anchoMinimo=460,
                                     icon=Iconos.Favoritos(), dispatch=dispatch)
        if resultado is None:
            return None

        accion, liResp = resultado
        txt = liResp[0].strip()
        if txt:
            move.mark(txt)
            self.ponIconoBookmark(move.item(), move.mark())
            self.wmoves.compruebaBookmarks()
示例#45
0
    def entrenar(self, fil=None, col=None):
        if len(self.lista) == 0:
            return
        if fil is None:
            fil = self.grid.recno()

        # Ultimo entrenamiento
        dicPar = Util.recuperaVar(self.ficheroParam)
        if dicPar is None:
            jugamos = "BLANCAS"
            repeticiones = 5
        else:
            jugamos = dicPar["JUGAMOS"]
            repeticiones = dicPar["REPETICIONES"]
        if not ((col is None) or (col.clave == "NOMBRE")):
            jugamos = col.clave

        # Datos
        liGen = [(None, None)]

        liJ = [(_("White"), "BLANCAS"), (_("Black"), "NEGRAS"), (_("White & Black"), "AMBOS")]
        config = FormLayout.Combobox(_("Play with"), liJ)
        liGen.append(( config, jugamos ))

        liR = [( _("Undefined"), 0 )]

        for x in range(4):
            liR.append((str(x + 1), x + 1))

        for x in range(5, 105, 5):
            liR.append((str(x), x))
        config = FormLayout.Combobox(_("Model"), liR)
        liGen.append(( config, repeticiones ))

        # Editamos
        resultado = FormLayout.fedit(liGen, title=_("Train"), parent=self, anchoMinimo=360, icon=Iconos.Entrenar())
        if resultado is None:
            return

        accion, liResp = resultado
        jugamos = liResp[0]
        repeticiones = liResp[1]

        dicPar = {}
        dicPar["JUGAMOS"] = jugamos
        dicPar["REPETICIONES"] = repeticiones
        Util.guardaVar(self.ficheroParam, dicPar)

        self.resultado = (self.listaAperturasStd, self.ficheroDatos, self.lista, fil, jugamos, repeticiones)
        self.accept()
示例#46
0
    def desdeHasta(self, titulo, desde, hasta):
        liGen = [(None, None)]

        config = FormLayout.Casillabox(_("From square"))
        liGen.append(( config, desde ))

        config = FormLayout.Casillabox(_("To square"))
        liGen.append(( config, hasta ))

        resultado = FormLayout.fedit(liGen, title=titulo, parent=self)
        if resultado:
            resp = resultado[1]
            self.ultDesde = desde = resp[0]
            self.ultHasta = hasta = resp[1]
            return desde, hasta
        else:
            return None, None
示例#47
0
    def configurar(self):
        segundos, puntos = self.boxing.actual()

        liGen = [(None, None)]

        config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80)
        liGen.append(( config, segundos ))

        config = FormLayout.Spinbox(_("Points"), 10, 99999, 80)
        liGen.append(( config, puntos ))

        resultado = FormLayout.fedit(liGen, title=_("Config"), parent=self, icon=Iconos.Configurar())
        if resultado:
            accion, liResp = resultado
            segundos = liResp[0]
            puntos = liResp[1]
            self.boxing.cambiaConfiguracion(segundos, puntos)
            self.ponTextoAyuda()
            self.grid.refresh()
            return liResp[0]
示例#48
0
 def editarNombre(self, previo, siNuevo=False):
     while True:
         liGen = [(None, None)]
         liGen.append((_("Name") + ":", previo))
         resultado = FormLayout.fedit(liGen, title=_("STS: Strategic Test Suite"), parent=self, icon=Iconos.STS())
         if resultado:
             accion, liGen = resultado
             nombre = Util.validNomFichero(liGen[0].strip())
             if nombre:
                 if not siNuevo and previo == nombre:
                     return None
                 path = os.path.join(self.carpetaSTS, nombre + ".sts")
                 if os.path.isfile(path):
                     QTUtil2.mensError(self, _("The file %s already exist") % nombre)
                     continue
                 return nombre
             else:
                 return None
         else:
             return None
示例#49
0
    def configurar(self):
        # Datos
        liGen = [(None, None)]

        # # Motor
        mt = self.configuracion.tutorInicial if self.motor is None else self.motor

        liCombo = [mt]
        for nombre, clave in self.configuracion.comboMotoresMultiPV10():
            liCombo.append((clave, nombre))

        liGen.append(( _("Engine") + ":", liCombo ))

        # # Segundos a pensar el tutor
        config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1, 99, 50)
        liGen.append(( config, self.segundos ))

        ## Pruebas
        config = FormLayout.Spinbox(_("N. of tests"), 1, 40, 40)
        liGen.append(( config, self.pruebas ))

        ## Fichero
        config = FormLayout.Fichero(_("File"), "%s (*.fns);;%s PGN (*.pgn)" % (_("List of FENs"), _("File")), False,
                                    anchoMinimo=280)
        liGen.append(( config, self.fns ))

        # Editamos
        resultado = FormLayout.fedit(liGen, title=_("Configuration"), parent=self, icon=Iconos.Opciones())
        if resultado:
            accion, liResp = resultado
            self.motor = liResp[0]
            self.segundos = liResp[1]
            self.pruebas = liResp[2]
            self.fns = liResp[3]

            param = Util.DicSQL(self.configuracion.ficheroDailyTest, tabla="parametros")
            param["MOTOR"] = self.motor
            param["SEGUNDOS"] = self.segundos
            param["PRUEBAS"] = self.pruebas
            param["FNS"] = self.fns
            param.close()
示例#50
0
def paramPelicula(parent):
    # Datos
    liGen = [(None, None)]

    # # Segundos
    liGen.append(( _("Number of seconds between moves") + ":", 2 ))

    # # Si desde el principi
    liGen.append(( _("Start from first move") + ":", True ))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("Replay game"), parent=parent, anchoMinimo=460, icon=Iconos.Pelicula())

    if resultado:
        accion, liResp = resultado

        segundos = liResp[0]
        siPrincipio = liResp[1]
        return segundos, siPrincipio
    else:
        return None
示例#51
0
    def configuraciones(self):
        fichero = self.configuracion.ficheroEntMaquinaConf
        dbc = Util.DicSQL(fichero)
        liConf = dbc.keys(siOrdenados=True)
        menu = Controles.Menu(self)
        SELECCIONA, BORRA, AGREGA = range(3)
        for x in liConf:
            menu.opcion((SELECCIONA, x), x, Iconos.PuntoAzul())
        menu.separador()
        menu.opcion((AGREGA, None), _("Save current configuration"), Iconos.Mas())
        if liConf:
            menu.separador()
            submenu = menu.submenu(_("Remove"), Iconos.Delete())
            for x in liConf:
                submenu.opcion((BORRA, x), x, Iconos.PuntoRojo())
        resp = menu.lanza()

        if resp:
            op, k = resp

            if op == SELECCIONA:
                dic = dbc[k]
                self.muestraDic(dic)
            elif op == BORRA:
                if QTUtil2.pregunta(self, _X(_("Delete %1 ?"), k)):
                    del dbc[k]
            elif op == AGREGA:
                liGen = [(None, None)]

                liGen.append((_("Name") + ":", ""))

                resultado = FormLayout.fedit(liGen, title=_("Name"), parent=self, icon=Iconos.Libre())
                if resultado:
                    accion, liGen = resultado

                    nombre = liGen[0].strip()
                    if nombre:
                        dbc[nombre] = self.creaDic()

        dbc.close()
示例#52
0
    def configurar(self):
        # Datos
        liGen = [(None, None)]

        # # Motor
        mt = self.configuracion.tutorInicial if self.motor is None else self.motor

        liCombo = [mt]
        for nombre, clave in self.configuracion.comboMotoresMultiPV10():
            liCombo.append((clave, nombre))

        liGen.append(( _("Engine") + ":", liCombo ))

        # # Segundos a pensar el tutor
        config = FormLayout.Spinbox(_("Duration of engine analysis (secs)"), 1, 99, 50)
        liGen.append(( config, self.segundos ))

        ## Minutos
        config = FormLayout.Spinbox(_("Minimum minutes"), 0, 99, 50)
        liGen.append(( config, self.min_min ))

        config = FormLayout.Spinbox(_("Maximum minutes"), 0, 99, 50)
        liGen.append(( config, self.min_max ))

        # Editamos
        resultado = FormLayout.fedit(liGen, title=_("Configuration"), parent=self, icon=Iconos.Opciones())
        if resultado:
            accion, liResp = resultado
            self.motor = liResp[0]
            self.segundos = liResp[1]
            self.min_min = liResp[2]
            self.min_max = liResp[3]

            param = Util.DicSQL(self.configuracion.ficheroPotencia, tabla="parametros")
            param["MOTOR"] = self.motor
            param["SEGUNDOS"] = self.segundos
            param["MIN_MIN"] = self.min_min
            param["MIN_MAX"] = self.min_max
            param.close()
示例#53
0
def opcionesPrimeraVez(parent, configuracion):
    separador = (None, None)

    # Datos generales
    liGen = [separador]

    # # Nombre del jugador
    liGen.append(( _("Player's name") + ":", configuracion.jugador ))

    # Editamos
    resultado = FormLayout.fedit(liGen, title=_("Configuration"), parent=parent, anchoMinimo=560,
                                 icon=Iconos.Opciones())

    if resultado:
        accion, resp = resultado

        liGen = resp

        configuracion.jugador = liGen[0]

        return True
    else:
        return False
示例#54
0
def cambiaColoresPGN(ventana, configuracion):
    liGen = [(None, None)]

    dicNAGs = TrListas.dicNAGs()
    config = FormLayout.Colorbox(dicNAGs[1], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag1 ))

    config = FormLayout.Colorbox(dicNAGs[2], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag2 ))

    config = FormLayout.Colorbox(dicNAGs[3], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag3 ))

    config = FormLayout.Colorbox(dicNAGs[4], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag4 ))

    config = FormLayout.Colorbox(dicNAGs[5], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag5 ))

    config = FormLayout.Colorbox(dicNAGs[6], 80, 20, siSTR=True)
    liGen.append(( config, configuracion.color_nag6 ))

    resultado = FormLayout.fedit(liGen, title=_("PGN"), parent=ventana, icon=Iconos.Vista(), siDefecto=True)
    if resultado:
        accion, liResp = resultado
        if accion == "defecto":
            configuracion.coloresPGNdefecto()
            configuracion.graba()
            cambiaColoresPGN(ventana, configuracion)
        else:
            configuracion.color_nag1 = liResp[0]
            configuracion.color_nag2 = liResp[1]
            configuracion.color_nag3 = liResp[2]
            configuracion.color_nag4 = liResp[3]
            configuracion.color_nag5 = liResp[4]
            configuracion.color_nag6 = liResp[5]
            configuracion.graba()
示例#55
0
    def reindexar(self):
        if not QTUtil2.pregunta(self, _("Do you want to rebuild stats?")):
            return

        # Select depth
        liGen = [(None, None)]
        liGen.append(( None, _("Select the number of moves <br> for each game to be considered") ))
        liGen.append((None, None))

        li = [(str(n), n) for n in range(3, 255)]
        config = FormLayout.Combobox(_("Depth"), li)
        liGen.append(( config, self.dbGames.depthStat() ))

        resultado = FormLayout.fedit(liGen, title=_("Rebuild"), parent=self, icon=Iconos.Reindexar())
        if resultado is None:
            return None

        accion, liResp = resultado

        depth = liResp[0]

        self.RECCOUNT = 0

        bpTmp = QTUtil2.BarraProgreso1(self, _("Rebuilding"))
        bpTmp.mostrar()

        def dispatch(recno, reccount):
            if reccount != self.RECCOUNT:
                self.RECCOUNT = reccount
                bpTmp.ponTotal(reccount)
            bpTmp.pon(recno)
            return not bpTmp.siCancelado()

        self.dbGames.recrearSTAT(dispatch, depth)
        bpTmp.cerrar()
        self.grid.refresh()
示例#56
0
    def create(self):
        name = os.path.basename(self.dbGames.nomFichero)[:-4]
        maxdepth = self.dbGames.depthStat()
        depth = maxdepth
        minGames = min(self.dbGames.reccountTotal() * 10 / 100, 5)
        pointview = 2
        inicio = 0
        mov = self.movActivo()

        while True:
            liGen = [(None, None)]
            liGen.append(( _("Name") + ":", name ))

            liGen.append((FormLayout.Spinbox(_("Depth"), 2, maxdepth, 50), depth))

            liGen.append((None, None))

            liGen.append((FormLayout.Spinbox(_("Minimum games"), 1, 99, 50), minGames))

            liGen.append((None, None))

            liPointV = [pointview,
                        ( 0, _("White") ),
                        ( 1, _("Black") ),
                        ( 2, "%s + %s" % (_("White"), _("Draw") ) ),
                        ( 3, "%s + %s" % (_("Black"), _("Draw") ) ),
            ]
            liGen.append((_("Point of view") + ":", liPointV))

            liGen.append((None, None))

            if mov:
                liInicio = [inicio,
                            ( 0, _("The beginning") ),
                            ( 1, _("Current move") ),
                ]
                liGen.append((_("Start from") + ":", liInicio))

            resultado = FormLayout.fedit(liGen, title=_("Create new guide"), parent=self, anchoMinimo=460,
                                         icon=Iconos.TutorialesCrear())
            if resultado is None:
                return

            accion, liResp = resultado
            name = liResp[0].strip()
            if not name:
                return
            depth = liResp[1]
            minGames = liResp[2]
            pointview = liResp[3]
            if mov:
                inicio = liResp[4]

            ok = True
            for una in self.bookGuide.getTodas():
                if una.strip().upper() == name.upper():
                    QTUtil2.mensError(self, _("The name is repeated"))
                    ok = False
                    continue
            if ok:
                break

        # Grabamos
        um = QTUtil2.unMomento(self)

        # Read stats
        siWhite = pointview % 2 == 0
        siDraw = pointview > 1
        pv = ""
        if mov:
            if inicio > 0:
                pv = self.pvBase + " " + mov["pvmove"]
                pv = pv.strip()

        fichPVs = self.dbGames.flistAllpvs(depth, minGames, siWhite, siDraw, pv)

        # Write to bookGuide
        self.bookGuide.grabarFichSTAT(name, fichPVs)

        # BookGuide
        self.wmoves.inicializa()

        um.final()