Exemplo n.º 1
0
    def __init__(self, owner, conj_piezas, siBlancas, posicion):
        QtGui.QWidget.__init__(self)

        self.owner = owner
        self.wm = WEdMove(self, conj_piezas, siBlancas)
        self.ms = Controles.LB(self, "")
        self.an = Controles.PB(self, "?", self.analizarUno, plano=False).anchoFijo(18)
        self.cancelar = Controles.LB(self, "").ponImagen(Iconos.pmCancelarPeque())
        self.aceptar = Controles.LB(self, "").ponImagen(Iconos.pmAceptarPeque())
        ly = (
            Colocacion.H()
            .control(self.aceptar)
            .control(self.cancelar)
            .control(self.wm)
            .control(self.an)
            .control(self.ms)
            .relleno()
            .margen(0)
        )
        self.setLayout(ly)

        self.ms.hide()
        self.an.hide()
        self.aceptar.hide()
        self.cancelar.hide()

        self.posicion = posicion
Exemplo n.º 2
0
    def getAlbum(self, alias):
        claveDB = self.preClave + "_" + alias
        dic = self.getDB(claveDB)
        if dic:
            dig = {}
            for cromo in self.liGeneralCromos:
                dig[cromo.clave] = cromo
            album = Album(claveDB, _F(alias), Iconos.icono(alias))
            li = []
            pos = 0
            for k, v in dic.iteritems():
                cromo = dig[k]
                cromo.hecho = v
                cromo.pos = pos
                cromo.siBlancas = pos % 2 == 0
                pos += 1
                li.append(cromo)
            album.liCromos = li
        else:
            album = self.creaAlbum(alias)

        li = self.dicAlbumes.keys()
        for n, k in enumerate(li):
            if k == alias:
                album.siguiente = li[n + 1] if n < len(li) - 1 else None
                if album.siguiente:
                    dicDB = self.getDB(ALBUMSHECHOS)
                    if dicDB and dicDB.get(self.preClave + "_" + alias):
                        album.siguiente = None  # Para que no avise de que esta hecho
                break
        return album
Exemplo n.º 3
0
    def __init__(self, owner, conj_piezas, siBlancas):
        QtGui.QWidget.__init__(self)

        self.owner = owner

        self.conj_piezas = conj_piezas

        self.filaPromocion = (7, 8) if siBlancas else (2, 1)

        self.menuPromocion = self.creaMenuPiezas("QRBN ", siBlancas)

        self.promocion = " "

        self.origen = EDCelda(self, "").caracteres(2).controlrx("(|[a-h][1-8])").anchoFijo(32).alinCentrado().capturaCambiado(self.miraPromocion)

        self.flecha = flecha = Controles.LB(self).ponImagen(Iconos.pmMover())

        self.destino = EDCelda(self, "").caracteres(2).controlrx("(|[a-h][1-8])").anchoFijo(32).alinCentrado().capturaCambiado(self.miraPromocion)

        self.pbPromocion = Controles.PB(self, "", self.pulsadoPromocion, plano=False).anchoFijo(32)

        ly = Colocacion.H().relleno().control(self.origen).espacio(2).control(flecha).espacio(2).control(
            self.destino).control(self.pbPromocion).margen(0).relleno()
        self.setLayout(ly)

        self.miraPromocion()
Exemplo n.º 4
0
    def muestraMensaje(self):
        tm = time.time() - self.iniTime

        mensaje = "%s: %0.02f"%(_("Time"), tm)
        if tm < 10.0:
            pmImagen = Iconos.pmSol()
        elif tm < 20.0:
            pmImagen = Iconos.pmSolNubes()
        elif tm < 30.0:
            pmImagen = Iconos.pmNubes()
        else:
            pmImagen = Iconos.pmTormenta()

        background = "#5DB0DB"

        segundos = 2.6
        QTUtil2.mensajeTemporal(self.pantalla, mensaje, segundos, background=background, pmImagen=pmImagen)
Exemplo n.º 5
0
    def __init__(self, clave, gestor):

        self.procesador = gestor.procesador
        self.xtutor = gestor.xtutor
        self.clave = clave
        self.autor = ""
        self.version = ""
        self.siUCI = False
        self.siTutor = False
        self.siDebug = False
        self.exe = ""
        self.motorProfundidad = None
        self.motorTiempoJugada = None

        self.ml = MotorInterno.MotorInterno()
        dic = {kMP_1: ( self.ml.mp1, _("Monkey"), 7, Iconos.pmMonkey() ),
               kMP_2: ( self.ml.mp2, _("Donkey"), 6, Iconos.pmDonkey() ),
               kMP_3: ( self.ml.mp3, _("Bull"), 5, Iconos.pmBull() ),
               kMP_4: ( self.ml.mp4, _("Wolf"), 4, Iconos.pmWolf() ),
               kMP_5: ( self.ml.mp5, _("Lion"), 3, Iconos.pmLion() ),
               kMP_6: ( self.ml.mp6, _("Rat"), 2, Iconos.pmRat() ),
               kMP_7: ( self.ml.mp7, _("Snake"), 0, Iconos.pmSnake() ),
        }

        self.funcion, txt, self.jugadasTutor, self.imagen = dic[clave]
        self.nombre = txt
        self.numJugada = 0

        self.siListo = clave == kMP_7
        if self.siListo:
            self.siJuegaTutor = False
            self.rmComparar = XMotorRespuesta.RespuestaMotor("listo", True)
            self.rmComparar.mate = 0
            self.rmComparar.puntos = -80
Exemplo n.º 6
0
    def creaAlbum(self, alias):
        album = Album(self.preClave + "_" + alias, _F(alias), Iconos.icono(alias))

        for nivel, cuantos in enumerate(self.dicAlbumes[alias]):
            if cuantos:
                li = []
                for cromo in self.liGeneralCromos:
                    if cromo.nivel == nivel:
                        li.append(cromo)
                for pos, cromo in enumerate(random.sample(li, cuantos)):
                    cromo.pos = pos
                    cromo.siBlancas = pos % 2 == 0
                    cromo.hecho = False
                    album.nuevoCromo(cromo)
        album.guarda()
        return album
Exemplo n.º 7
0
    def __init__(self, owner, liElem, ancho, margen=None):
        QtGui.QWidget.__init__(self)

        self.owner = owner
        self.ancho = ancho

        layout = Colocacion.G()
        self.liLB = []
        pm = Iconos.pmEnBlanco()
        if ancho != 32:
            pm = pm.scaled(ancho, ancho)
        self.pmVacio = pm
        for fila, numElem in enumerate(liElem):
            for n in range(numElem):
                lb = DragUna(self, self.pmVacio)
                self.liLB.append(lb)
                layout.control(lb, fila, n)
        if margen:
            layout.margen(margen)
        self.dicDatos = collections.OrderedDict()
        self.setLayout(layout)
Exemplo n.º 8
0
    def __init__(self, procesador):
        super(WAbout, self).__init__(procesador.pantalla)

        self.setWindowTitle(_("About"))
        self.setWindowIcon(Iconos.Aplicacion())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)
        self.setMaximumWidth(QTUtil.anchoEscritorio())

        f = Controles.TipoLetra(puntos=10)  # 0, peso=75 )

        cabecera = '<span style="font-size:30pt; font-weight="700"; font-family:arial; color:#2D2B2B">%s</span><br>' % _(
            "Lucas Chess")
        cabecera += '<span style="font-size:15pt;">%s</span><br>' % _X(_("version %1"), procesador.version)
        cabecera += '<span style="font-size:8pt;color:2D2B2B">%s</span>' % "Lucas Monge"
        cabecera += ' - <a style="font-size:8pt; color:2D2B2B" href="%s">%s</a>' % (procesador.web, procesador.web)
        cabecera += ' - <a style="font-size:8pt; color:2D2B2B" href="%s">Blog : Fresh news</a><br>' % (procesador.blog, )
        cabecera += '%s <a style="font-size:8pt; color:2D2B2B" href="http://www.gnu.org/copyleft/gpl.html"> GPL</a>' % _(
            "License")

        lbIco = Controles.LB(self).ponImagen(Iconos.pmAplicacion64())
        lbTitulo = Controles.LB(self, cabecera)
        btSeguir = Controles.PB(self, _("Continue"), self.accept).ponPlano(False)

        # Tabs
        tab = Controles.Tab()
        tab.ponFuente(f)

        ib = InfoBase.ThanksTo()

        for n, (k, titulo) in enumerate(ib.dic.iteritems()):
            txt = ib.texto(k)
            lb = Controles.LB(self, txt)
            lb.ponFondoN("Ivory")
            lb.ponFuente(f)
            tab.addTab(lb, titulo)

        lyV1 = Colocacion.H().control(lbIco).espacio(15).control(lbTitulo).relleno()
        layout = Colocacion.V().otro(lyV1).espacio(10).control(tab).control(btSeguir).margen(10)

        self.setLayout(layout)
Exemplo n.º 9
0
    def __init__(self, parent, mens, titulo=None, siResalta=True):
        super(Mensaje, self).__init__(parent)

        if titulo is None:
            titulo = _("Message")
        if siResalta:
            mens = resalta(mens)

        self.setWindowTitle(titulo)
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)
        # ~ self.setStyleSheet("QDialog, QLabel { background: #79b600 }")

        lbi = QtGui.QLabel(self)
        lbi.setPixmap(Iconos.pmInformacion())

        lbm = Controles.LB(self, mens)
        bt = Controles.PB(self, _("Continue"), rutina=self.accept, plano=False)

        ly = Colocacion.G().control(lbi, 0, 0).control(lbm, 0, 1).controld(bt, 1, 1)

        ly.margen(10)
        self.setLayout(ly)
Exemplo n.º 10
0
    def __init__(self, parent, mensaje, siCancelar, siMuestraYa, opacity, posicion, fixedSize, titCancelar, background, pmImagen=None):

        assert parent is not None

        super(MensEspera, self).__init__(parent)

        self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
        self.setStyleSheet("QWidget, QLabel { background: %s }" % background)
        lbi = QtGui.QLabel(self)
        lbi.setPixmap(pmImagen if pmImagen else Iconos.pmMensEspera())
        if fixedSize:
            self.setFixedWidth(fixedSize)

        self.owner = parent

        self.posicion = posicion

        self.lb = lb = Controles.LB(parent, resalta(mensaje)).ponFuente(Controles.TipoLetra(puntos=12)).ponWrap()

        if siCancelar:
            self.siCancelado = False
            if not titCancelar:
                titCancelar = _("Cancel")
            self.btCancelar = Controles.PB(self, titCancelar, rutina=self.cancelar, plano=False).ponIcono(
                Iconos.Cancelar()).anchoFijo(100)

        ly = Colocacion.G().control(lbi, 0, 0, 3, 1).control(lb, 1, 1)
        if siCancelar:
            ly.controlc(self.btCancelar, 2, 1)

        ly.margen(12)
        self.setLayout(ly)
        self.teclaPulsada = None

        self.setWindowOpacity(opacity)
        if siMuestraYa:
            self.muestra()
