Example #1
0
    def __init__(self, wowner, gestor, alm, muestraAnalisis):
        titulo = _("Result of analysis")
        icono = Iconos.Estadisticas()
        extparam = "estadisticas"
        QTVarios.WDialogo.__init__(self, wowner, titulo, icono, extparam)

        self.alm = alm
        self.procesador = gestor.procesador
        self.gestor = gestor
        self.siPawns = not gestor.procesador.configuracion.centipawns
        self.muestraAnalisis = muestraAnalisis
        self.colorWhite = QTUtil.qtColorRGB(231, 244, 254)

        tabGen = Controles.Tab()

        w = QtGui.QWidget()

        def xcol():
            oColumnas = Columnas.ListaColumnas()
            oColumnas.nueva("NUM", _("N."), 50, siCentrado=True)
            oColumnas.nueva("MOVE",
                            _("Move"),
                            120,
                            siCentrado=True,
                            edicion=Delegados.EtiquetaPGN(True, True, True))
            oColumnas.nueva("BEST",
                            _("Best move"),
                            120,
                            siCentrado=True,
                            edicion=Delegados.EtiquetaPGN(True, True, True))
            oColumnas.nueva("DIF", _("Difference"), 80, siCentrado=True)
            oColumnas.nueva("PORC", "%", 80, siCentrado=True)
            return oColumnas

        self.dicLiJG = {
            "A": self.alm.lijg,
            "W": self.alm.lijgW,
            "B": self.alm.lijgB
        }
        gridAll = Grid.Grid(self, xcol(), siSelecFilas=True, id="A")
        self.registrarGrid(gridAll)
        gridW = Grid.Grid(self, xcol(), siSelecFilas=True, id="W")
        self.registrarGrid(gridW)
        gridB = Grid.Grid(self, xcol(), siSelecFilas=True, id="B")
        self.registrarGrid(gridB)

        lbIndexes = Controles.LB(self, alm.indexesHTML)
        pbSave = Controles.PB(self,
                              _("Save to game comments"),
                              self.saveIndexes,
                              plano=False)
        pbSave.ponIcono(Iconos.Grabar())
        ly0 = Colocacion.H().control(pbSave).relleno()
        ly = Colocacion.V().control(lbIndexes).otro(ly0).relleno()
        wIdx = QtGui.QWidget()
        wIdx.setLayout(ly)

        tabGrid = Controles.Tab().ponPosicion("W")
        tabGrid.nuevaTab(gridAll, _("All moves"))
        tabGrid.nuevaTab(gridW, _("White"))
        tabGrid.nuevaTab(gridB, _("Black"))
        tabGrid.nuevaTab(wIdx, _("Indexes"))

        confTablero = VarGen.configuracion.confTablero("ANALISISGRAPH", 48)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)

        layout = Colocacion.H().control(tabGrid).control(
            self.tablero).margen(0)
        w.setLayout(layout)
        tabGen.nuevaTab(w, _("Data"))

        tabGraph = Controles.Tab().ponPosicion("W")
        tabGen.nuevaTab(tabGraph, _("Graphics"))

        tab = Controles.Tab()
        tab.nuevaTab(alm.game, _("Total"))
        tab.nuevaTab(alm.gameDif, _("Lost points"))
        tabGraph.nuevaTab(tab, _("All moves"))

        tab = Controles.Tab()
        tab.nuevaTab(alm.white, _("Total"))
        tab.nuevaTab(alm.whiteDif, _("Lost points"))
        tabGraph.nuevaTab(tab, _("White"))

        tab = Controles.Tab()
        tab.nuevaTab(alm.black, _("Total"))
        tab.nuevaTab(alm.blackDif, _("Lost points"))
        tabGraph.nuevaTab(tab, _("Black"))

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

        self.recuperarVideo(siTam=True, anchoDefecto=960, altoDefecto=600)

        gridAll.gotop()
        gridB.gotop()
        gridW.gotop()
        self.gridBotonIzquierdo(gridAll, 0, None)