Exemplo n.º 11
0
    def mueveHumano(self, desde, hasta, coronacion=None):
        if self.siJuegaHumano:
            self.paraHumano()
        else:
            self.sigueHumano()
            return False

        movimiento = desde + hasta

        # Peon coronando
        if not coronacion and self.partida.ultPosicion.siPeonCoronando(
                desde, hasta):
            coronacion = self.tablero.peonCoronando(
                self.partida.ultPosicion.siBlancas)
            if coronacion is None:
                self.sigueHumano()
                return False
        if coronacion:
            movimiento += coronacion

        siBien, mens, jg = Jugada.dameJugada(self.partida.ultPosicion, desde,
                                             hasta, coronacion)

        siAnalisis = False

        if self.siTeclaPanico:
            self.sigueHumano()
            return False

        if siBien:
            siElegido = False

            if self.book and self.bookMandatory:
                fen = self.fenUltimo()
                listaJugadas = self.book.miraListaJugadas(fen)
                if listaJugadas:
                    li = []
                    for apdesde, aphasta, apcoronacion, nada, nada1 in listaJugadas:
                        mx = apdesde + aphasta + apcoronacion
                        if mx.strip().lower() == movimiento:
                            siElegido = True
                            break
                        li.append((apdesde, aphasta, False))
                    if not siElegido:
                        self.tablero.ponFlechasTmp(li)
                        self.sigueHumano()
                        return False

            if not siElegido and self.siApertura:
                fenBase = self.fenUltimo()
                if self.siAperturaStd:
                    if self.apertura.compruebaHumano(fenBase, desde, hasta):
                        siElegido = True
                    else:
                        if self.apertura.activa:
                            apdesde, aphasta = self.apertura.desdeHastaActual(
                                fenBase)

                            self.tablero.ponFlechasTmp(
                                ((apdesde, aphasta, False), ))
                            self.sigueHumano()
                            return False
                if not siElegido and self.apertura and self.apertura.compruebaHumano(
                        fenBase, desde, hasta):
                    siElegido = True

            if self.siTeclaPanico:
                self.sigueHumano()
                return False

            if not siElegido and self.siTutorActivado:
                self.analizaTutorFinal()
                rmUser, n = self.mrmTutor.buscaRM(movimiento)
                if not rmUser:
                    rmUser = self.xtutor.valora(self.partida.ultPosicion,
                                                desde, hasta, coronacion)
                    if not rmUser:
                        return False
                    self.mrmTutor.agregaRM(rmUser)
                siAnalisis = True
                pointsBest, pointsUser = self.mrmTutor.difPointsBest(
                    movimiento)
                self.setSummary("POINTSBEST", pointsBest)
                self.setSummary("POINTSUSER", pointsUser)
                if (pointsBest - pointsUser) > 0:
                    if not jg.siJaqueMate:
                        siTutor = True
                        if self.chance:
                            num = self.mrmTutor.numMejorMovQue(movimiento)
                            if num:
                                rmTutor = self.mrmTutor.rmBest()
                                rmUser, n = self.mrmTutor.buscaRM(movimiento)
                                menu = QTVarios.LCMenu(self.pantalla)
                                submenu = menu.submenu(
                                    _("There are %d best moves") % num,
                                    Iconos.Motor())
                                submenu.opcion(
                                    "tutor", "%s (%s)" %
                                    (_("Show tutor"), rmTutor.abrTextoBase()),
                                    Iconos.Tutor())
                                submenu.separador()
                                submenu.opcion("try", _("Try again"),
                                               Iconos.Atras())
                                submenu.separador()
                                submenu.opcion(
                                    "user",
                                    "%s (%s)" % (_("Select my move"),
                                                 rmUser.abrTextoBase()),
                                    Iconos.Player())
                                self.pantalla.cursorFueraTablero()
                                resp = menu.lanza()
                                if resp == "try":
                                    self.sigueHumano()
                                    return False
                                elif resp == "user":
                                    siTutor = False
                        if siTutor:
                            tutor = Tutor.Tutor(self, self, jg, desde, hasta,
                                                False)

                            if self.siApertura:
                                liApPosibles = self.listaAperturasStd.listaAperturasPosibles(
                                    self.partida)
                            else:
                                liApPosibles = None

                            if tutor.elegir(self.ayudas > 0,
                                            liApPosibles=liApPosibles):
                                if self.ayudas > 0:  # doble entrada a tutor.
                                    self.reponPieza(desde)
                                    self.ayudas -= 1
                                    desde = tutor.desde
                                    hasta = tutor.hasta
                                    coronacion = tutor.coronacion
                                    siBien, mens, jgTutor = Jugada.dameJugada(
                                        self.partida.ultPosicion, desde, hasta,
                                        coronacion)
                                    if siBien:
                                        jg = jgTutor
                                        self.setSummary("SELECTTUTOR", True)
                            if self.configuracion.guardarVariantesTutor:
                                tutor.ponVariantes(
                                    jg, 1 + self.partida.numJugadas() / 2)

                            del tutor

            if self.siTeclaPanico:
                self.sigueHumano()
                return False

            self.setSummary("TIMEUSER", self.timekeeper.stop())
            self.relojStop(True)

            if self.siApertura and self.siAperturaStd:
                self.siApertura = self.apertura.activa

            self.movimientosPiezas(jg.liMovs)

            if siAnalisis:
                rm, nPos = self.mrmTutor.buscaRM(jg.movimiento())
                if rm:
                    jg.analisis = self.mrmTutor, nPos

            self.partida.ultPosicion = jg.posicion
            self.masJugada(jg, True)
            self.error = ""
            self.siguienteJugada()
            return True
        else:
            self.error = mens
            self.sigueHumano()
            return False
Exemplo n.º 12
0
    def menu(self):
        main_window = self.procesador.main_window
        main_window.cursorFueraTablero()
        menu = QTVarios.LCMenu(main_window)
        f = Controles.TipoLetra(name="Courier", puntos=12)
        fbold = Controles.TipoLetra(name="Courier", puntos=12, peso=700)
        fbolds = Controles.TipoLetra(name="Courier",
                                     puntos=12,
                                     peso=500,
                                     siSubrayado=True)
        menu.ponFuente(f)

        li_results = self.lee_results()
        icono = Iconos.PuntoAzul()

        menu.separador()
        titulo = ("** %s **" % _("Challenge 101")).center(30)
        if self.pendientes == 0:
            menu.opcion("close", titulo, Iconos.Terminar())
        else:
            menu.opcion("continuar", titulo, Iconos.Pelicula_Seguir())
        menu.separador()
        ok_en_lista = False
        for n, (fecha, pts) in enumerate(li_results, 1):
            if fecha == self.key:
                ok_en_lista = True
                ico = Iconos.PuntoEstrella()
                tipoLetra = fbolds
            else:
                ico = icono
                tipoLetra = None
            txt = str(fecha)[:16]
            menu.opcion(None,
                        "%2d. %-20s %6d" % (n, txt, pts),
                        ico,
                        tipoLetra=tipoLetra)

        menu.separador()
        menu.opcion(None, "", Iconos.PuntoNegro())
        menu.separador()
        if self.puntos_ultimo:
            menu.opcion(None, ("+%d" % (self.puntos_ultimo)).center(30),
                        Iconos.PuntoNegro(),
                        tipoLetra=fbold)
        if self.pendientes == 0:
            if not ok_en_lista:
                menu.opcion(None,
                            ("%s: %d" %
                             (_("Score"), self.puntos_totales)).center(30),
                            Iconos.Gris(),
                            tipoLetra=fbold)
            menu.separador()
            menu.opcion("close", _("GAME OVER").center(30), Iconos.Terminar())
        else:
            menu.opcion(None, ("%s: %d" %
                               (_("Score"), self.puntos_totales)).center(30),
                        Iconos.PuntoNegro(),
                        tipoLetra=fbold)
            menu.separador()
            menu.opcion(
                None,
                ("%s: %d" % (_("Positions left"), self.pendientes)).center(30),
                Iconos.PuntoNegro(),
                tipoLetra=fbold,
            )
            menu.separador()
            menu.opcion(None, "", Iconos.PuntoNegro())
            menu.separador()
            menu.opcion("continuar", _("Continue"), Iconos.Pelicula_Seguir())
            menu.separador()
            menu.opcion("close", _("Close"), Iconos.MainMenu())

        resp = menu.lanza()

        return not (resp == "close" or self.pendientes == 0)
Exemplo n.º 13
0
    def procesarAccion(self, clave):
        if clave == k_cancelar:
            self.finalizar()

        elif clave == k_rendirse:
            self.rendirse()

        elif clave == k_tablas:
            self.tablasPlayer()

        elif clave == k_atras:
            self.atras()

        elif clave == k_ayudaMover:
            self.analizaTutorFinal()
            self.ayudaMover(999)

        elif clave == k_reiniciar:
            self.reiniciar(True)

        elif clave == k_configurar:
            liMasOpciones = []
            if self.estado == kJugando and not self.siRivalInterno:
                liMasOpciones.append((None, None, None))
                liMasOpciones.append(
                    ("rival", _("Change opponent"), Iconos.Motor()))
            resp = self.configurar(liMasOpciones,
                                   siSonidos=True,
                                   siCambioTutor=self.ayudasPGN > 0)
            if resp == "rival":
                self.cambioRival()

        elif clave == k_utilidades:
            liMasOpciones = []
            if self.siJuegaHumano or self.siTerminada():
                liMasOpciones.append(
                    ("libros", _("Consult a book"), Iconos.Libros()))
                liMasOpciones.append((None, None, None))
                liMasOpciones.append(("bookguide", _("Personal Opening Guide"),
                                      Iconos.BookGuide()))
                liMasOpciones.append((None, None, None))
                liMasOpciones.append(
                    ("play", _('Play current position'), Iconos.MoverJugar()))

            resp = self.utilidades(liMasOpciones)
            if resp == "libros":
                siEnVivo = self.siJuegaHumano and not self.siTerminada()
                liMovs = self.librosConsulta(siEnVivo)
                if liMovs and siEnVivo:
                    desde, hasta, coronacion = liMovs[-1]
                    self.mueveHumano(desde, hasta, coronacion)
            elif resp == "bookguide":
                self.bookGuide()
            elif resp == "play":
                self.jugarPosicionActual()

        elif clave == k_aplazar:
            self.aplazar()

        else:
            self.rutinaAccionDef(clave)
Exemplo n.º 14
0
def dameCategoria(wParent, configuracion, procesador):
    rival = configuracion.rival

    menu = QTVarios.LCMenu(wParent)

    menu.opcion(None, "%s: %d %s" % (_("Total score"), configuracion.puntuacion(), _("pts")), Iconos.NuevaPartida())
    menu.separador()
    menu.opcion(None, "%s: %s" % (_("Opponent"), rival.rotuloPuntos()), Iconos.Motor(), siDeshabilitado=False)
    menu.separador()

    # ---------- CATEGORIAS
    ant = 1
    for x in range(6):
        cat = rival.categorias.numero(x)
        txt = cat.nombre()
        nm = cat.nivelHecho

        nh = cat.hecho

        if nm > 0:
            txt += " %s %d" % (_("Level"), nm)
        if nh:
            if "B" in nh:
                txt += " +%s:%d" % ( _("White"), nm + 1)
            if "N" in nh:
                txt += " +%s:%d" % ( _("Black"), nm + 1)

                # if "B" not in nh:
                # txt += "  ...  %s:%d"%( _( "White" )[0],nm+1)
                # elif "N" not in nh:
                # txt += "  ...  %s:%d"%( _( "Black" )[0],nm+1)
                # else:
                # txt += "  ...  %s:%d"%( _( "White" )[0],nm+1)

        siDesHabilitado = (ant == 0)
        ant = nm
        menu.opcion(str(x), txt, cat.icono(), siDeshabilitado=siDesHabilitado)

    # ----------- RIVAL
    menu.separador()
    menuRival = menu.submenu(_("Change opponent"))

    puntuacion = configuracion.puntuacion()

    icoNo = Iconos.Motor_No()
    icoSi = Iconos.Motor_Si()
    icoActual = Iconos.Motor_Actual()
    grpNo = Iconos.Grupo_No()
    grpSi = Iconos.Grupo_Si()

    for grupo in configuracion.grupos.liGrupos:
        nombre = _X(_("%1 group"), grupo.nombre)
        if grupo.minPuntos > 0:
            nombre += " (+%d %s)" % (grupo.minPuntos, _("pts") )

        siDes = (grupo.minPuntos > puntuacion)
        if siDes:
            icoG = grpNo
            icoM = icoNo
        else:
            icoG = grpSi
            icoM = icoSi
        submenu = menuRival.submenu(nombre, icoG)

        for rv in grupo.liRivales:
            siActual = rv.clave == rival.clave
            ico = icoActual if siActual else icoM
            submenu.opcion("MT_" + rv.clave, rv.rotuloPuntos(), ico, siDes or siActual)
        menuRival.separador()

    # ----------- RIVAL
    menu.separador()
    menu.opcion("ayuda", _("Help"), Iconos.Ayuda())

    cursor = QtGui.QCursor.pos()
    resp = menu.lanza()
    if resp is None:
        return None
    elif resp == "ayuda":
        titulo = _("Competition")
        ancho, alto = QTUtil.tamEscritorio()
        ancho = min(ancho, 700)
        txt = _("<br><b>The aim is to obtain the highest possible score</b> :<ul><li>The current point score is displayed in the title bar.</li><li>To obtain points it is necessary to win on different levels in different categories.</li><li>To overcome a level it is necessary to win against the engine with white and with black.</li><li>The categories are ranked in the order of the following table:</li><ul><li><b>Beginner</b> : 5</li><li><b>Amateur</b> : 10</li><li><b>Master candidate</b> : 20</li><li><b>Master</b> : 40</li><li><b>Grandmaster candidate</b> : 80</li><li><b>Grandmaster</b> : 160</li></ul><li>The score for each game is calculated by multiplying the playing level with the score of the category.</li><li>The engines are divided into groups.</li><li>To be able to play with an opponent of a particular group a minimum point score is required. The required score is shown next to the group label.</li></ul>")
        Info.info(wParent, _("Lucas Chess"), titulo, txt, ancho, Iconos.pmAyudaGR())
        return None

    elif resp.startswith("MT_"):
        procesador.cambiaRival(resp[3:])
        QtGui.QCursor.setPos(cursor)
        procesador.competicion()
        return None
    else:
        categoria = rival.categorias.numero(int(resp))
        return categoria
Exemplo n.º 15
0
    def configurarGS(self):
        mt = _("Engine").lower()
        mt = _X(_("Disable %1"), mt) if self.play_against_engine else _X(
            _("Enable %1"), mt)

        sep = (None, None, None)

        liMasOpciones = [
            ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()),
            sep,
            ("opening", _("Opening"), Iconos.Opening()),
            sep,
            ("position", _("Edit start position"), Iconos.Datos()),
            sep,
            ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()),
            sep,
            ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()),
            sep,
            ("pastepgn", _("Paste PGN"), Iconos.Pegar16()),
            sep,
            ("engine", mt, Iconos.Motores()),
            sep,
            ("voyager", _("Voyager 2"), Iconos.Voyager()),
        ]
        resp = self.configurar(liMasOpciones,
                               siCambioTutor=True,
                               siSonidos=True)

        if resp == "rotacion":
            self.auto_rotate = not self.auto_rotate
            is_white = self.game.last_position.is_white
            if self.auto_rotate:
                if is_white != self.board.is_white_bottom:
                    self.board.rotaBoard()
        elif resp == "opening":
            me = self.unMomento()
            w = WindowOpenings.WOpenings(self.main_window, self.configuration,
                                         self.opening_block)
            me.final()
            if w.exec_():
                self.opening_block = w.resultado()
                self.xfichero = None
                self.xpgn = None
                self.xjugadaInicial = None
                self.reiniciar()

        elif resp == "position":
            self.startPosition()

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = Position.Position()
                try:
                    cp.read_fen(str(texto))
                    self.xfichero = None
                    self.xpgn = None
                    self.xjugadaInicial = None
                    self.new_game()
                    self.game.set_position(first_position=cp)
                    self.opening_block = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            self.leerpgn()

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                ok, game = Game.pgn_game(texto)
                if not ok:
                    QTUtil2.message_error(
                        self.main_window,
                        _("The text from the clipboard does not contain a chess game in PGN format"
                          ))
                    return
                self.xfichero = None
                self.xpgn = None
                self.xjugadaInicial = None
                self.opening_block = None
                dic = self.creaDic()
                dic["GAME"] = game.save()
                dic["WHITEBOTTOM"] = game.first_position.is_white
                self.reiniciar(dic)

        elif resp == "engine":
            self.set_label1("")
            if self.play_against_engine:
                if self.xrival:
                    self.xrival.terminar()
                    self.xrival = None
                self.play_against_engine = False
            else:
                self.cambioRival()

        elif resp == "voyager":
            ptxt = Voyager.voyagerPartida(self.main_window, self.game)
            if ptxt:
                self.xfichero = None
                self.xpgn = None
                self.xjugadaInicial = None
                dic = self.creaDic()
                dic["GAME"] = ptxt.save()
                dic["WHITEBOTTOM"] = self.board.is_white_bottom
                self.reiniciar(dic)