Example #2
0
    def __init__(self, mAnalisis, ventana, siBlancas, siLibre, siGrabar,
                 muestraInicial):
        titulo = _("Analysis")
        icono = Iconos.Tutor()
        extparam = "analysis"

        QTVarios.WDialogo.__init__(self, ventana, titulo, icono, extparam)

        self.mAnalisis = mAnalisis
        self.muestraActual = None

        confTablero = VarGen.configuracion.confTablero("ANALISIS", 48)
        self.siLibre = siLibre
        self.siGrabar = siGrabar
        self.siBlancas = siBlancas

        tbWork = Controles.TBrutina(self, tamIcon=24)
        tbWork.new(_("Close"), Iconos.MainMenu(), self.terminar)
        tbWork.new(_("New"), Iconos.NuevoMas(), self.crear)

        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(siBlancas)

        self.lbMotor = Controles.LB(self).alinCentrado()
        self.lbTiempo = Controles.LB(self).alinCentrado()
        self.lbPuntuacion = Controles.LB(self).alinCentrado().ponTipoLetra(
            puntos=10, peso=75)
        self.lbPGN = Controles.LB(self).ponTipoLetra(peso=75).ponWrap()

        self.setStyleSheet(
            "QStatusBar::item { border-style: outset; border-width: 1px; border-color: LightSlateGray ;}"
        )

        liMasAcciones = (("FEN:%s" % _("Copy to clipboard"), "MoverFEN",
                          Iconos.Clip()), )
        lytb, self.tb = QTVarios.lyBotonesMovimiento(
            self,
            "",
            siLibre=siLibre,
            siGrabar=siGrabar,
            siGrabarTodos=siGrabar,
            siJugar=mAnalisis.maxRecursion > 10,
            liMasAcciones=liMasAcciones)

        lyTabl = Colocacion.H().relleno().control(self.tablero).relleno()

        lyMotor = Colocacion.H().control(self.lbPuntuacion).relleno().control(
            self.lbMotor).control(self.lbTiempo)

        lyV = Colocacion.V()
        lyV.control(tbWork)
        lyV.otro(lyTabl)
        lyV.otro(lytb)
        lyV.otro(lyMotor)
        lyV.control(self.lbPGN)
        lyV.relleno()

        wm = WMuestra(self, muestraInicial)
        muestraInicial.wmu = wm

        # Layout
        self.ly = Colocacion.H().margen(10)
        self.ly.otro(lyV)
        self.ly.control(wm)

        lyM = Colocacion.H().margen(0).otro(self.ly).relleno()

        layout = Colocacion.V()
        layout.otro(lyM)
        layout.margen(3)
        layout.setSpacing(1)
        self.setLayout(layout)

        self.recuperarVideo(siTam=False)
        self.show()
        wm.cambiadoRM(muestraInicial.posElegida)
        self.activaMuestra(muestraInicial)