Exemplo n.º 16
0
    def __init__(self, owner, dicdatos):

        self.dicdatos = dicdatos

        site = dicdatos["SITE"]
        self.level = dicdatos["LEVEL"]
        self.intervalo = dicdatos["INTERVAL"]
        self.intervaloPorPieza = dicdatos["INTERVALPIECE"]
        self.esatacada = dicdatos["ISATTACKED"]
        self.esatacante = dicdatos["ISATTACKING"]
        self.posicion = dicdatos["POSITION"]
        self.color = dicdatos["COLOR"]
        self.errors = dicdatos["ERRORS"]
        self.time = dicdatos["TIME"]
        self.liFENs = dicdatos["FENS"]

        mas = "x" if self.intervaloPorPieza else ""
        titulo = "%s (%s%d\")" % (site, mas, self.intervalo)

        super(WPlay, self).__init__(owner, titulo, Iconos.Gafas(), "visualplay")

        self.procesador = owner.procesador
        self.configuracion = self.procesador.configuracion

        # Tiempo en tablero
        intervaloMax = self.intervalo
        if self.intervaloPorPieza:
            intervaloMax *= 32

        # Tablero
        confTablero = self.configuracion.confTablero("VISUALPLAY", 48)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()

        lyT = Colocacion.V().control(self.tablero)

        self.gbTablero = Controles.GB(self, "", lyT)

        # entradas
        ly = Colocacion.G()

        self.posPosicion = None
        self.posColor = None
        self.posIsAttacked = None
        self.posIsAttacking = None

        lista = [_("Piece")]
        if self.posicion:
            lista.append(_("Position"))
        if self.color:
            lista.append(_("Square color"))
        if self.esatacada:
            lista.append(_("Is attacked?"))
        if self.esatacante:
            lista.append(_("Is attacking?"))
        self.liLB2 = []
        for col, eti in enumerate(lista):
            ly.control(Controles.LB(self, eti), 0, col + 1)
            lb2 = Controles.LB(self, eti)
            ly.control(lb2, 0, col + len(lista) + 2)
            self.liLB2.append(lb2)
        elementos = len(lista) + 1

        liComboPieces = []
        for c in "PNBRQKpnbrqk":
            liComboPieces.append(("", c, self.tablero.piezas.icono(c)))

        self.pmBien = Iconos.pmAceptarPeque()
        self.pmMal = Iconos.pmCancelarPeque()
        self.pmNada = Iconos.pmPuntoAmarillo()

        self.liBloques = []
        for x in range(32):
            fila = x % 16 + 1
            colPos = elementos if x > 15 else 0

            unBloque = []
            self.liBloques.append(unBloque)

            # # Solucion
            lb = Controles.LB(self, "").ponImagen(self.pmNada)
            ly.control(lb, fila, colPos)
            unBloque.append(lb)

            # # Piezas
            colPos += 1
            cb = Controles.CB(self, liComboPieces, "P")
            # cb.setStyleSheet("* { min-height:32px }")
            cb.setIconSize(QtCore.QSize(20, 20))

            ly.control(cb, fila, colPos)
            unBloque.append(cb)

            if self.posicion:
                ec = Controles.ED(self, "").caracteres(2).controlrx("(|[a-h][1-8])").anchoFijo(24).alinCentrado()
                colPos += 1
                ly.controlc(ec, fila, colPos)
                unBloque.append(ec)

            if self.color:
                cl = QTVarios.TwoImages(Iconos.pmBlancas(), Iconos.pmNegras())
                colPos += 1
                ly.controlc(cl, fila, colPos)
                unBloque.append(cl)

            if self.esatacada:
                isat = QTVarios.TwoImages(Iconos.pmAtacada().scaledToWidth(24), Iconos.pmPuntoNegro())
                colPos += 1
                ly.controlc(isat, fila, colPos)
                unBloque.append(isat)

            if self.esatacante:
                at = QTVarios.TwoImages(Iconos.pmAtacante().scaledToWidth(24), Iconos.pmPuntoNegro())
                colPos += 1
                ly.controlc(at, fila, colPos)
                unBloque.append(at)

        ly1 = Colocacion.H().otro(ly).relleno()
        ly2 = Colocacion.V().otro(ly1).relleno()
        self.gbSolucion = Controles.GB(self, "", ly2)

        f = Controles.TipoLetra("", 11, 80, False, False, False, None)

        bt = Controles.PB(self, _("End game"), self.terminar, plano=False).ponIcono(Iconos.FinPartida()).ponFuente(f)
        self.btTablero = Controles.PB(self, _("Go to board"), self.activaTablero, plano=False).ponIcono(
            Iconos.Tablero()).ponFuente(f)
        self.btComprueba = Controles.PB(self, _("Test the solution"), self.compruebaSolucion, plano=False).ponIcono(
            Iconos.Check()).ponFuente(f)
        self.btGotoNextLevel = Controles.PB(self, _("Go to next level"), self.gotoNextLevel, plano=False).ponIcono(
            Iconos.GoToNext()).ponFuente(f)
        ly0 = Colocacion.H().control(bt).relleno().control(self.btTablero).control(self.btComprueba).control(
            self.btGotoNextLevel)

        lyBase = Colocacion.H().control(self.gbTablero).control(self.gbSolucion)

        layout = Colocacion.V().otro(ly0).otro(lyBase)

        self.setLayout(layout)

        self.recuperarVideo()

        self.gotoNextLevel()
Exemplo n.º 17
0
    def __init__(self, wParent, torneo):

        titulo = _("Competition")
        icono = Iconos.Torneos()
        extparam = "untorneo"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        self.configuracion = VarGen.configuracion

        # Datos
        self.torneo = torneo
        self.liEnActual = []
        self.xjugar = None
        self.liResult = None

        # Toolbar
        liAcciones = (
            (_("Save") + "+" + _("Quit"), Iconos.MainMenu(), "terminar"),
            None,
            (_("Cancel"), Iconos.Cancelar(), "cancelar"),
            None,
            (_("Play"), Iconos.Empezar(), "gmJugar"),
            None,
        )
        tb = Controles.TB(self, liAcciones)

        # Tabs
        self.tab = tab = Controles.Tab()

        # Tab-configuracion --------------------------------------------------
        w = QtGui.QWidget()
        # # Nombre
        lbNombre = Controles.LB(self, _("Name") + ": ")
        self.edNombre = Controles.ED(w, torneo.nombre())
        # # Resign
        lbResign = Controles.LB(self,
                                _("Minimum points to assign winner") + ": ")
        self.sbResign = Controles.SB(self, torneo.resign(), 60, 100000)
        # Draw-plys
        lbDrawMinPly = Controles.LB(self,
                                    _("Minimum moves to assign draw") + ": ")
        self.sbDrawMinPly = Controles.SB(self, torneo.drawMinPly(), 20, 1000)
        # Draw-puntos
        lbDrawRange = Controles.LB(self,
                                   _("Maximum points to assign draw") + ": ")
        self.sbDrawRange = Controles.SB(self, torneo.drawRange(), 0, 50)

        lbBook = Controles.LB(self, _("Opening book") + ": ")
        fvar = self.configuracion.ficheroBooks
        self.listaLibros = Books.ListaLibros()
        self.listaLibros.recuperaVar(fvar)
        # Comprobamos que todos esten accesibles
        self.listaLibros.comprueba()
        li = [(x.nombre, x.path) for x in self.listaLibros.lista]
        li.insert(0, ("* " + _("Default"), ""))
        self.cbBooks = Controles.CB(self, li, torneo.book())
        btNuevoBook = Controles.PB(self, "", self.nuevoBook,
                                   plano=False).ponIcono(Iconos.Nuevo(),
                                                         tamIcon=16)
        lyBook = Colocacion.H().control(
            self.cbBooks).control(btNuevoBook).relleno()

        # Posicion inicial
        lbFEN = Controles.LB(self, _("Initial position") + ": ")
        self.fen = torneo.fen()
        self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5,
                                       self.posicionEditar).ponPlano(False)
        self.btPosicionQuitar = Controles.PB(
            self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No())
        self.btPosicionPegar = Controles.PB(self, "",
                                            self.posicionPegar).ponIcono(
                                                Iconos.Pegar16()).ponToolTip(
                                                    _("Paste FEN position"))
        lyFEN = Colocacion.H().control(self.btPosicionQuitar).control(
            self.btPosicion).control(self.btPosicionPegar).relleno()

        # Norman Pollock
        lbNorman = Controles.LB(
            self,
            '%s(<a href="https://komodochess.com/pub/40H-pgn-utilities">?</a>): '
            % _("Initial position from Norman Pollock openings database"))
        self.chbNorman = Controles.CHB(self, " ", self.torneo.norman())

        # Layout
        layout = Colocacion.G()
        layout.controld(lbNombre, 0, 0).control(self.edNombre, 0, 1)
        layout.controld(lbResign, 1, 0).control(self.sbResign, 1, 1)
        layout.controld(lbDrawMinPly, 2, 0).control(self.sbDrawMinPly, 2, 1)
        layout.controld(lbDrawRange, 3, 0).control(self.sbDrawRange, 3, 1)
        layout.controld(lbBook, 4, 0).otro(lyBook, 4, 1)
        layout.controld(lbFEN, 5, 0).otro(lyFEN, 5, 1)
        layout.controld(lbNorman, 6, 0).control(self.chbNorman, 6, 1)
        layoutV = Colocacion.V().relleno().otro(layout).relleno()
        layoutH = Colocacion.H().relleno().otro(layoutV).relleno()

        # Creamos
        w.setLayout(layoutH)
        tab.nuevaTab(w, _("Configuration"))

        # Tab-engines --------------------------------------------------
        self.splitterEngines = QtGui.QSplitter(self)
        self.registrarSplitter(self.splitterEngines, "engines")
        # TB
        liAcciones = [
            (_("New"), Iconos.TutorialesCrear(), "enNuevo"),
            None,
            (_("Modify"), Iconos.Modificar(), "enModificar"),
            None,
            (_("Remove"), Iconos.Borrar(), "enBorrar"),
            None,
            (_("Copy"), Iconos.Copiar(), "enCopiar"),
            None,
            (_("Import"), Iconos.MasDoc(), "enImportar"),
            None,
        ]
        tbEnA = Controles.TB(self, liAcciones, tamIcon=24)

        # Grid engine
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("ALIAS", _("Alias"), 209)
        self.gridEnginesAlias = Grid.Grid(self,
                                          oColumnas,
                                          siSelecFilas=True,
                                          xid="EA",
                                          siSeleccionMultiple=True)
        self.registrarGrid(self.gridEnginesAlias)

        w = QtGui.QWidget()
        ly = Colocacion.V().control(self.gridEnginesAlias).margen(0)
        w.setLayout(ly)
        self.splitterEngines.addWidget(w)

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("CAMPO", _("Label"), 200, siDerecha=True)
        oColumnas.nueva("VALOR", _("Value"), 286)
        self.gridEnginesValores = Grid.Grid(self,
                                            oColumnas,
                                            siSelecFilas=False,
                                            xid="EV")
        self.registrarGrid(self.gridEnginesValores)

        w = QtGui.QWidget()
        ly = Colocacion.V().control(self.gridEnginesValores).margen(0)
        w.setLayout(ly)
        self.splitterEngines.addWidget(w)

        self.splitterEngines.setSizes([250, 520])  # por defecto

        w = QtGui.QWidget()
        ly = Colocacion.V().control(tbEnA).control(self.splitterEngines)
        w.setLayout(ly)
        tab.nuevaTab(w, _("Engines"))

        # Creamos

        # Tab-games --------------------------------------------------
        w = QtGui.QWidget()
        # TB
        liAcciones = [
            (_("New"), Iconos.TutorialesCrear(), "gmCrear"),
            None,
            (_("Remove"), Iconos.Borrar(), "gmBorrar"),
            None,
            (_("Show"), Iconos.PGN(), "gmMostrar"),
            None,
            (_("Save") + "(%s)" % _("PGN"), Iconos.GrabarComo(), "gmGuardar"),
            None,
        ]
        tbEnG = Controles.TB(self, liAcciones, tamIcon=24)
        # Grid engine
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("WHITE", _("White"), 190, siCentrado=True)
        oColumnas.nueva("BLACK", _("Black"), 190, siCentrado=True)
        oColumnas.nueva("RESULT", _("Result"), 190, siCentrado=True)
        oColumnas.nueva("TIEMPO", _("Time"), 170, siCentrado=True)
        self.gridGames = Grid.Grid(self,
                                   oColumnas,
                                   siSelecFilas=True,
                                   xid="G",
                                   siSeleccionMultiple=True)
        self.registrarGrid(self.gridGames)
        # Layout
        layout = Colocacion.V().control(tbEnG).control(self.gridGames)

        # Creamos
        w.setLayout(layout)
        tab.nuevaTab(w, _("Games"))

        # Tab-resultado --------------------------------------------------
        w = QtGui.QWidget()

        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        oColumnas.nueva("MOTOR", _("Engine"), 190, siCentrado=True)
        oColumnas.nueva("GANADOS", _("Wins"), 120, siCentrado=True)
        oColumnas.nueva("PERDIDOS", _("Lost"), 120, siCentrado=True)
        oColumnas.nueva("TABLAS", _("Draw"), 120, siCentrado=True)
        oColumnas.nueva("PUNTOS", _("Points"), 120, siCentrado=True)
        self.gridResult = Grid.Grid(self,
                                    oColumnas,
                                    siSelecFilas=True,
                                    xid="R")
        self.registrarGrid(self.gridResult)
        # Layout
        layout = Colocacion.V().control(self.gridResult)

        # Creamos
        w.setLayout(layout)
        tab.nuevaTab(w, _("Result"))

        # Layout
        layout = Colocacion.V().control(tb).control(tab).margen(8)
        self.setLayout(layout)

        self.recuperarVideo(siTam=True, anchoDefecto=800, altoDefecto=430)

        self.gridEnginesAlias.gotop()

        self.edNombre.setFocus()

        self.muestraPosicion()