Example #3
0
    def __init__(self, wParent, oColumnas, liFiltro):

        super(WFiltrar, self).__init__(wParent)

        self.setWindowTitle(_("Filter"))
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)
        self.setWindowIcon(Iconos.Filtrar())

        self.liFiltro = liFiltro
        nFiltro = len(liFiltro)

        liCampos = [(x.cabecera, x.clave) for x in oColumnas.liColumnas
                    if x.clave != "numero"]
        liCampos.insert(0, ("", None))
        liCondicion = [("", None), (_("Equal"), "="), (_("Not equal"), "<>"),
                       (_("Greater than"), ">"), (_("Less than"), "<"),
                       (_("Greater than or equal"), ">="),
                       (_("Less than or equal"), "<="),
                       (_("Like (wildcard = *)"), "LIKE"),
                       (_("Not like (wildcard = *)"), "NOT LIKE")]

        liUnion = [("", None), (_("AND"), "AND"), (_("OR"), "OR")]

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

        lbCol = Controles.LB(self, _("Column")).ponFuente(f)
        lbPar0 = Controles.LB(self, "(").ponFuente(f)
        lbPar1 = Controles.LB(self, ")").ponFuente(f)
        lbCon = Controles.LB(self, _("Condition")).ponFuente(f)
        lbVal = Controles.LB(self, _("Value")).ponFuente(f)
        lbUni = Controles.LB(self, "+").ponFuente(f)

        ly = Colocacion.G()
        ly.controlc(lbUni, 0,
                    0).controlc(lbPar0, 0, 1).controlc(lbCol, 0, 2).controlc(
                        lbCon, 0, 3).controlc(lbVal, 0,
                                              4).controlc(lbPar1, 0, 5)

        self.numC = 8
        liC = []

        for i in range(self.numC):
            if nFiltro > i:
                union, par0, campo, condicion, valor, par1 = liFiltro[i]
            else:
                union, par0, campo, condicion, valor, par1 = None, False, None, None, "", False
            if i > 0:
                c_union = Controles.CB(self, liUnion, union)
                ly.controlc(c_union, i + 1, 0)
            else:
                c_union = None

            c_par0 = Controles.CHB(self, "", par0).anchoFijo(20)
            ly.controlc(c_par0, i + 1, 1)
            c_campo = Controles.CB(self, liCampos, campo)
            ly.controlc(c_campo, i + 1, 2)
            c_condicion = Controles.CB(self, liCondicion, condicion)
            ly.controlc(c_condicion, i + 1, 3)
            c_valor = Controles.ED(self, valor)
            ly.controlc(c_valor, i + 1, 4)
            c_par1 = Controles.CHB(self, "", par1).anchoFijo(20)
            ly.controlc(c_par1, i + 1, 5)

            liC.append(
                (c_union, c_par0, c_campo, c_condicion, c_valor, c_par1))

        self.liC = liC

        # Toolbar
        liAcciones = [
            (_("Accept"), Iconos.Aceptar(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.reject),
            None,
            (_("Reinit"), Iconos.Reiniciar(), self.reiniciar),
            None,
        ]
        tb = Controles.TBrutina(self, liAcciones)

        # Layout
        layout = Colocacion.V().control(tb).otro(ly).margen(3)
        self.setLayout(layout)

        liC[0][2].setFocus()
Example #4
0
def comboBoxLB(parent, liOpciones, valor, etiqueta=None):
    cb = Controles.CB(parent, liOpciones, valor)
    if etiqueta:
        return cb, Controles.LB(parent, etiqueta + ": ")
    else:
        return cb
Example #5
0
    def creaBloqueInformacion(self):
        configuracion = self.gestor.configuracion
        nAnchoPgn = configuracion.anchoPGN
        nAnchoColor = (nAnchoPgn - 35 - 20) / 2
        nAnchoLabels = max(int((nAnchoPgn - 3) / 2), 140)
        # # Pgn
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        siFigurinesPGN = configuracion.figurinesPGN
        oColumnas.nueva(
            "BLANCAS",
            _("White"),
            nAnchoColor,
            edicion=Delegados.EtiquetaPGN(True if siFigurinesPGN else None))
        oColumnas.nueva(
            "NEGRAS",
            _("Black"),
            nAnchoColor,
            edicion=Delegados.EtiquetaPGN(False if siFigurinesPGN else None))
        self.pgn = Grid.Grid(self, oColumnas, siCabeceraMovible=False)
        self.pgn.setMinimumWidth(nAnchoPgn)
        self.pgn.tipoLetra(puntos=configuracion.puntosPGN)
        self.pgn.ponAltoFila(configuracion.altoFilaPGN)

        # # Blancas y negras
        f = Controles.TipoLetra(
            puntos=self.gestor.configuracion.tamFontRotulos + 2, peso=75)
        bl, ng = _("White"), _("Black")
        self.lbJugBlancas = Controles.LB(self, bl).anchoFijo(
            nAnchoLabels).alinCentrado().ponFuente(f).ponColorFondoN(
                "black", "white").ponWrap()
        self.lbJugNegras = Controles.LB(self, ng).anchoFijo(
            nAnchoLabels).alinCentrado().ponFuente(f).ponColorFondoN(
                "white", "black").ponWrap()
        self.lbJugBlancas.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)
        self.lbJugNegras.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)

        # Relojes
        f = Controles.TipoLetra("Arial Black", puntos=26, peso=75)

        def lbReloj():
            lb = Controles.LB(
                self, "00:00").ponFuente(f).alinCentrado().ponColorFondoN(
                    "#076C9F", "#EFEFEF").anchoMinimo(nAnchoLabels)
            lb.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)
            return lb

        self.lbRelojBlancas = lbReloj()
        self.lbRelojNegras = lbReloj()

        # Revisando
        f = Controles.TipoLetra(puntos=14, peso=75)
        self.lbRevision = Controles.LB(
            self,
            _("Reviewing...")).alinCentrado().ponFuente(f).ponFondoN("#b3b3b3")

        # Ayudas
        self.ayudasUD = QTVarios.LCNumero(3)

        f = Controles.TipoLetra(puntos=12)
        self.lbCredito = Controles.LB(self,
                                      _("Available hints") +
                                      " :   ").alinCentrado().ponFuente(f)

        # Boton de tutor activo
        self.btActivarTutor = Controles.PB(
            self, "", rutina=self.cambiaSiActivarTutor,
            plano=False)  # .anchoFijo( nAnchoPgn )

        # Rotulos de informacion
        f = Controles.TipoLetra(
            puntos=self.gestor.configuracion.tamFontRotulos)
        self.lbRotulo1 = Controles.LB(self).ponWrap().ponFuente(f)
        self.lbRotulo2 = Controles.LB(self).ponWrap().ponFuente(f)
        f9 = Controles.TipoLetra(puntos=9)
        self.lbRotulo3 = Controles.LB(self).ponWrap().ponFuente(f9)
        # self.lbRotulo1.setStyleSheet("*{ border: 1px solid darkgray }")
        # self.lbRotulo2.setStyleSheet("*{ border: 1px solid darkgray }")
        self.lbRotulo3.setStyleSheet("*{ border: 1px solid darkgray }")
        self.lbRotulo3.altoFijo(48)

        # Lo escondemos
        self.lbJugBlancas.hide()
        self.lbJugNegras.hide()
        self.lbRelojBlancas.hide()
        self.lbRelojNegras.hide()
        self.pgn.hide()
        self.lbRevision.hide()
        self.ayudasUD.hide()
        self.lbCredito.hide()
        self.btActivarTutor.hide()
        self.lbRotulo1.hide()
        self.lbRotulo2.hide()
        self.lbRotulo3.hide()

        # Layout

        # Remoto
        lyColor = Colocacion.G()
        lyColor.controlc(self.lbJugBlancas, 0,
                         0).controlc(self.lbJugNegras, 0, 1)
        lyColor.controlc(self.lbRelojBlancas, 1,
                         0).controlc(self.lbRelojNegras, 1, 1)

        # Ayudas
        lyAyudas = Colocacion.H().relleno().control(self.lbCredito).control(
            self.ayudasUD).relleno().ponSeparacion(1)

        # Abajo
        lyAbajo = Colocacion.V()
        lyAbajo.setSizeConstraint(lyAbajo.SetFixedSize)
        lyAbajo.control(self.lbRevision).otro(lyAyudas).control(
            self.btActivarTutor)
        lyAbajo.control(self.lbRotulo1).control(self.lbRotulo2).control(
            self.lbRotulo3)

        lyV = Colocacion.V().otro(lyColor).control(self.pgn)
        lyV.otro(lyAbajo)

        return lyV