Exemplo n.º 18
0
    def configurarGS(self):
        # self.test()
        # return

        mt = _("Engine").lower()
        mt = _X(_("Disable %1"), mt) if self.siJuegaMotor else _X(
            _("Enable %1"), mt)

        sep = (None, None, None)

        liMasOpciones = [
            ("rotacion", _("Auto-rotate board"), Iconos.JS_Rotacion()),
            sep,
            ("apertura", _("Opening"), Iconos.Apertura()),
            sep,
            ("posicion", _("Start position"), Iconos.Datos()),
            sep,
            ("pasteposicion", _("Paste FEN position"), Iconos.Pegar16()),
            sep,
            ("leerpgn", _("Read PGN"), Iconos.PGN_Importar()),
            sep,
            ("pastepgn", _("Paste PGN"), Iconos.Pegar16()),
            sep,
            ("motor", mt, Iconos.Motores()),
            sep,
            ("voyager", _("Voyager 2").replace("2", "1"), Iconos.Voyager1()),
        ]
        if self.configuracion.voice:
            liMasOpciones.append(sep)
            if self.activeVoice:
                liMasOpciones.append(
                    ("desvoice", _("Deactivate voice"), Iconos.X_Microfono()))
            else:
                liMasOpciones.append(
                    ("actvoice", _("Activate voice"), Iconos.S_Microfono()))
        resp = self.configurar(liMasOpciones,
                               siCambioTutor=True,
                               siSonidos=True)

        if resp == "rotacion":
            self.siVolteoAutomatico = not self.siVolteoAutomatico
            siBlancas = self.partida.ultPosicion.siBlancas
            if self.siVolteoAutomatico:
                if siBlancas != self.tablero.siBlancasAbajo:
                    self.tablero.rotaTablero()
        elif resp == "apertura":
            bl, ps = PantallaAperturas.dameApertura(self.pantalla,
                                                    self.configuracion,
                                                    self.bloqueApertura,
                                                    self.posicApertura)
            if bl:
                self.bloqueApertura = bl
                self.posicApertura = ps
                self.fen = None
                self.reiniciar()

        elif resp == "posicion":
            resp = WinPosition.editarPosicion(self.pantalla,
                                              self.configuracion, self.fen)
            if resp is not None:
                self.fen = resp
                self.bloqueApertura = None
                self.posicApertura = None

                if self.xpgn:
                    siInicio = self.fen == ControlPosicion.FEN_INICIAL
                    li = self.xpgn.split("\n")
                    lin = []
                    siFen = False
                    for linea in li:
                        if linea.startswith("["):
                            if "FEN " in linea:
                                siFen = True
                                if siInicio:
                                    continue
                                linea = '[FEN "%s"]' % self.fen
                            lin.append(linea)
                        else:
                            break
                    if not siFen:
                        linea = '[FEN "%s"]' % self.fen
                        lin.append(linea)
                    self.liPGN = lin
                    self.xpgn = "\n".join(lin) + "\n\n*"

                self.reiniciar()

        elif resp == "pasteposicion":
            texto = QTUtil.traePortapapeles()
            if texto:
                cp = ControlPosicion.ControlPosicion()
                try:
                    cp.leeFen(str(texto))
                    self.fen = cp.fen()
                    self.bloqueApertura = None
                    self.posicApertura = None
                    self.reiniciar()
                except:
                    pass

        elif resp == "leerpgn":
            unpgn = PantallaPGN.eligePartida(self.pantalla)
            if unpgn:
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "pastepgn":
            texto = QTUtil.traePortapapeles()
            if texto:
                unpgn = PGN.UnPGN()
                unpgn.leeTexto(texto)
                if unpgn.siError:
                    QTUtil2.mensError(
                        self.pantalla,
                        _("The text from the clipboard does not contain a chess game in PGN format"
                          ))
                    return
                self.bloqueApertura = None
                self.posicApertura = None
                self.fen = unpgn.dic.get("FEN", None)
                dic = self.creaDic()
                dic["PARTIDA"] = unpgn.partida.guardaEnTexto()
                dic["liPGN"] = unpgn.listaCabeceras()
                dic["FEN"] = self.fen
                dic["SIBLANCASABAJO"] = unpgn.partida.ultPosicion.siBlancas
                self.reiniciar(dic)

        elif resp == "motor":
            self.ponRotulo1("")
            if self.siJuegaMotor:
                if self.xrival:
                    self.xrival.terminar()
                    self.xrival = None
                self.siJuegaMotor = False
            else:
                self.cambioRival()

        elif resp == "voyager":
            ptxt = XVoyager.xVoyager(self.pantalla, self.configuracion,
                                     self.partida)
            if ptxt:
                dic = self.creaDic()
                dic["PARTIDA"] = ptxt
                p = self.partida.copia()
                p.recuperaDeTexto(ptxt)
                dic["FEN"] = None if p.siFenInicial() else p.iniPosicion.fen()
                dic["SIBLANCASABAJO"] = self.tablero.siBlancasAbajo
                self.reiniciar(dic)

        elif resp == "actvoice":
            self.setVoice(True)

        elif resp == "desvoice":
            self.setVoice(False)
Exemplo n.º 19
0
    def mueveHumano(self, desde, hasta, coronacion=None):
        jg = self.checkMueveHumano(desde, hasta, coronacion)
        if not jg:
            return False

        movimiento = jg.movimiento()

        siAnalisis = False

        siElegido = False

        if self.book and self.bookMandatory:
            fen = self.fenUltimo()
            listaJugadas = self.book.miraListaJugadas(fen)
            if listaJugadas:
                li = []
                for apdesde, aphasta, apcoronacion, nada, nada1 in listaJugadas:
                    mx = apdesde + aphasta + apcoronacion
                    if mx.strip().lower() == movimiento:
                        siElegido = True
                        break
                    li.append((apdesde, aphasta, False))
                if not siElegido:
                    self.tablero.ponFlechasTmp(li)
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaObl:
            fenBase = self.fenUltimo()
            if self.aperturaObl.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                apdesde, aphasta = self.aperturaObl.desdeHastaActual(fenBase)
                if apdesde is None:
                    self.aperturaObl = None
                else:
                    self.tablero.ponFlechasTmp(((apdesde, aphasta, False), ))
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaStd:
            fenBase = self.fenUltimo()
            if self.aperturaStd.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                if not self.aperturaStd.isActive(fenBase):
                    self.aperturaStd = None

        if self.siTeclaPanico:
            self.sigueHumano()
            return False

        self.analizaFinal()  # tiene que acabar siempre
        if not siElegido and (self.siTutorActivado or self.childmode):
            rmUser, n = self.mrmTutor.buscaRM(movimiento)
            if not rmUser:
                rmUser = self.xtutor.valora(self.partida.ultPosicion, desde,
                                            hasta, jg.coronacion)
                if not rmUser:
                    self.sigueHumanoAnalisis()
                    return False
                self.mrmTutor.agregaRM(rmUser)
            siAnalisis = True
            pointsBest, pointsUser = self.mrmTutor.difPointsBest(movimiento)
            self.setSummary("POINTSBEST", pointsBest)
            self.setSummary("POINTSUSER", pointsUser)
            difpts = self.configuracion.tutorDifPts
            difporc = self.configuracion.tutorDifPorc
            if self.mrmTutor.mejorRMQue(rmUser, difpts, difporc):
                if not jg.siJaqueMate:
                    siTutor = not self.childmode
                    if self.chance:
                        num = self.mrmTutor.numMejorMovQue(movimiento)
                        if num:
                            rmTutor = self.mrmTutor.rmBest()
                            menu = QTVarios.LCMenu(self.pantalla)
                            menu.opcion("None",
                                        _("There are %d best moves") % num,
                                        Iconos.Motor())
                            menu.separador()
                            if siTutor:
                                menu.opcion(
                                    "tutor", "&1. %s (%s)" %
                                    (_("Show tutor"), rmTutor.abrTextoBase()),
                                    Iconos.Tutor())
                                menu.separador()
                            menu.opcion("try", "&2. %s" % _("Try again"),
                                        Iconos.Atras())
                            menu.separador()
                            menu.opcion(
                                "user", "&3. %s (%s)" %
                                (_("Select my move"), rmUser.abrTextoBase()),
                                Iconos.Player())
                            self.pantalla.cursorFueraTablero()
                            resp = menu.lanza()
                            if resp == "try":
                                self.sigueHumanoAnalisis()
                                return False
                            elif resp == "user":
                                siTutor = False
                            elif resp != "tutor":
                                self.sigueHumanoAnalisis()
                                return False

                    if siTutor:
                        tutor = Tutor.Tutor(self, self, jg, desde, hasta,
                                            False)

                        if self.aperturaStd:
                            liApPosibles = self.listaAperturasStd.listaAperturasPosibles(
                                self.partida)
                        else:
                            liApPosibles = None

                        if tutor.elegir(self.ayudas > 0,
                                        liApPosibles=liApPosibles):
                            if self.ayudas > 0:  # doble entrada a tutor.
                                self.reponPieza(desde)
                                self.ayudas -= 1
                                self.childmode = self.nArrowsTt > 0 and self.ayudas > 0
                                desde = tutor.desde
                                hasta = tutor.hasta
                                coronacion = tutor.coronacion
                                siBien, mens, jgTutor = Jugada.dameJugada(
                                    self.partida.ultPosicion, desde, hasta,
                                    coronacion)
                                if siBien:
                                    jg = jgTutor
                                    self.setSummary("SELECTTUTOR", True)
                        if self.configuracion.guardarVariantesTutor:
                            tutor.ponVariantes(
                                jg, 1 + self.partida.numJugadas() / 2)

                        del tutor

        self.setSummary("TIMEUSER", self.timekeeper.stop())
        self.relojStop(True)

        self.movimientosPiezas(jg.liMovs)

        if siAnalisis:
            rm, nPos = self.mrmTutor.buscaRM(jg.movimiento())
            if rm:
                jg.analisis = self.mrmTutor, nPos

        self.partida.ultPosicion = jg.posicion
        self.masJugada(jg, True)
        self.error = ""
        self.siguienteJugada()
        return True
Exemplo n.º 20
0
    def __init__(self, wParent, configuracion, fen):

        QtGui.QDialog.__init__(self, wParent)

        self.wParent = wParent

        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.configuracion = configuracion

        self.setWindowTitle(_("Position"))
        self.setWindowIcon(Iconos.Datos())

        # Quien mueve
        self.rbBlancas = Controles.RB(self, _("White"))
        self.rbNegras = Controles.RB(self, _("Black"))

        # Enroques permitidos
        self.cbBoo = Controles.CHB(self, _("White") + " O-O", True)
        self.cbBooo = Controles.CHB(self, _("White") + " O-O-O", True)
        self.cbNoo = Controles.CHB(self, _("Black") + " O-O", True)
        self.cbNooo = Controles.CHB(self, _("Black") + " O-O-O", True)

        # Peon al paso
        lbAlPaso = Controles.LB(self, _("En passant") + ":")
        self.edAlPaso = Controles.ED(self).controlrx(
            "(-|[a-h][36])").anchoFijo(30)

        # Medias jugadas desde ultimo mov. peon
        self.edMedias, lbMedias = QTUtil2.spinBoxLB(
            self,
            0,
            0,
            999,
            etiqueta=_("Moves since the last pawn advance or capture"),
            maxTam=50)

        # Jugadas
        self.edJugadas, lbJugadas = QTUtil2.spinBoxLB(self,
                                                      1,
                                                      1,
                                                      999,
                                                      etiqueta=_("Moves"),
                                                      maxTam=50)

        # Botones adicionales
        btPosInicial = Controles.PB(self,
                                    _("Start position"),
                                    self.posInicial,
                                    plano=False)
        btLimpiaTablero = Controles.PB(self,
                                       _("Clear board"),
                                       self.limpiaTablero,
                                       plano=False)
        btPegar = Controles.PB(self,
                               _("Paste FEN position"),
                               self.pegarPosicion,
                               plano=False)
        btCopiar = Controles.PB(self,
                                _("Copy FEN position"),
                                self.copiarPosicion,
                                plano=False)
        btVoyager = Controles.PB(self, "", self.lanzaVoyager,
                                 plano=False).ponIcono(Iconos.Voyager())
        self.btVoice = Controles.PB(self, "", self.voiceActive,
                                    plano=False).ponIcono(Iconos.S_Microfono())
        self.btVoiceX = Controles.PB(self, "", self.voiceDeactive,
                                     plano=False).ponIcono(
                                         Iconos.X_Microfono())

        # Tablero
        confTablero = configuracion.confTablero("POSICION", 24)
        self.posicion = ControlPosicion.ControlPosicion()
        if fen:
            self.posicion.leeFen(fen)
        else:
            self.posicion.posInicial()
        self.tablero = Tablero.PosTablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueve)
        self.tablero.mensBorrar = self.borraCasilla
        self.tablero.mensCrear = self.creaCasilla
        self.tablero.mensRepetir = self.repitePieza
        self.ultimaPieza = "P"
        self.piezas = self.tablero.piezas

        self.resetPosicion()

        # Piezas drag-drop
        self.dragDropWI = QTVarios.ListaPiezas(self, "P;N;B;R;Q;K",
                                               self.tablero)
        self.dragDropWB = QTVarios.ListaPiezas(self, "P,N,B,R,Q,K",
                                               self.tablero)
        self.dragDropBD = QTVarios.ListaPiezas(self, "k;q;r;b;n;p",
                                               self.tablero)
        self.dragDropBA = QTVarios.ListaPiezas(self, "k,q,r,b,n,p",
                                               self.tablero)
        self.tablero.ponDispatchDrop(self.dispatchDrop)
        self.tablero.baseCasillasSC.setAcceptDrops(True)

        # Ayuda
        lbAyuda = Controles.LB(
            self,
            _("<ul><li><b>Add piece</b> : Right mouse button on empty square</li><li><b>Copy piece</b> : Left mouse button on empty square</li><li><b>Move piece</b> : Drag and drop piece with left mouse button</li><li><b>Delete piece</b> : Right mouse button on occupied square</li></ul>"
              ))

        # Tool bar
        tb = QTUtil2.tbAcceptCancel(self, siReject=False)

        # Layout

        # # Quien mueve
        hbox = Colocacion.H().relleno().control(
            self.rbBlancas).espacio(30).control(self.rbNegras).relleno()
        gbColor = Controles.GB(self, _("Next move"), hbox)

        # # Enroques
        ly = Colocacion.G().control(self.cbBoo, 0, 0).control(self.cbNoo, 0, 1)
        ly.control(self.cbBooo, 1, 0).control(self.cbNooo, 1, 1)
        gbEnroques = Controles.GB(self, _("Castling moves possible"), ly)

        ## Otros
        ly = Colocacion.G()
        ly.controld(lbMedias, 0, 0, 1, 3).control(self.edMedias, 0, 3)
        ly.controld(lbAlPaso, 1, 0).control(self.edAlPaso, 1, 1)
        ly.controld(lbJugadas, 1, 2).control(self.edJugadas, 1, 3)
        gbOtros = Controles.GB(self, "", ly)

        ## Botones adicionales
        lyBA = Colocacion.H().control(btPosInicial).control(
            btLimpiaTablero).control(btPegar).control(btCopiar).control(
                btVoyager)

        ## Ayuda
        ly = Colocacion.H().control(lbAyuda)
        gbAyuda = Controles.GB(self, _("Help"), ly)

        ## Izquierda
        ly = Colocacion.V().control(gbColor).relleno().control(
            gbEnroques).relleno()
        ly.control(gbOtros).relleno().control(gbAyuda).margen(5)
        lyI = Colocacion.V().control(tb).otro(ly).margen(3)

        ## Derecha
        lyBT = Colocacion.H().control(self.btVoice).control(self.btVoiceX)
        lyDA = Colocacion.G()
        lyDA.controlc(self.dragDropBA, 0, 1).otro(lyBT, 0, 2)
        lyDA.controld(self.dragDropWI, 1,
                      0).control(self.tablero, 1,
                                 1).control(self.dragDropBD, 1, 2)
        lyDA.controlc(self.dragDropWB, 2, 1)

        lyD = Colocacion.V().otro(lyDA).otro(lyBA).relleno()

        ## Completo
        ly = Colocacion.H().otro(lyI).otro(lyD).margen(3)
        self.setLayout(ly)

        if configuracion.siDGT:
            if not DGT.activarSegunON_OFF(self.dgt):  # Error
                QTUtil2.mensError(
                    self, _("Error, could not detect the DGT board driver."))

        self.ponCursor()

        self.voyager = None
        self.bufferVoice = ""
        self.queueVoice = []
        self.isVoiceActive = False
        if not configuracion.voice:
            self.btVoiceX.setVisible(False)
            self.btVoice.setVisible(False)
        else:
            if Voice.runVoice.isActive():
                self.voiceActive()
            else:
                self.voiceDeactive()
Exemplo n.º 21
0
    def __init__(self, owner, db_captures, capture):

        QTVarios.WDialogo.__init__(self, owner,
                                   _("Captures and threats in a game"),
                                   Iconos.Captures(), "runcaptures")

        self.configuration = Code.configuration
        self.capture = capture
        self.db_captures = db_captures

        conf_board = self.configuration.config_board("RUNCAPTURES", 64)

        self.board = Board.BoardEstaticoMensaje(self, conf_board, None)
        self.board.crea()

        # Rotulo informacion
        self.lb_info_game = Controles.LB(
            self,
            self.capture.game.titulo(
                "DATE", "EVENT", "WHITE", "BLACK", "RESULT")).ponTipoLetra(
                    puntos=self.configuration.x_pgn_fontpoints)

        # Movimientos
        self.liwm_captures = []
        ly = Colocacion.G().margen(4)
        for i in range(16):
            f = i // 2
            c = i % 2
            wm = WRunCommon.WEdMove(self)
            self.liwm_captures.append(wm)
            ly.control(wm, f, c)

        self.gb_captures = Controles.GB(self, _("Captures"), ly).ponFuente(
            Controles.TipoLetra(puntos=10, peso=750))

        self.liwm_threats = []
        ly = Colocacion.G().margen(4)
        for i in range(16):
            f = i // 2
            c = i % 2
            wm = WRunCommon.WEdMove(self)
            self.liwm_threats.append(wm)
            ly.control(wm, f, c)

        self.gb_threats = Controles.GB(self, _("Threats"), ly).ponFuente(
            Controles.TipoLetra(puntos=10, peso=750))

        self.lb_result = Controles.LB(self).ponTipoLetra(
            puntos=10, peso=500).anchoFijo(254).altoFijo(32).set_wrap()
        self.lb_info = (
            Controles.LB(self).anchoFijo(254).set_foreground_backgound(
                "white", "#496075").align_center().ponTipoLetra(puntos=14,
                                                                peso=500))

        # Botones
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Begin"), Iconos.Empezar(), self.begin),
            (_("Check"), Iconos.Check(), self.check),
            (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir),
        )
        self.tb = QTVarios.LCTB(self,
                                li_acciones,
                                style=QtCore.Qt.ToolButtonTextBesideIcon,
                                icon_size=32)
        self.show_tb(self.terminar, self.begin)

        ly_right = (Colocacion.V().control(self.tb).controlc(
            self.lb_info).relleno().control(
                self.gb_captures).relleno().control(self.gb_threats).control(
                    self.lb_result).relleno())

        ly_center = Colocacion.H().control(self.board).otro(ly_right)

        ly = Colocacion.V().otro(ly_center).control(
            self.lb_info_game).margen(3)

        self.setLayout(ly)

        self.restore_video()
        self.adjustSize()

        # Tiempo
        self.time_base = time.time()

        self.gb_captures.setDisabled(True)
        self.gb_threats.setDisabled(True)

        self.liwm_captures[0].activa()

        self.ultimaCelda = None

        self.pon_info_posic()
        self.set_position()
    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 __init__(self, owner, configuration, opening_block):
        icono = Iconos.Opening()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = OpeningsStd.apTrain
        self.configuration = configuration
        self.game = Game.Game()
        self.opening_block = opening_block
        self.liActivas = []

        # Board
        config_board = configuration.config_board("APERTURAS", 32)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.set_dispatcher(self.player_has_moved)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").set_wrap().ponTipoLetra(puntos=10,
                                                                    peso=75)

        # Movimiento
        self.is_moving_time = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self,
                                                  "",
                                                  siLibre=False,
                                                  icon_size=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)
        tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida)
        tb.new(_("Takeback"), Iconos.Atras(), self.atras)
        tb.new(_("Remove"), Iconos.Borrar(), self.borrar)

        # Lista Openings
        o_columns = Columnas.ListaColumnas()
        dicTipos = {
            "b": Iconos.pmSun(),
            "n": Iconos.pmPuntoAzul(),
            "l": Iconos.pmNaranja()
        }
        o_columns.nueva("TYPE",
                        "",
                        24,
                        edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        o_columns.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, altoFila=32)
        self.register_grid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.board).otro(lyBM).control(self.lbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtWidgets.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.register_splitter(splitter, "splitter")

        # Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()

        dic = {"_SIZE_": "916,444", "SP_splitter": [356, 548]}
        self.restore_video(dicDef=dic)
Exemplo n.º 24
0
    def __init__(self, procesador):

        icono = Iconos.ManualSave()
        extparam = "manualsave"
        titulo = _("Save positions to FNS/PGN")
        QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, icono,
                                   extparam)

        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.posicion = ControlPosicion.ControlPosicion()
        self.posicion.posInicial()

        self.gestor_motor = None
        self.pgn = None
        self.fns = None

        self.li_labels = [
            ["Site", ""],
            ["Event", ""],
            ["Date", ""],
            ["White", ""],
            ["Black", ""],
            ["WhiteElo", ""],
            ["BlackElo", ""],
            ["Result", ""],
        ]
        self.li_labels.extend([["", ""] for x in range(10)])

        self.li_analysis = []
        self.analyzing = False

        self.partida = None

        # Toolbar
        liAcciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("External engines"), Iconos.Motores(), self.ext_engines),
            None,
        )
        tb = Controles.TBrutina(self, liAcciones)

        # Board + botones + solucion + boton salvado
        ##
        bt_change_position = Controles.PB(self,
                                          "   " + _("Change position"),
                                          self.change_position,
                                          plano=False)
        bt_change_position.ponIcono(Iconos.Datos(), 24)
        ##
        conf_tablero = self.configuracion.confTablero("MANUALSAVE", 32)
        self.tablero = Tablero.Tablero(self, conf_tablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)
        ##
        lybt, bt = QTVarios.lyBotonesMovimiento(self,
                                                "",
                                                siLibre=False,
                                                tamIcon=24,
                                                siTiempo=False)
        ##
        self.em_solucion = Controles.EM(
            self,
            siHTML=False).altoMinimo(40).capturaCambios(self.reset_partida)
        ##
        self.bt_solucion = Controles.PB(self,
                                        "   " + _("Save solution"),
                                        self.savesolucion,
                                        plano=False).ponIcono(
                                            Iconos.Grabar(), 24)
        self.bt_editar = Controles.PB(self,
                                      "   " + _("Edit"),
                                      self.editar_solucion,
                                      plano=False).ponIcono(Iconos.PlayGame())
        ly = Colocacion.V().control(self.em_solucion).control(self.bt_editar)
        gb = Controles.GB(self, _("Solution"), ly)
        ###
        lybtp = Colocacion.H().control(bt_change_position).espacio(20).control(
            self.bt_solucion)
        lyT = Colocacion.V().otro(lybtp).control(
            self.tablero).otro(lybt).control(gb)
        gb_left = Controles.GB(self, "", lyT)

        # Ficheros PGN + FNS
        lb_pgn = Controles.LB(self, _("PGN") + ": ")
        self.bt_pgn = Controles.PB(self, "", self.pgn_select,
                                   plano=False).anchoMinimo(300)
        bt_no_pgn = Controles.PB(self, "", self.pgn_unselect).ponIcono(
            Iconos.Delete()).anchoFijo(16)
        lb_fns = Controles.LB(self, _("FNS") + ": ")
        self.bt_fns = Controles.PB(self, "", self.fns_select,
                                   plano=False).anchoMinimo(300)
        bt_no_fns = Controles.PB(self, "", self.fns_unselect).ponIcono(
            Iconos.Delete()).anchoFijo(16)
        ## Codec
        lb_codec = Controles.LB(self, _("Encoding") + ": ")
        liCodecs = [
            k for k in set(v for k, v in encodings.aliases.aliases.iteritems())
        ]
        liCodecs.sort()
        liCodecs = [(k, k) for k in liCodecs]
        liCodecs.insert(0,
                        ("%s: %s" % (_("By default"), _("UTF-8")), "default"))
        self.codec = "default"
        self.cb_codecs = Controles.CB(self, liCodecs, self.codec)
        ###
        ly0 = Colocacion.G().control(lb_pgn, 0,
                                     0).control(self.bt_pgn, 0,
                                                1).control(bt_no_pgn, 0, 2)
        ly0.control(lb_fns, 1, 0).control(self.bt_fns, 1,
                                          1).control(bt_no_fns, 1, 2)
        ly1 = Colocacion.H().control(lb_codec).control(
            self.cb_codecs).relleno(1)
        ly = Colocacion.V().otro(ly0).otro(ly1)
        gb_files = Controles.GB(self, _("File to save"), ly)

        # Labels + correlativo
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("LABEL",
                        _("Label"),
                        80,
                        edicion=Delegados.LineaTextoUTF8(),
                        siCentrado=True)
        oColumnas.nueva("VALUE",
                        _("Value"),
                        280,
                        edicion=Delegados.LineaTextoUTF8())
        self.grid_labels = Grid.Grid(self, oColumnas, siEditable=True, xid=1)
        n = self.grid_labels.anchoColumnas()
        self.grid_labels.setFixedWidth(n + 20)
        self.registrarGrid(self.grid_labels)

        ##
        lb_number = Controles.LB(self, _("Correlative number") + ": ")
        self.sb_number = Controles.SB(self, 0, 0, 99999999).tamMaximo(50)
        lb_number_help = Controles.LB(
            self, _("Replace symbol # in Value column (#=3, ###=003)"))
        lb_number_help.setWordWrap(True)

        ly_number = Colocacion.H().control(lb_number).control(
            self.sb_number).control(lb_number_help, 4)

        ly = Colocacion.V().control(self.grid_labels).otro(ly_number)
        gb_labels = Controles.GB(self, _("PGN labels"), ly)

        # Analysis + grid + start/stop + multiPV
        self.bt_start = Controles.PB(self, "", self.start).ponIcono(
            Iconos.Pelicula_Seguir(), 32)
        self.bt_stop = Controles.PB(self, "", self.stop).ponIcono(
            Iconos.Pelicula_Pausa(), 32)
        self.bt_stop.hide()

        lb_engine = Controles.LB(self, _("Engine") + ":")
        liMotores = self.configuracion.comboMotoresCompleto()
        self.cb_engine = Controles.CB(
            self, liMotores,
            self.configuracion.tutor.clave).capturaCambiado(self.reset_motor)

        lb_multipv = Controles.LB(self, _("Multi PV") + ": ")
        self.sb_multipv = Controles.SB(self, 1, 1, 500).tamMaximo(50)
        ##
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("PDT", _("Evaluation"), 100, siCentrado=True)
        oColumnas.nueva("PGN", _("Solution"), 360)
        self.grid_analysis = Grid.Grid(self, oColumnas, siSelecFilas=True)
        self.registrarGrid(self.grid_analysis)
        ##
        lb_analysis_help = Controles.LB(
            self, _("Double click to send analysis line to solution"))
        ###
        ly_lin1 = Colocacion.H().control(self.bt_start).control(
            self.bt_stop).control(lb_engine).control(self.cb_engine)
        ly_lin1.relleno(1).control(lb_multipv).control(self.sb_multipv)
        ly = Colocacion.V().otro(ly_lin1).control(
            self.grid_analysis).control(lb_analysis_help)
        gb_analysis = Controles.GB(self, _("Analysis"), ly)

        # ZONA
        splitter_right = QtGui.QSplitter(self)
        splitter_right.setOrientation(QtCore.Qt.Vertical)
        splitter_right.addWidget(gb_files)
        splitter_right.addWidget(gb_labels)
        splitter_right.addWidget(gb_analysis)

        self.registrarSplitter(splitter_right, "RIGHT")
        ##
        splitter = QtGui.QSplitter(self)
        splitter.addWidget(gb_left)
        splitter.addWidget(splitter_right)

        self.registrarSplitter(splitter, "ALL")

        layout = Colocacion.V().control(tb).control(splitter).margen(5)

        self.setLayout(layout)

        self.inicializa()