Example #6
0
 def lbReloj():
     lb = Controles.LB(
         self, "00:00").ponFuente(f).alinCentrado().ponColorFondoN(
             "#076C9F", "#EFEFEF").anchoMinimo(nAnchoLabels)
     lb.setFrameStyle(QtGui.QFrame.Box | QtGui.QFrame.Raised)
     return lb
    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()
Example #8
0
    def __init__(self, gestor, tutor, siRival, siAperturas, is_white,
                 siPuntos):
        titulo = _("Analyzing your move")
        icono = Iconos.Tutor()
        extparam = "tutor"
        QTVarios.WDialogo.__init__(self, gestor.main_window, titulo, icono,
                                   extparam)

        self.tutor = tutor
        self.gestor0 = gestor.gestor
        self.respLibro = None
        self.siElegidaApertura = False

        self.x_tutor_view = gestor.procesador.configuracion.x_tutor_view

        # ~ self.setStyleSheet("QDialog,QGroupBox { background: #f0f0f0; }")

        f = Controles.TipoLetra(puntos=12, peso=75)
        flb = Controles.TipoLetra(puntos=10)
        flba = Controles.TipoLetra(puntos=8)

        ae = QTUtil.anchoEscritorio()
        mx = 32 if ae > 1000 else 20
        config_board = Code.configuracion.config_board("TUTOR", mx)

        # Tableros

        def creaTablero(name, si=True, siLibre=True, siMas=False):
            if not si:
                return None, None, None
            tablero = Tablero.Tablero(self, config_board)
            tablero.crea()
            tablero.ponerPiezasAbajo(is_white)
            lytb, tb = QTVarios.lyBotonesMovimiento(self,
                                                    name,
                                                    siLibre,
                                                    siMas=siMas)
            return tablero, lytb, tb

        self.tableroTutor, lytbTutor, self.tbTutor = creaTablero("tutor")
        self.tableroUsuario, lytbUsuario, self.tbUsuario = creaTablero("user")
        self.tableroRival, lytbRival, self.tbRival = creaTablero(
            "rival", siRival)
        self.tableroApertura, lytbApertura, self.tbApertura = creaTablero(
            "opening", siAperturas, siLibre=False)
        tutor.ponTablerosGUI(self.tableroTutor, self.tableroUsuario,
                             self.tableroRival, self.tableroApertura)

        # Puntuaciones
        self.lbTutorPuntuacion = Controles.LB(self).alinCentrado().ponFuente(
            flb)
        self.lbUsuarioPuntuacion = Controles.LB(self).alinCentrado().ponFuente(
            flb)
        if siRival:
            self.lbRivalPuntuacion = Controles.LB(
                self).alinCentrado().ponFuente(flb)

        # Aperturas
        if siAperturas:
            li_options = self.tutor.opcionesAperturas()
            self.cbAperturas = Controles.CB(self, li_options, 0)
            self.cbAperturas.setFont(flba)
            self.connect(self.cbAperturas,
                         QtCore.SIGNAL("currentIndexChanged(int)"),
                         self.tutor.cambiarApertura)

        # RM
        liRM = []
        for n, uno in enumerate(tutor.list_rm):
            liRM.append((uno[1], n))

        self.cbRM, self.lbRM = QTUtil2.comboBoxLB(self, liRM, liRM[0][1],
                                                  _("Moves analyzed"))
        self.connect(self.cbRM, QtCore.SIGNAL("currentIndexChanged (int)"),
                     tutor.cambiadoRM)
        lyRM = Colocacion.H().control(self.lbRM).control(self.cbRM)

        lyTutor = Colocacion.V().relleno().control(
            self.lbTutorPuntuacion).relleno()
        gbTutor = Controles.GB(self, _("Tutor's suggestion"),
                               lyTutor).ponFuente(f).alinCentrado()
        if siPuntos:
            gbTutor.conectar(self.elegirTutor)
            self.lbTutorPuntuacion.setEnabled(True)

        lyUsuario = Colocacion.V().relleno().control(
            self.lbUsuarioPuntuacion).relleno()
        gbUsuario = (Controles.GB(
            self, _("Your move"),
            lyUsuario).ponFuente(f).alinCentrado().conectar(
                self.elegirUsuario))
        self.lbUsuarioPuntuacion.setEnabled(True)
        btLibros = Controles.PB(self, _("Consult a book"),
                                self.consultaLibro).ponPlano(False)

        if siRival:
            lyRival = Colocacion.V().relleno().control(
                self.lbRivalPuntuacion).relleno()
            gbRival = Controles.GB(self, _("Opponent's prediction"),
                                   lyRival).ponFuente(f).alinCentrado()

        if siAperturas:
            lyAperturas = Colocacion.V().relleno().control(
                self.cbAperturas).relleno()
            gbAperturas = Controles.GB(self, _("Opening"),
                                       lyAperturas).alinCentrado().ponFuente(f)
            if siPuntos:
                gbAperturas.conectar(self.elegirApertura)
            self.cbAperturas.setEnabled(True)
            self.tutor.cambiarApertura(0)

        dicVista = {
            POS_TUTOR_HORIZONTAL: ((0, 1), (0, 2)),
            POS_TUTOR_HORIZONTAL_2_1: ((0, 1), (4, 0)),
            POS_TUTOR_HORIZONTAL_1_2: ((4, 0), (4, 1)),
            POS_TUTOR_VERTICAL: ((4, 0), (8, 0)),
        }

        usu, riv = dicVista[self.x_tutor_view]

        fu, cu = usu
        fr, cr = riv

        layout = Colocacion.G()
        layout.controlc(gbTutor, 0, 0).controlc(self.tableroTutor, 1,
                                                0).otro(lytbTutor, 2,
                                                        0).otroc(lyRM, 3, 0)
        layout.controlc(gbUsuario, fu,
                        cu).controlc(self.tableroUsuario, fu + 1, cu).otro(
                            lytbUsuario, fu + 2,
                            cu).controlc(btLibros, fu + 3, cu)
        if siRival:
            layout.controlc(gbRival, fr,
                            cr).controlc(self.tableroRival, fr + 1,
                                         cr).otro(lytbRival, fr + 2, cr)
        elif siAperturas:
            layout.controlc(gbAperturas, fr,
                            cr).controlc(self.tableroApertura, fr + 1,
                                         cr).otro(lytbApertura, fr + 2, cr)

        layout.margen(8)

        self.setLayout(layout)

        self.restore_video(siTam=False)
Example #9
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()
Example #10
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 __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)
    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()
Example #13
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()
Example #14
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()
Example #15
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)