Exemplo n.º 25
0
    def menuPlay(self):
        menu = QTVarios.LCMenu(self.pantalla)
        menu.opcion(k_libre, _("Play against an engine of your choice"), Iconos.Libre())
        menu.separador()

        # Principiantes ----------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Opponents for young players"), Iconos.RivalesMP())

        menu1.opcion(1000 + kMP_1, _("Monkey"), Iconos.Monkey())
        menu1.opcion(1000 + kMP_2, _("Donkey"), Iconos.Donkey())
        menu1.opcion(1000 + kMP_3, _("Bull"), Iconos.Bull())
        menu1.opcion(1000 + kMP_4, _("Wolf"), Iconos.Wolf())
        menu1.opcion(1000 + kMP_5, _("Lion"), Iconos.Lion())
        menu1.opcion(1000 + kMP_6, _("Rat"), Iconos.Rat())
        menu1.opcion(1000 + kMP_7, _("Snake"), Iconos.Snake())
        menu1.separador()

        menu2 = menu1.submenu(_("Albums of animals"), Iconos.Penguin())
        albumes = Albums.AlbumesAnimales()
        dic = albumes.listaMenu()
        anterior = None
        for animal in dic:
            siDeshabilitado = False
            if anterior and not dic[anterior]:
                siDeshabilitado = True
            menu2.opcion(( "animales", animal ), _F(animal), Iconos.icono(animal), siDeshabilitado=siDeshabilitado)
            anterior = animal
        menu1.separador()

        menu2 = menu1.submenu(_("Albums of vehicles"), Iconos.Wheel())
        albumes = Albums.AlbumesVehicles()
        dic = albumes.listaMenu()
        anterior = None
        for character in dic:
            siDeshabilitado = False
            if anterior and not dic[anterior]:
                siDeshabilitado = True
            menu2.opcion(( "vehicles", character ), _F(character), Iconos.icono(character),
                         siDeshabilitado=siDeshabilitado)
            anterior = character

        resp = menu.lanza()
        if resp:
            if resp == k_libre:
                self.procesarAccion(resp)

            elif type(resp) == int:
                rival = resp - 1000
                uno = QTVarios.blancasNegrasTiempo(self.pantalla)
                if uno:
                    siBlancas, siTiempo, minutos, segundos = uno
                    if siBlancas is not None:
                        if not siTiempo:
                            minutos = None
                            segundos = None
                        self.entrenaRivalesMPC(siBlancas, rival, rival >= kMP_6, minutos, segundos)
            else:
                tipo, cual = resp
                if tipo == "animales":
                    self.albumAnimales(cual)
                elif tipo == "vehicles":
                    self.albumVehicles(cual)
Exemplo n.º 26
0
 def icono(self):
     return Iconos.icono(self.c_icono)
Exemplo n.º 27
0
    def __init__(self, wParent, torneo, torneoTMP, gestor):

        titulo = _("Results")
        icono = Iconos.Torneos()
        extparam = "unresulttorneo"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        # Datos
        self.torneo = torneo
        self.torneoTMP = torneoTMP
        self.gestor = gestor
        self.liResult = self.torneo.rehacerResult()
        self.liResultTMP = self.torneoTMP.rehacerResult()

        # Tabs
        self.tab = tab = Controles.Tab()

        # Tab-configuracion --------------------------------------------------
        w = QtGui.QWidget()
        # # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        oColumnas.nueva("MOTOR", _("Engine"), 190, siCentrado=True)
        oColumnas.nueva("GANADOS", _("Wins"), 120, siCentrado=True)
        oColumnas.nueva("PERDIDOS", _("Lost"), 120, siCentrado=True)
        oColumnas.nueva("TABLAS", _("Draw"), 120, siCentrado=True)
        oColumnas.nueva("PUNTOS", _("Points"), 120, siCentrado=True)
        self.gridResultTMP = Grid.Grid(self,
                                       oColumnas,
                                       siSelecFilas=True,
                                       xid="T")
        # # Layout
        layout = Colocacion.V().control(self.gridResultTMP)
        w.setLayout(layout)
        tab.nuevaTab(w, _("Current"))

        # Tab-configuracion --------------------------------------------------
        w = QtGui.QWidget()
        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        oColumnas.nueva("MOTOR", _("Engine"), 190, siCentrado=True)
        oColumnas.nueva("GANADOS", _("Wins"), 120, siCentrado=True)
        oColumnas.nueva("PERDIDOS", _("Lost"), 120, siCentrado=True)
        oColumnas.nueva("TABLAS", _("Draw"), 120, siCentrado=True)
        oColumnas.nueva("PUNTOS", _("Points"), 120, siCentrado=True)
        self.gridResult = Grid.Grid(self,
                                    oColumnas,
                                    siSelecFilas=True,
                                    xid="B")
        # Layout
        layout = Colocacion.V().control(self.gridResult)
        w.setLayout(layout)
        tab.nuevaTab(w, _("All"))

        layout = Colocacion.V().control(tab).margen(8)
        self.setLayout(layout)

        self.registrarGrid(self.gridResultTMP)
        self.registrarGrid(self.gridResult)
        self.recuperarVideo(siTam=True, anchoDefecto=800, altoDefecto=430)

        self.gridResult.gotop()
        self.gridResultTMP.gotop()
Exemplo n.º 28
0
 def pixmap(self):
     return Iconos.pixmap(self.clave)
Exemplo n.º 29
0
    def __init__(self, owner, file):
        self.litourneys = Everest.str_file(file)
        self.configuration = owner.configuration
        titulo = _("New expedition")
        icono = Iconos.Trekking()
        extparam = "newexpedition"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.selected = None

        # Torneo
        li = [("%s (%d)" % (_F(tourney["TOURNEY"]), len(tourney["GAMES"])),
               tourney) for tourney in self.litourneys]
        li.sort(key=lambda x: x[0])
        self.cbtourney, lbtourney = QTUtil2.comboBoxLB(self, li, li[0],
                                                       _("Expedition"))
        btmas = Controles.PB(self, "", self.mas).ponIcono(Iconos.Mas22())
        lytourney = Colocacion.H().control(lbtourney).control(
            self.cbtourney).control(btmas).relleno(1)

        # tolerance
        self.sbtolerance_min, lbtolerance_min = QTUtil2.spinBoxLB(
            self, 20, 0, 99999, _("From"))
        self.sbtolerance_min.capture_changes(self.tolerance_changed)
        self.sbtolerance_max, lbtolerance_max = QTUtil2.spinBoxLB(
            self, 1000, 0, 99999, _("To"))
        lbexplanation = Controles.LB(
            self,
            _("Maximum lost centipawns for having to repeat active game"))
        ly = Colocacion.H().relleno(2).control(lbtolerance_min).control(
            self.sbtolerance_min).relleno(1)
        ly.control(lbtolerance_max).control(self.sbtolerance_max).relleno(2)
        layout = Colocacion.V().otro(ly).control(lbexplanation)
        gbtolerance = Controles.GB(self, _("Tolerance"), layout)

        # tries
        self.sbtries_min, lbtries_min = QTUtil2.spinBoxLB(
            self, 2, 1, 99999, _("From"))
        self.sbtries_min.capture_changes(self.tries_changed)
        self.sbtries_max, lbtries_max = QTUtil2.spinBoxLB(
            self, 15, 1, 99999, _("To"))
        lbexplanation = Controles.LB(
            self, _("Maximum repetitions to return to the previous game"))
        ly = Colocacion.H().relleno(2).control(lbtries_min).control(
            self.sbtries_min).relleno(1)
        ly.control(lbtries_max).control(self.sbtries_max).relleno(2)
        layout = Colocacion.V().otro(ly).control(lbexplanation)
        gbtries = Controles.GB(self, _("Tries"), layout)

        # color
        liColors = ((_("Default"), "D"), (_("White"), "W"), (_("Black"), "B"))
        self.cbcolor = Controles.CB(self, liColors, "D")
        layout = Colocacion.H().relleno(1).control(self.cbcolor).relleno(1)
        gbcolor = Controles.GB(self, _("Color"), layout)

        tb = QTVarios.LCTB(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)

        layout = Colocacion.V().control(tb).otro(lytourney).control(
            gbtolerance).control(gbtries).control(gbcolor)

        self.setLayout(layout)
Exemplo n.º 30
0
    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.Spinbox(_("Total minutes"), 1, 999, 50)
        liGen.append((config, get("MINUTES", 10)))

        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))

        reg = Util.Almacen()
        reg.form = None

        def dispatch(valor):
            if reg.form is None:
                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())

        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)
        self.torneo.randomize()

        self.gridGames.refresh()
        self.gridGames.gobottom()
        self.borraResult()
Exemplo n.º 31
0
 def icono(self):
     return Iconos.icono(self.c_icono)
Exemplo n.º 32
0
    def ponToolbar(self, tipo):

        if tipo == self.INICIO:
            liAcciones = (
                (_("Cancel"), Iconos.Cancelar(), "cancelar"),
                None,
                (_("Reinit"), Iconos.Reiniciar(), "reset"),
                None,
                (_("Help"), Iconos.AyudaGR(), "ayuda"),
                None,
            )
        elif tipo == self.FINAL_JUEGO:
            liAcciones = (
                (_("Close"), Iconos.MainMenu(), "final"),
                None,
                (_("Reinit"), Iconos.Reiniciar(), "reset"),
                None,
                (_("Replay game"), Iconos.Pelicula(), "replay"),
                None,
            )
        elif tipo == self.REPLAY:
            liAcciones = (
                (_("Cancel"), Iconos.Cancelar(), "repCancelar"),
                None,
                (_("Reinit"), Iconos.Inicio(), "repReiniciar"),
                None,
                (_("Slow"), Iconos.Pelicula_Lento(), "repSlow"),
                None,
                (_("Pause"), Iconos.Pelicula_Pausa(), "repPause"),
                None,
                (_("Fast"), Iconos.Pelicula_Rapido(), "repFast"),
                None,
            )
        elif tipo == self.REPLAY_CONTINUE:
            liAcciones = (
                (_("Cancel"), Iconos.Cancelar(), "repCancelar"),
                None,
                (_("Continue"), Iconos.Pelicula_Seguir(), "repContinue"),
                None,
            )
        self.tb.reset(liAcciones)
Exemplo n.º 33
0
    def __init__(self, owner, configuracion, bloqueApertura):
        icono = Iconos.Apertura()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = AperturasStd.ListaAperturasStd(configuracion, True, True)
        self.configuracion = configuracion
        self.partida = Partida.Partida()
        self.bloqueApertura = bloqueApertura
        self.liActivas = []

        # Tablero
        confTablero = configuracion.confTablero("APERTURAS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueveHumano)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").ponWrap().ponTipoLetra(puntos=10, peso=75)
        ly = Colocacion.H().control(self.lbPGN)
        gbPGN = Controles.GB(self, _("Current opening"), ly)

        # Movimiento
        self.siMoviendoTiempo = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new( _("Accept"), Iconos.Aceptar(), self.aceptar )
        tb.new( _("Cancel"), Iconos.Cancelar(), self.cancelar )
        tb.new( _("Reinit"), Iconos.Reiniciar(), self.resetPartida )
        tb.new( _("Takeback"), Iconos.Atras(), self.atras )
        tb.new( _("Remove"), Iconos.Borrar(), self.borrar )

        # Lista Aperturas
        oColumnas = Columnas.ListaColumnas()
        dicTipos = {"b": Iconos.pmEstrella(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja()}
        oColumnas.nueva("TIPO", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        oColumnas.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, altoFila=32)
        self.registrarGrid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.tablero).otro(lyBM).control(gbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtGui.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.registrarSplitter(splitter, "splitter")

        ## Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.recuperarVideo(siTam=True)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()
Exemplo n.º 34
0
    def __init__(self, wParent, configuracion, dic, siGestorSolo):
        super(WCambioRival, self).__init__(wParent)

        if not dic:
            dic = {}

        self.setWindowTitle(_("Change opponent"))
        self.setWindowIcon(Iconos.Motor())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.configuracion = configuracion
        self.personalidades = Personalidades.Personalidades(self, configuracion)

        # Toolbar
        liAcciones = [(_("Accept"), Iconos.Aceptar(), "aceptar"), None,
                      (_("Cancel"), Iconos.Cancelar(), "cancelar"), None,
                      ]
        tb = Controles.TB(self, liAcciones)

        # Blancas o negras
        self.rbBlancas = Controles.RB(self, _("White")).activa()
        self.rbNegras = Controles.RB(self, _("Black"))

        # Atras
        self.cbAtras = Controles.CHB(self, "", True)

        # Motores
        self.motores = Motores.Motores(configuracion)

        liDepths = [("--", 0)]
        for x in range(1, 31):
            liDepths.append((str(x), x))

        # # Rival
        self.rival = configuracion.rivalInicial
        self.rivalTipo = Motores.INTERNO
        self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False)
        self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50)
        self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth)
        lbTiempoSegundosR = Controles.LB2P(self, _("Time"))
        lbNivel = Controles.LB2P(self, _("Depth"))

        # # Ajustar rival
        liAjustes = self.personalidades.listaAjustes(True)
        self.cbAjustarRival = Controles.CB(self, liAjustes, kAjustarMejor).capturaCambiado(self.ajustesCambiado)
        lbAjustarRival = Controles.LB2P(self, _("Set strength"))
        btAjustarRival = Controles.PB(self, "", self.cambiaPersonalidades, plano=False).ponIcono(Iconos.Nuevo(),
                                                                                                 tamIcon=16)
        btAjustarRival.ponToolTip(_("Personalities"))

        # Layout
        # Color
        hbox = Colocacion.H().relleno().control(self.rbBlancas).espacio(30).control(self.rbNegras).relleno()
        gbColor = Controles.GB(self, _("Play with"), hbox)

        # Atras
        hbox = Colocacion.H().espacio(10).control(self.cbAtras)
        gbAtras = Controles.GB(self, _("Takeback"), hbox).alinCentrado()

        ## Color + Atras
        hAC = Colocacion.H().control(gbColor).control(gbAtras)
        if siGestorSolo:
            # gbColor.hide()
            gbAtras.hide()

        # Motores
        # Rival
        ly = Colocacion.G()
        ly.controlc(self.btRival, 0, 0, 1, 4)
        ly.controld(lbTiempoSegundosR, 1, 0).controld(self.edRtiempo, 1, 1)
        ly.controld(lbNivel, 1, 2).control(self.cbRdepth, 1, 3)
        lyH = Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(btAjustarRival).relleno()
        ly.otroc(lyH, 2, 0, 1, 4)
        gbR = Controles.GB(self, _("Opponent"), ly)

        lyResto = Colocacion.V()
        lyResto.otro(hAC).espacio(3)
        lyResto.control(gbR).espacio(1)
        lyResto.margen(8)

        layout = Colocacion.V().control(tb).otro(lyResto).relleno().margen(3)

        self.setLayout(layout)

        self.dic = dic
        self.recuperaDic()

        self.ajustesCambiado()
        self.ponRival()
Exemplo n.º 35
0
 def ico(ok):
     return Iconos.Aceptar() if ok else Iconos.PuntoAmarillo()
Exemplo n.º 36
0
    def preparaTB(self):

        self.dicTB = {}

        liOpciones = ((_("Accept"), Iconos.S_Aceptar(), self.ks_aceptar),
                      (_("Cancel"), Iconos.S_Cancelar(), self.ks_cancelar),
                      (_("Recording Mic"), Iconos.S_Microfono(), self.ks_microfono),
                      (_("Read wav"), Iconos.S_LeerWav(), self.ks_wav),
                      (_("Listen"), Iconos.S_Play(), self.ks_play),
                      (_("End"), Iconos.S_StopPlay(), self.ks_stopplay),
                      (_("End"), Iconos.S_StopMicrofono(), self.ks_stopmic),
                      (_("Begin"), Iconos.S_Record(), self.ks_record),
                      (_("Cancel"), Iconos.S_Cancelar(), self.ks_cancelmic),
                      (_("Delete"), Iconos.S_Limpiar(), self.ks_limpiar),
                      (_("Save wav"), Iconos.Grabar(), self.ks_grabar),
                      )

        for titulo, icono, clave in liOpciones:
            accion = QtGui.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            self.connect(accion, QtCore.SIGNAL("triggered()"), self.procesaTB)
            accion.clave = clave
            self.dicTB[clave] = accion
Exemplo n.º 37
0
 def icono(self):
     return Iconos.icono(self.clave)
Exemplo n.º 38
0
    def __init__(self, owner, listaMarcos, dbMarcos):

        titulo = _("Boxes")
        icono = Iconos.Marcos()
        extparam = "marcos"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.owner = owner

        flb = Controles.TipoLetra(puntos=8)

        self.liPMarcos = listaMarcos
        self.configuracion = VarGen.configuracion

        self.dbMarcos = dbMarcos

        self.liPMarcos = owner.listaMarcos()

        # Lista
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 60, siCentrado=True)
        oColumnas.nueva("NOMBRE", _("Name"), 256)

        self.grid = Grid.Grid(self, oColumnas, id="M", siSelecFilas=True)

        liAcciones = [
            (_("Quit"), Iconos.MainMenu(), "terminar"),
            None,
            (_("New"), Iconos.Nuevo(), "mas"),
            None,
            (_("Remove"), Iconos.Borrar(), "borrar"),
            None,
            (_("Modify"), Iconos.Modificar(), "modificar"),
            None,
            (_("Copy"), Iconos.Copiar(), "copiar"),
            None,
            (_("Up"), Iconos.Arriba(), "arriba"),
            None,
            (_("Down"), Iconos.Abajo(), "abajo"),
            None,
        ]
        tb = Controles.TB(self, liAcciones)
        tb.setFont(flb)

        ly = Colocacion.V().control(tb).control(self.grid)

        # Tablero
        confTablero = owner.tablero.confTablero
        self.tablero = Tablero.TableroVisual(self, confTablero)
        self.tablero.crea()
        self.tablero.copiaPosicionDe(owner.tablero)

        # Layout
        layout = Colocacion.H().otro(ly).control(self.tablero)
        self.setLayout(layout)

        self.registrarGrid(self.grid)
        self.recuperarVideo()

        # Ejemplos
        liMovs = ["b4c4", "e2e2", "e4g7"]
        self.liEjemplos = []
        regMarco = TabTipos.Marco()
        for a1h8 in liMovs:
            regMarco.a1h8 = a1h8
            regMarco.siMovible = True
            marco = self.tablero.creaMarco(regMarco)
            self.liEjemplos.append(marco)

        self.grid.gotop()
        self.grid.setFocus()
Exemplo n.º 39
0
 def pixmap_level(self):
     li = ("Amarillo", "Naranja", "Verde", "Azul", "Magenta", "Rojo")
     return Iconos.pixmap(li[self.nivel])
Exemplo n.º 40
0
    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
            li_gen = []
            li_gen.append((None, "%s: %d" % (_("Total games"), nreccount)))
            li_gen.append(sep)
            config = FormLayout.Editbox(_("Select games") + "<br>" +
                                        _("By example:") + " -5,7-9,14,19-" +
                                        "<br>" + _("Empty means all games"),
                                        rx="[0-9,\-,\,]*")
            li_gen.append((config, plant))

            li_gen.append(sep)

            li_gen.append((_("Shuffle") + ":", shuffle))

            li_gen.append(sep)

            li_gen.append((_("Reverse") + ":", reverse))

            li_gen.append(sep)

            config = FormLayout.Spinbox(_("Max moves"), 0, 999, 50)
            li_gen.append((config, 0))

            resultado = FormLayout.fedit(li_gen,
                                         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()
Exemplo n.º 41
0
    def __init__(self, owner, regMarco):

        QtGui.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.TableroVisual(self, confTablero)
        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)
Exemplo n.º 42
0
    def __init__(self, owner, partida, nivel, white, black, siClock):

        QTVarios.WDialogo.__init__(self, owner, owner.rotulo(), Iconos.PGN(),
                                   "learnpuente")

        self.owner = owner
        self.procesador = owner.procesador
        self.configuracion = self.procesador.configuracion
        self.partida = partida
        self.nivel = nivel
        self.white = white
        self.black = black
        self.siClock = siClock

        self.repTiempo = 3000
        self.repWorking = False

        # Tool bar
        self.tb = Controles.TB(self, [])

        self.ponToolbar(self.INICIO)

        # Tableros
        confTablero = self.configuracion.confTablero("LEARNPGN", 48)

        self.tableroIni = Tablero.Tablero(self, confTablero)
        self.tableroIni.crea()
        self.tableroIni.ponMensajero(self.mueveHumano, None)
        self.lbIni = Controles.LB(self).alinCentrado().ponColorFondoN(
            "#076C9F", "#EFEFEF").anchoMinimo(self.tableroIni.ancho)
        lyIni = Colocacion.V().control(self.tableroIni).control(self.lbIni)

        self.tableroFin = Tablero.TableroEstatico(self, confTablero)
        self.tableroFin.crea()
        self.lbFin = Controles.LB(self).alinCentrado().ponColorFondoN(
            "#076C9F", "#EFEFEF").anchoMinimo(self.tableroFin.ancho)
        lyFin = Colocacion.V().control(self.tableroFin).control(self.lbFin)

        # Rotulo tiempo
        f = Controles.TipoLetra(puntos=30, peso=75)
        self.lbReloj = Controles.LB(
            self, "00:00").ponFuente(f).alinCentrado().ponColorFondoN(
                "#076C9F", "#EFEFEF").anchoMinimo(200)
        self.lbReloj.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)

        # Movimientos
        flb = Controles.TipoLetra(puntos=11)
        self.lbInfo = Controles.LB(self).anchoFijo(200).ponWrap().ponFuente(
            flb)

        # Layout
        lyC = Colocacion.V().control(self.lbReloj).control(
            self.lbInfo).relleno()
        lyTM = Colocacion.H().otro(lyIni).otro(lyC).otro(lyFin).relleno()

        ly = Colocacion.V().control(self.tb).otro(lyTM).relleno().margen(3)

        self.setLayout(ly)

        self.recuperarVideo()
        self.adjustSize()

        if siClock:
            self.timer = QtCore.QTimer(self)
            self.connect(self.timer, QtCore.SIGNAL("timeout()"),
                         self.ajustaReloj)
            self.timer.start(500)
        else:
            self.lbReloj.hide()

        self.reset()
Exemplo n.º 43
0
    def __init__(self, procesador, titulo):

        QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, Iconos.Libre(), "entMaquina")

        self.configuracion = procesador.configuracion
        self.procesador = procesador

        self.personalidades = Personalidades.Personalidades(self, self.configuracion)

        self.motores = Motores.Motores(self.configuracion)

        # Toolbar

        liAcciones = [(_("Accept"), Iconos.Aceptar(), self.aceptar), None,
                      (_("Cancel"), Iconos.Cancelar(), self.cancelar), None,
                      (_("Configurations"), Iconos.Configurar(), self.configuraciones), None,
                      ]
        tb = Controles.TBrutina(self, liAcciones)

        # Tab

        tab = Controles.Tab()

        def nuevoG():
            lyG = Colocacion.G()
            lyG.filaActual = 0
            return lyG

        gbStyle = """
            QGroupBox {
                font: bold 16px;
                background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/
                border: 1px solid gray;
                border-radius: 3px;
                margin-top: 5ex; /* leave space at the top for the title */
            }
            QGroupBox::title {
                subcontrol-origin: margin;
                subcontrol-position: top center; /* position at the top center */
                padding: 0 3px;
             }
        """

        def _label(lyG, txt, ly, rutinaCHB=None, siCheck=False):
            gb = Controles.GB(self, txt, ly)
            if rutinaCHB:
                gb.conectar(rutinaCHB)
            elif siCheck:
                gb.setCheckable(True)
                gb.setChecked(False)

            gb.setStyleSheet(gbStyle)
            lyG.controlc(gb, lyG.filaActual, 0)
            lyG.filaActual += 1
            return gb

        # TAB General

        lyG = nuevoG()

        # Blancas o negras
        self.rbBlancas = Controles.RB(self, "").activa()
        self.rbBlancas.setIcon(QTVarios.fsvg2ico("Pieces/Chessicons/wp.svg", 64))
        self.rbNegras = Controles.RB(self, "")
        self.rbNegras.setIcon(QTVarios.fsvg2ico("Pieces/Chessicons/bp.svg", 64))
        self.rbRandom = Controles.RB(self, _("Random"))
        hbox = Colocacion.H().relleno().control(self.rbBlancas).espacio(30).control(self.rbNegras).espacio(30).control(
                self.rbRandom).relleno()
        _label(lyG, _("Select color"), hbox)

        # Motores
        liDepths = [("--", 0)]
        for x in range(1, 31):
            liDepths.append((str(x), x))

        # # Rival
        self.rival = self.configuracion.rivalInicial
        self.rivalTipo = Motores.INTERNO
        self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False)
        self.edRtiempo = Controles.ED(self).tipoFloat().anchoMaximo(50)
        self.cbRdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth)
        lbTiempoSegundosR = Controles.LB2P(self, _("Time"))
        lbNivel = Controles.LB2P(self, _("Depth"))

        # # Ajustar rival
        liAjustes = self.personalidades.listaAjustes(True)
        self.cbAjustarRival = Controles.CB(self, liAjustes, kAjustarMejor).capturaCambiado(self.ajustesCambiado)
        lbAjustarRival = Controles.LB2P(self, _("Set strength"))
        btAjustarRival = Controles.PB(self, _("Personality"), self.cambiaPersonalidades, plano=True).ponIcono(
                Iconos.Mas(), tamIcon=16)

        # Resign
        lbResign = Controles.LB2P(self, _("Resign/draw by engine"))
        liResign = ((_("Very early"), -100),
                    (_("Early"), -300),
                    (_("Average"), -500),
                    (_("Late"), -800),
                    (_("Very late"), -1000),
                    (_("Never"), -9999999))
        self.cbResign = Controles.CB(self, liResign, -800)

        lyH1 = Colocacion.H().control(self.btRival).espacio(20)
        lyH1.control(lbTiempoSegundosR).control(self.edRtiempo)
        lyH1.control(lbNivel).control(self.cbRdepth).relleno()
        lyH2 = Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(btAjustarRival).relleno()
        lyH3 = Colocacion.H().control(lbResign).control(self.cbResign).relleno()
        ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3)
        _label(lyG, _("Opponent"), ly)

        gb = Controles.GB(self, "", lyG)
        tab.nuevaTab(gb, _("Basic configuration"))

        # TAB Ayudas
        lbAyudas = Controles.LB2P(self, _("Available hints"))
        self.sbAyudas = Controles.SB(self, 7, 0, 999).tamMaximo(50)
        self.cbAtras = Controles.CHB(self, _("Takeback"), True)
        self.cbChance = Controles.CHB(self, _("Second chance"), True)
        btTutorChange = Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False).ponIcono(Iconos.Tutor(), tamIcon=16)

        liThinks = [(_("Nothing"), -1), (_("Score"), 0)]
        for i in range(1, 5):
            liThinks.append(("%d %s" % (i, _("ply") if i == 1 else _("plies")), i))
        liThinks.append((_("All"), 9999))

        lb = Controles.LB(self, _("It is showed") + ":")
        self.cbThoughtTt = Controles.CB(self, liThinks, -1)
        self.cbContinueTt = Controles.CHB(self, _("The tutor thinks while you think"), True)
        lbBoxHeight = Controles.LB2P(self, _("Box height"))
        self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50)
        ly1 = Colocacion.H().control(lb).control(self.cbThoughtTt).relleno()
        ly2 = Colocacion.H().control(lbBoxHeight).control(self.sbBoxHeight).relleno()
        ly = Colocacion.V().otro(ly1).control(self.cbContinueTt).espacio(16).otro(ly2).relleno()
        gbThoughtTt = Controles.GB(self, _("Thought of the tutor"), ly)
        gbThoughtTt.setStyleSheet(gbStyle)

        lb = Controles.LB(self, _("It is showed") + ":")
        self.cbThoughtOp = Controles.CB(self, liThinks, -1)
        lbArrows = Controles.LB2P(self, _("Arrows to show"))
        self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50)
        ly1 = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno()
        ly2 = Colocacion.H().control(lbArrows).control(self.sbArrows).relleno()
        ly = Colocacion.V().otro(ly1).otro(ly2).relleno()
        gbThoughtOp = Controles.GB(self, _("Thought of the opponent"), ly)
        gbThoughtOp.setStyleSheet(gbStyle)

        self.chbSummary = Controles.CHB(self, _("Save a summary when the game is finished in the main comment"), False)

        lyH1 = Colocacion.H().relleno()
        lyH1.control(lbAyudas).control(self.sbAyudas).relleno()
        lyH1.control(self.cbAtras).relleno()
        lyH1.control(self.cbChance).relleno()
        lyH1.control(btTutorChange).relleno()

        # lyV1 = Colocacion.V().control(gbThoughtOp)

        lyH3 = Colocacion.H().relleno()
        lyH3.control(gbThoughtOp).relleno()
        lyH3.control(gbThoughtTt).relleno()

        ly = Colocacion.V().otro(lyH1).otro(lyH3).control(self.chbSummary).margen(16)
        gb = Controles.GB(self, "", ly)
        tab.nuevaTab(gb, _("Help configuration"))

        # TAB Tiempo

        lyG = nuevoG()
        self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB(self, 15, 0, 999, maxTam=50, etiqueta=_("Total minutes"))
        self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB(self, 6, -999, 999, maxTam=54,
                                                             etiqueta=_("Seconds added per move"))
        self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB(self, 0, -999, 999, maxTam=70,
                                                             etiqueta=_("Extra minutes for the player"))
        self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB(self, 0, -999, 999, maxTam=54,
                                                           etiqueta=_("Zeitnot: alarm sounds when remaining seconds"))
        lyH1 = Colocacion.H()
        lyH1.control(self.lbMinutos).control(self.edMinutos).espacio(30)
        lyH1.control(self.lbSegundos).control(self.edSegundos).relleno()
        lyH2 = Colocacion.H()
        lyH2.control(self.lbMinExtra).control(self.edMinExtra).relleno()
        lyH3 = Colocacion.H()
        lyH3.control(self.lbZeitnot).control(self.edZeitnot).relleno()
        ly = Colocacion.V().otro(lyH1).otro(lyH2).otro(lyH3)
        self.chbTiempo = _label(lyG, _("Time"), ly, siCheck=True)

        gb = Controles.GB(self, "", lyG)
        tab.nuevaTab(gb, _("Time"))

        # TAB Initial moves

        lyG = nuevoG()

        # Posicion
        self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False)
        self.fen = ""
        self.btPosicionQuitar = Controles.PB(self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No())
        self.btPosicionPegar = Controles.PB(self, "", self.posicionPegar).ponIcono(Iconos.Pegar16()).ponToolTip(
                _("Paste FEN position"))
        hbox = Colocacion.H().relleno().control(self.btPosicionQuitar).control(self.btPosicion).control(
                self.btPosicionPegar).relleno()
        _label(lyG, _("Start position"), hbox)

        # Aperturas
        self.btApertura = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.editarApertura).ponPlano(False)
        self.bloqueApertura = None
        self.btAperturasFavoritas = Controles.PB(self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos())
        self.btAperturasQuitar = Controles.PB(self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No())
        hbox = Colocacion.H().relleno().control(self.btAperturasQuitar).control(self.btApertura).control(
                self.btAperturasFavoritas).relleno()
        _label(lyG, _("Opening"), hbox)

        # Libros
        fvar = self.configuracion.ficheroBooks
        self.listaLibros = Books.ListaLibros()
        self.listaLibros.recuperaVar(fvar)
        # Comprobamos que todos esten accesibles
        self.listaLibros.comprueba()
        li = [(x.nombre, x) for x in self.listaLibros.lista]
        libInicial = li[0][1] if li else None
        self.cbBooks = QTUtil2.comboBoxLB(self, li, libInicial)
        self.btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16)
        self.chbBookMandatory = Controles.CHB(self, _("Mandatory"), False)
        # Respuesta rival
        li = (
            (_("Selected by the player"), "su"),
            (_("Uniform random"), "au"),
            (_("Proportional random"), "ap"),
            (_("Always the highest percentage"), "mp"),
        )
        self.cbBooksRR = QTUtil2.comboBoxLB(self, li, "mp")
        self.lbBooksRR = Controles.LB2P(self, _("Opponent's move"))
        hbox = Colocacion.H().relleno().control(self.cbBooks).control(self.btNuevoBook).control(
                self.chbBookMandatory).relleno()
        hboxRR = Colocacion.H().relleno().control(self.lbBooksRR).control(self.cbBooksRR).relleno()
        hboxV = Colocacion.V().otro(hbox).otro(hboxRR)
        self.chbBook = _label(lyG, _("Book"), hboxV, siCheck=True)

        ly = Colocacion.V().otro(lyG).relleno()

        gb = Controles.GB(self, "", ly)
        tab.nuevaTab(gb, _("Initial moves"))

        layout = Colocacion.V().control(tb).control(tab).relleno().margen(3)

        self.setLayout(layout)

        self.liAperturasFavoritas = []
        self.btAperturasFavoritas.hide()

        dic = Util.recuperaDIC(self.configuracion.ficheroEntMaquina)
        if not dic:
            dic = {}
        self.muestraDic(dic)

        self.ajustesCambiado()
        # self.ayudasCambiado()
        self.ponRival()

        self.recuperarVideo()
Exemplo n.º 44
0
    def __init__(self, owner, tablero):
        self.owner = owner
        self.posicion = tablero.ultPosicion
        self.tablero = tablero
        self.configuracion = tablero.configuracion
        self.fenM2 = self.posicion.fenM2()
        self.origin_new = None

        self.leeRecursos()

        titulo = _("Director")
        icono = Iconos.Script()
        extparam = "tabvisualscript"
        QTVarios.WDialogo.__init__(self, tablero, titulo, icono, extparam)

        self.siGrabar = False
        self.ant_foto = None

        self.guion = TabVisual.Guion(tablero, self)

        # Guion
        liAcciones = [(_("Close"), Iconos.MainMenu(), self.terminar),
                      (_("Cancel"), Iconos.Cancelar(), self.cancelar),
                      (_("Save"), Iconos.Grabar(), self.grabar),
                      (_("New"), Iconos.Nuevo(), self.gnuevo),
                      (_("Insert"), Iconos.Insertar(), self.ginsertar),
                      (_("Remove"), Iconos.Borrar(), self.gborrar), None,
                      (_("Up"), Iconos.Arriba(), self.garriba),
                      (_("Down"), Iconos.Abajo(), self.gabajo), None,
                      (_("Mark"), Iconos.Marcar(), self.gmarcar), None,
                      (_("File"), Iconos.Recuperar(), self.gfile), None]
        self.tb = Controles.TBrutina(self,
                                     liAcciones,
                                     siTexto=False,
                                     tamIcon=24)
        self.tb.setAccionVisible(self.grabar, False)

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 20, siCentrado=True)
        oColumnas.nueva("MARCADO", "", 20, siCentrado=True, siChecked=True)
        oColumnas.nueva("TIPO", _("Type"), 50, siCentrado=True)
        oColumnas.nueva("NOMBRE",
                        _("Name"),
                        100,
                        siCentrado=True,
                        edicion=Delegados.LineaTextoUTF8())
        oColumnas.nueva("INFO", _("Information"), 100, siCentrado=True)
        self.g_guion = Grid.Grid(self,
                                 oColumnas,
                                 siCabeceraMovible=False,
                                 siEditable=True,
                                 siSeleccionMultiple=True)
        self.g_guion.fixMinWidth()

        self.registrarGrid(self.g_guion)

        self.chbSaveWhenFinished = Controles.CHB(
            self, _("Save when finished"),
            self.dbConfig.get("SAVEWHENFINISHED", False))

        # Visuales
        self.selectBanda = PantallaTab.SelectBanda(self)

        lyG = Colocacion.V().control(self.g_guion).control(
            self.chbSaveWhenFinished)
        lySG = Colocacion.H().control(self.selectBanda).otro(lyG).relleno(1)
        layout = Colocacion.V().control(self.tb).otro(lySG).margen(3)

        self.setLayout(layout)

        self.recuperarVideo()

        self.recuperar()
        self.ant_foto = self.foto()

        self.actualizaBandas()
        li = self.dbConfig["SELECTBANDA"]
        if li:
            self.selectBanda.recuperar(li)
        num_lb = self.dbConfig["SELECTBANDANUM"]
        if num_lb is not None:
            self.selectBanda.seleccionarNum(num_lb)

        self.ultDesde = "d4"
        self.ultHasta = "e5"

        self.g_guion.gotop()