Exemple #1
0
    def __init__(self, parent):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        icoP = VarGen.todasPiezas.iconoDefecto("P")
        icop = VarGen.todasPiezas.iconoDefecto("p")
        self.setWindowTitle(_("Choose Color"))
        self.setWindowIcon(icoP)

        btBlancas = Controles.PB(self, "", rutina=self.blancas,
                                 plano=False).ponIcono(icoP, tamIcon=64)
        btNegras = Controles.PB(self, "", rutina=self.negras,
                                plano=False).ponIcono(icop, tamIcon=64)

        # Tiempo
        self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB(
            self, 5, 0, 999, maxTam=50, etiqueta=_("Total minutes"))
        self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB(
            self, 10, 0, 999, maxTam=50, etiqueta=_("Seconds added per move"))
        ly = Colocacion.G()
        ly.controld(self.lbMinutos, 0, 0).control(self.edMinutos, 0, 1)
        ly.controld(self.lbSegundos, 0, 2).control(self.edSegundos, 0, 3)
        self.gbT = Controles.GB(self, _("Time"),
                                ly).conectar(self.cambiaTiempo)
        self.cambiaTiempo()

        self.color = None

        ly = Colocacion.H().control(btBlancas).control(btNegras)
        ly.margen(10)
        layout = Colocacion.V().otro(ly).espacio(10).control(
            self.gbT).margen(5)
        self.setLayout(layout)
Exemple #2
0
    def __init__(self, wowner, procesador, album):

        self.album = album
        titulo = album.name
        QTVarios.WDialogo.__init__(self, wowner, titulo, album.icono(), "albumes")

        self.configuration = procesador.configuration

        ncromos = len(album)
        dicT = {6: 3, 8: 4, 10: 5, 12: 6, 14: 7, 16: 8, 18: 6, 20: 5, 24: 6, 28: 7, 32: 8, 40: 8}
        divisor = dicT.get(ncromos, 6)

        layout = Colocacion.G()

        pte = False

        icoCaracol = Iconos.Caracol()

        for pos in range(ncromos):
            cromo = album.get_cromo(pos)
            if not cromo.hecho:
                pte = True

            pb = Controles.PB(self, "", rutina=self.pulsado, plano=False)
            pb.setFixedSize(110, 110)
            pb.key = cromo

            if cromo.hecho:
                icono = cromo.icono()
                pixmap = icono.pixmap(64, 64)
                icono.addPixmap(pixmap, QtGui.QIcon.Disabled)
                pb.setEnabled(False)
            else:
                icono = icoCaracol

            pb.ponIcono(icono, 64)

            lb = Controles.LB(self, cromo.name)
            lb.ponTipoLetra(puntos=10, peso=75)
            row = pos // divisor
            col = pos % divisor
            layout.controlc(pb, row * 2, col)
            layout.controlc(lb, row * 2 + 1, col)

        mensaje = _("Select a slot to play against and get its image if you win") if pte else ""
        lb = Controles.LB(self, mensaje)

        pbExit = Controles.PB(self, _("Close"), self.quit, plano=False).ponIcono(Iconos.MainMenu())
        lyP = Colocacion.H().relleno().control(lb).relleno().control(pbExit)
        if not pte:
            pbRebuild = Controles.PB(self, _("Rebuild this album"), self.rebuild, plano=False).ponIcono(Iconos.Delete())
            lyP.control(pbRebuild)

        lyT = Colocacion.V().otro(layout).otro(lyP)

        self.setLayout(lyT)

        self.restore_video(siTam=False)

        self.resultado = None, None
Exemple #3
0
    def __init__(self, owner, lista, tablero, tam=None, margen=None):
        QtGui.QWidget.__init__(self)

        self.owner = owner
        # self.tablero = tablero = owner.tablero

        if tam is None:
            tam = tablero.anchoPieza

        liLB = []
        for fila, valor in enumerate(lista.split(";")):
            for columna, pieza in enumerate(valor.split(",")):
                lb = LBPieza(self, pieza, tablero, tam)
                liLB.append((lb, fila, columna))

        layout = Colocacion.G()
        for lb, fila, columna in liLB:
            layout.control(lb, fila, columna)
        if margen is not None:
            layout.margen(margen)

            # l1 = Colocacion.H().otro(layout).relleno()
            # if margen:
            # l1.margen(margen)
            # l2 = Colocacion.V().otro(l1)
            # if margen:
            # l2.margen(margen)

        self.setLayout(layout)
Exemple #4
0
    def __init__(self,
                 parent,
                 mensaje,
                 siCancelar,
                 siMuestraYa,
                 opacity,
                 posicion,
                 fixedSize,
                 titCancelar,
                 background,
                 pmImagen=None,
                 puntos=12,
                 conImagen=True):

        super(MensEspera, self).__init__(parent)

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

        self.owner = parent

        self.posicion = posicion
        self.siCancelado = False

        if posicion == "tb":
            fixedSize = parent.width()

        self.lb = lb = Controles.LB(parent, resalta(mensaje)).ponFuente(
            Controles.TipoLetra(puntos=puntos))
        if fixedSize is not None:
            lb.ponWrap().anchoFijo(fixedSize - 60)

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

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

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

        if fixedSize:
            self.setFixedWidth(fixedSize)

        self.setWindowOpacity(opacity)
        if siMuestraYa:
            self.muestra()
Exemple #5
0
    def __init__(self, owner, lista, board, tam=None, margen=None):
        QtWidgets.QWidget.__init__(self)

        self.owner = owner
        # self.board = board = owner.board

        if tam is None:
            tam = board.anchoPieza

        liLB = []
        for row, valor in enumerate(lista.split(";")):
            for column, pieza in enumerate(valor.split(",")):
                lb = LBPieza(self, pieza, board, tam)
                liLB.append((lb, row, column))

        layout = Colocacion.G()
        for lb, row, column in liLB:
            layout.control(lb, row, column)
        if margen is not None:
            layout.margen(margen)

            # l1 = Colocacion.H().otro(layout).relleno()
            # if margen:
            # l1.margen(margen)
            # l2 = Colocacion.V().otro(l1)
            # if margen:
            # l2.margen(margen)

        self.setLayout(layout)
Exemple #6
0
    def __init__(self, parent, minMinutos, minSegundos, maxMinutos,
                 maxSegundos):
        super(Tiempo, self).__init__(parent)
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.setWindowTitle(_("Time"))
        self.setWindowIcon(Iconos.MoverTiempo())

        tb = QTUtil2.tbAcceptCancel(self)

        # Tiempo
        self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB(
            self,
            10,
            minMinutos,
            maxMinutos,
            maxTam=50,
            etiqueta=_("Total minutes"))
        self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB(
            self,
            0,
            minSegundos,
            maxSegundos,
            maxTam=50,
            etiqueta=_("Seconds added per move"))

        # # Tiempo
        lyT = Colocacion.G()
        lyT.controld(self.lbMinutos, 0, 0).control(self.edMinutos, 0, 1)
        lyT.controld(self.lbSegundos, 1, 0).control(self.edSegundos, 1,
                                                    1).margen(20)

        ly = Colocacion.V().control(tb).espacio(20).otro(lyT)
        self.setLayout(ly)
Exemple #7
0
    def __init__(self, owner):
        QtWidgets.QWidget.__init__(self)

        numElem, ancho = 10, 32
        self.owner = owner
        self.ancho = ancho
        self.seleccionada = None

        layout = Colocacion.G()
        layout.setSpacing(2)
        layout.setContentsMargins(0, 0, 0, 0)
        self.liLB = []
        self.liLB_F = []
        pm = Iconos.pmEnBlanco()
        if ancho != 32:
            pm = pm.scaled(ancho, ancho)
        self.pmVacio = pm
        color = "lightgray"
        for n in range(numElem):
            lb_f = Controles.LB("F%d" % (n + 1, ))
            lb_f.setStyleSheet("*{ border: 1px solid %s; background: %s;}" %
                               (color, color))
            lb_f.anchoFijo(24)
            lb_f.altoFijo(36)
            lb_f.alinCentrado()
            layout.controlc(lb_f, n, 1)
            if n == 9:
                lb = SelectUna(self,
                               Iconos.pmTexto().scaled(ancho, ancho), True)
                lb.addText = True
            else:
                lb = SelectUna(self, self.pmVacio, False)

            lb_f.mousePressEvent = lb.mousePressEvent
            self.liLB.append(lb)
            self.liLB_F.append(lb_f)
            layout.controlc(lb, n, 0)
        lb_f = Controles.LB("%s F10\n%s" % (_("CTRL"), _("Changes")))
        lb_f.setStyleSheet("*{ border: 1px solid %s; background: %s;}" %
                           (color, color))
        lb_f.anchoFijo(64)
        lb_f.altoFijo(36)
        lb_f.alinCentrado()
        self.lb_change_graphics = lb_f
        lb_f.mousePressEvent = self.mousePressEventGraphics
        layout.controlc(lb_f, numElem, 0, 1, 2)
        self.dicDatos = collections.OrderedDict()
        self.setLayout(layout)

        st = "*{ border: 1px solid %s; background:%s;}"
        self.style_f = {
            True: st % ("orange", "orange"),
            False: st % ("lightgray", "lightgray")
        }

        self.liTipos = ((_("Arrows"), Iconos.Flechas(), self.owner.flechas),
                        (_("Boxes"), Iconos.Marcos(), self.owner.marcos),
                        (_("Images"), Iconos.SVGs(), self.owner.svgs),
                        (_("Markers"), Iconos.Markers(), self.owner.markers))
    def __init__(self, wParent):

        QtGui.QDialog.__init__(self, wParent)

        self.wParent = wParent

        self.fichero = ""

        self.setWindowTitle(_("Create a new book"))
        self.setWindowIcon(Iconos.Libros())
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)

        f = Controles.TipoLetra(puntos=9, peso=75)

        self.configuracion = VarGen.configuracion
        fvar = self.configuracion.ficheroBooks
        self.listaLibros = Books.ListaLibros()
        self.listaLibros.recuperaVar(fvar)

        lbFichero = Controles.LB(self, _("Book to create") + ":").ponFuente(f)
        self.btFichero = Controles.PB(self, "", self.buscaFichero,
                                      False).anchoMinimo(450).ponFuente(f)
        lbMaxPly = Controles.LB(self,
                                _("Maximum no. half moves (ply)") +
                                ":").ponFuente(f)
        self.sbMaxPly = Controles.SB(self, 0, 0, 999).tamMaximo(50)
        lbMinGame = Controles.LB(self,
                                 _("Minimum number of games") +
                                 ":").ponFuente(f)
        self.sbMinGame = Controles.SB(self, 3, 1, 999).tamMaximo(50)
        lbMinScore = Controles.LB(self, _("Minimum score") + ":").ponFuente(f)
        self.sbMinScore = Controles.SB(self, 0, 0, 100).tamMaximo(50)
        self.chbOnlyWhite = Controles.CHB(self, _("White only"),
                                          False).ponFuente(f)
        self.chbOnlyBlack = Controles.CHB(self, _("Black only"),
                                          False).ponFuente(f)
        self.chbUniform = Controles.CHB(self, _("Uniform distribution"),
                                        False).ponFuente(f)

        lyf = Colocacion.H().control(lbFichero).control(self.btFichero)
        ly = Colocacion.G().margen(15)
        ly.otroc(lyf, 0, 0, 1, 2)
        ly.controld(lbMaxPly, 1, 0).control(self.sbMaxPly, 1, 1)
        ly.controld(lbMinGame, 2, 0).control(self.sbMinGame, 2, 1)
        ly.controld(lbMinScore, 3, 0).control(self.sbMinScore, 3, 1)
        ly.controlc(self.chbOnlyWhite, 4, 0, 1, 2)
        ly.controlc(self.chbOnlyBlack, 5, 0, 1, 2)
        ly.controlc(self.chbUniform, 6, 0, 1, 2)

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

        # Layout
        layout = Colocacion.V().control(tb).otro(ly).margen(3)
        self.setLayout(layout)
Exemple #9
0
    def __init__(self, owner, db_coordinates, is_white):

        QTVarios.WDialogo.__init__(self, owner, _("Coordinates"),
                                   Iconos.Blocks(), "runcoordinatesbasic")

        self.configuration = Code.configuration
        self.is_white = is_white
        self.db_coordinates = db_coordinates
        self.coordinates = None
        self.current_score = 0
        self.working = False
        self.time_ini = None

        conf_board = self.configuration.config_board(
            "RUNCOORDINATESBASIC", self.configuration.size_base())

        self.board = Board.BoardEstaticoMensaje(self, conf_board, None, 0.6)
        self.board.crea()
        self.board.bloqueaRotacion(True)
        self.cp_initial = Position.Position()
        self.cp_initial.set_pos_initial()
        self.board.ponerPiezasAbajo(self.is_white)
        self.board.set_position(self.cp_initial)

        font = Controles.TipoLetra(puntos=26, peso=500)

        lb_score_k = Controles.LB(self, _("Score")).ponFuente(font)
        self.lb_score = Controles.LB(self).ponFuente(font)

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Begin"), Iconos.Empezar(), self.begin),
            (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir),
        )
        self.tb = QTVarios.LCTB(self, li_acciones)
        self.show_tb(self.terminar, self.begin)

        ly_info = Colocacion.G()
        ly_info.controlc(lb_score_k, 0, 0).controlc(self.lb_score, 1, 0)

        ly_right = Colocacion.V().control(
            self.tb).relleno().otro(ly_info).relleno()

        w = QtWidgets.QWidget(self)
        w.setLayout(ly_right)
        w.setMinimumWidth(240)

        ly_center = Colocacion.H().control(self.board).control(w).margen(3)

        self.setLayout(ly_center)

        self.restore_video()
        self.adjustSize()
    def __init__(self, parent, titulo, siErroneos, icono):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)

        self.setWindowTitle(titulo)
        self.setWindowIcon(icono)
        self.fontB = f = Controles.TipoLetra(puntos=10, peso=75)

        self.siErroneos = siErroneos

        self.siCancelado = False

        lbRotLeidos = Controles.LB(self, _("Games read") + ":").ponFuente(f)
        self.lbLeidos = Controles.LB(self, "0").ponFuente(f)

        if siErroneos:
            lbRotErroneos = Controles.LB(self,
                                         _("Erroneous") + ":").ponFuente(f)
            self.lbErroneos = Controles.LB(self, "0").ponFuente(f)

        self.lbRotDuplicados = Controles.LB(self,
                                            _("Duplicated") + ":").ponFuente(f)
        self.lbDuplicados = Controles.LB(self, "0").ponFuente(f)

        self.lbRotImportados = lbRotImportados = Controles.LB(
            self,
            _("Imported") + ":").ponFuente(f)
        self.lbImportados = Controles.LB(self, "0").ponFuente(f)

        self.btCancelarSeguir = Controles.PB(self,
                                             _("Cancel"),
                                             self.cancelar,
                                             plano=False).ponIcono(
                                                 Iconos.Delete())

        # Tiempo
        ly = Colocacion.G().margen(20)
        ly.controld(lbRotLeidos, 0, 0).controld(self.lbLeidos, 0, 1)
        if siErroneos:
            ly.controld(lbRotErroneos, 1, 0).controld(self.lbErroneos, 1, 1)
        ly.controld(self.lbRotDuplicados, 2,
                    0).controld(self.lbDuplicados, 2, 1)
        ly.controld(lbRotImportados, 3, 0).controld(self.lbImportados, 3, 1)

        lyBT = Colocacion.H().relleno().control(self.btCancelarSeguir)

        layout = Colocacion.V()
        layout.otro(ly)
        layout.espacio(20)
        layout.otro(lyBT)

        self.setLayout(layout)
    def __init__(self, oBase, ventana, segundosPensando, siBlancas, cPuntos, maxRecursion):
        super(WAnalisisVariantes, self).__init__(ventana)

        self.oBase = oBase

        # Creamos los controles
        self.setWindowTitle(_("Variants"))

        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint  )
        self.setWindowIcon(Iconos.Tutor())

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

        lbPuntuacionAnterior = Controles.LB(self, cPuntos).alinCentrado().ponFuente(flb)
        self.lbPuntuacionNueva = Controles.LB(self).alinCentrado().ponFuente(flb)

        confTablero = VarGen.configuracion.confTablero("ANALISISVARIANTES", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(siBlancas)

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

        btTerminar = Controles.PB(self, _("Close"), self.close).ponPlano(False)
        btReset = Controles.PB(self, _("Another change"), oBase.reset).ponIcono(Iconos.MoverLibre()).ponPlano(False)
        liMasAcciones = (("FEN:%s" % _("Copy to clipboard"), "MoverFEN", Iconos.Clip()),)
        lytbTutor, self.tb = QTVarios.lyBotonesMovimiento(self, "", siLibre=maxRecursion > 0,
                                                          liMasAcciones=liMasAcciones)
        self.maxRecursion = maxRecursion - 1

        self.segundos, lbSegundos = QTUtil2.spinBoxLB(self, segundosPensando, 1, 999, maxTam=40, etiqueta=_("Second(s)"))

        # Creamos los layouts

        lyVariacion = Colocacion.V().control(lbPuntuacionAnterior).control(self.tablero)
        gbVariacion = Controles.GB(self, _("Proposed change"), lyVariacion).ponFuente(f).alinCentrado()

        lyTutor = Colocacion.V().control(self.lbPuntuacionNueva).control(self.tableroT)
        gbTutor = Controles.GB(self, _("Tutor's prediction"), lyTutor).ponFuente(f).alinCentrado()

        lyBT = Colocacion.H().control(btTerminar).control(btReset).relleno().control(lbSegundos).control(self.segundos)

        layout = Colocacion.G().control(gbVariacion, 0, 0).control(gbTutor, 0, 1)
        layout.otro(lyBT, 1, 0).otro(lytbTutor, 1, 1)

        self.setLayout(layout)

        self.move(ventana.x() + 20, ventana.y() + 20)
Exemple #12
0
    def __init__(self, parent, mens):
        QtGui.QDialog.__init__(self, parent)

        self.setWindowTitle(_("Fide-Elo"))
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)
        self.setWindowIcon(Iconos.Fide())
        self.setStyleSheet("QDialog, QLabel { background: #E9E9E9 }")

        lbm = Controles.LB(self, "<big><b>%s</b></big>" % mens)
        self.bt = Controles.PB(self, _("One moment please..."), rutina=self.final, plano=True)
        self.bt.setDisabled(True)
        self.siFinalizado = False

        ly = Colocacion.G().control(lbm, 0, 0).controlc(self.bt, 1, 0)

        ly.margen(20)

        self.setLayout(ly)
Exemple #13
0
    def __init__(self, owner, procesador):

        title = _("In one line")
        titulo = _("Turn on the lights") + ": " + title
        extparam = "tolconfoneline"
        icono = Iconos.TOLchange()
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.tol = TurnOnLights.read_oneline_tol()
        self.procesador = procesador

        lbNumPos = Controles.LB2P(self, _("Number of positions"))
        liBlocks = [(str(x), x) for x in range(6, 60, 6)]
        self.cbNumPos = Controles.CB(self, liBlocks, self.tol.num_pos)

        lbtipo = Controles.LB2P(self, _("Mode"))
        liTipos = [(_("Calculation mode"), True), (_("Memory mode"), False)]
        self.cbTipo = Controles.CB(self, liTipos, self.tol.calculation_mode)

        lbfile = Controles.LB2P(self, _("File"))
        pbfile = Controles.PB(self, "", self.newfile).ponIcono(Iconos.Buscar())
        self.lbshowfile = Controles.LB(self, self.tol.fns)
        lyfile = Colocacion.H().control(pbfile).control(
            self.lbshowfile).relleno(1)

        self.chbauto = Controles.CHB(self, _("Redo each day automatically"),
                                     self.tol.auto_day)

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

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.G()
        ly.controld(lbNumPos, 1, 0).control(self.cbNumPos, 1, 1)
        ly.controld(lbtipo, 2, 0).control(self.cbTipo, 2, 1)
        ly.controld(lbfile, 3, 0).otro(lyfile, 3, 1)
        ly.control(self.chbauto, 4, 0, 1, 2)

        layout = Colocacion.V().control(tb).espacio(10).otro(ly)

        self.setLayout(layout)

        self.recuperarVideo(siTam=True)
Exemple #14
0
def genOpcionesME(owner, motorExterno):
    fil = 0
    col = 0
    layout = Colocacion.G()
    for opcion in motorExterno.liOpciones:
        tipo = opcion.tipo
        lb = Controles.LB(owner, opcion.nombre + ":").alinDerecha()
        if tipo == "spin":
            control = QTUtil2.spinBoxLB(owner,
                                        opcion.valor,
                                        opcion.min,
                                        opcion.max,
                                        maxTam=50 if opcion.max < 1000 else 80)
            lb.ponTexto("%s [%d-%d] :" %
                        (opcion.nombre, opcion.min, opcion.max))
        elif tipo == "check":
            control = Controles.CHB(owner, " ", opcion.valor)
        elif tipo == "combo":
            liVars = []
            for var in opcion.liVars:
                liVars.append((var, var))
            control = Controles.CB(owner, liVars, opcion.valor)
        elif tipo == "string":
            control = Controles.ED(
                owner, opcion.valor
            )  # todo check si cambiar self por None no causa problemas
        elif tipo == "button":
            control = Controles.CHB(owner, " ", opcion.valor)

        layout.controld(lb, fil, col).control(control, fil, col + 1)
        col += 2
        if col > 2:
            fil += 1
            col = 0
        opcion.control = control

    w = QtGui.QWidget(owner)
    w.setLayout(layout)
    scrollArea = QtGui.QScrollArea()
    scrollArea.setBackgroundRole(QtGui.QPalette.Light)
    scrollArea.setWidget(w)
    scrollArea.setWidgetResizable(True)

    return scrollArea
Exemple #15
0
    def __init__(self, parent, mens):
        QtGui.QDialog.__init__(self, parent)

        self.setWindowTitle(_("Result"))
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)
        self.setWindowIcon(Iconos.Fide())
        self.setStyleSheet("QDialog, QLabel { background: #E9E9E9 }")

        lbm = Controles.LB(self, "<big><b>%s</b></big>" % mens)
        self.bt = Controles.PB(self, _("Continue"), rutina=self.accept, plano=False)

        ly = Colocacion.G().control(lbm, 0, 0).controlc(self.bt, 1, 0)

        ly.margen(20)

        self.setLayout(ly)

        w = parent.base.pgn
        self.move(w.x() + w.width() / 2 - self.width() / 2, w.y() + w.height() / 2 - self.height() / 2)
Exemple #16
0
def wgen_options_engine(owner, engine):
    fil = 0
    col = 0
    layout = Colocacion.G()
    for opcion in engine.li_uci_options_editable():
        tipo = opcion.tipo
        lb = Controles.LB(owner, opcion.name + ":").align_right()
        if tipo == "spin":
            control = QTUtil2.spinBoxLB(
                owner,
                opcion.valor,
                opcion.minimo,
                opcion.maximo,
                maxTam=50 if opcion.maximo < 1000 else 80)
            lb.set_text("%s [%d-%d] :" %
                        (opcion.name, opcion.minimo, opcion.maximo))
        elif tipo == "check":
            control = Controles.CHB(owner, " ", opcion.valor)
        elif tipo == "combo":
            li_vars = []
            for var in opcion.li_vars:
                li_vars.append((var, var))
            control = Controles.CB(owner, li_vars, opcion.valor)
        elif tipo == "string":
            control = Controles.ED(owner, opcion.valor)
        # elif tipo == "button":
        #     control = Controles.CHB(owner, " ", opcion.valor)

        layout.controld(lb, fil, col).control(control, fil, col + 1)
        col += 2
        if col > 2:
            fil += 1
            col = 0
        opcion.control = control

    w = QtWidgets.QWidget(owner)
    w.setLayout(layout)
    scrollArea = QtWidgets.QScrollArea()
    scrollArea.setBackgroundRole(QtGui.QPalette.Light)
    scrollArea.setWidget(w)
    scrollArea.setWidgetResizable(True)

    return scrollArea
    def __init__(self, owner, liElem, ancho, margen=None):
        QtWidgets.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 row, numElem in enumerate(liElem):
            for n in range(numElem):
                lb = DragUna(self, self.pmVacio)
                self.liLB.append(lb)
                layout.control(lb, row, n)
        if margen:
            layout.margen(margen)
        self.dic_data = collections.OrderedDict()
        self.setLayout(layout)
Exemple #18
0
    def __init__(self, liUsuarios):
        QtWidgets.QDialog.__init__(self, None)
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)

        self.setWindowTitle(Code.lucas_chess)
        self.setWindowIcon(Iconos.Aplicacion64())

        self.setFont(Controles.TipoLetra(puntos=14))

        self.liUsuarios = liUsuarios

        li_options = [(usuario.name, nusuario)
                      for nusuario, usuario in enumerate(liUsuarios)]
        lbU = Controles.LB(self, _("User") + ":")
        self.cbU = Controles.CB(self, li_options, liUsuarios[0])

        lbP = Controles.LB(self, _("Password") + ":")
        self.edP = Controles.ED(self).password()

        btaceptar = Controles.PB(self,
                                 _("Accept"),
                                 rutina=self.accept,
                                 plano=False)
        btcancelar = Controles.PB(self,
                                  _("Cancel"),
                                  rutina=self.reject,
                                  plano=False)

        ly = Colocacion.G()
        ly.controld(lbU, 0, 0).control(self.cbU, 0, 1)
        ly.controld(lbP, 1, 0).control(self.edP, 1, 1)

        lybt = Colocacion.H().relleno().control(btaceptar).espacio(10).control(
            btcancelar)

        layout = Colocacion.V().otro(ly).espacio(10).otro(lybt).margen(10)

        self.setLayout(layout)
        self.edP.setFocus()
Exemple #19
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)
Exemple #20
0
    def __init__(self, parent):
        QtWidgets.QDialog.__init__(self, parent)
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)

        icoP = Code.todasPiezas.iconoDefecto("K")
        icop = Code.todasPiezas.iconoDefecto("k")
        self.setWindowTitle(_("Choose Color"))
        self.setWindowIcon(icoP)
        self.key_saved = "BLANCASNEGRASTIEMPO"

        btBlancas = Controles.PB(self, "", rutina=self.blancas,
                                 plano=False).ponIcono(icoP, icon_size=64)
        btNegras = Controles.PB(self, "", rutina=self.negras,
                                plano=False).ponIcono(icop, icon_size=64)

        # Tiempo
        self.edMinutos, self.lbMinutos = QTUtil2.spinBoxLB(
            self, 10, 0, 999, maxTam=50, etiqueta=_("Total minutes"))
        self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB(
            self, 0, 0, 999, maxTam=50, etiqueta=_("Seconds added per move"))
        ly = Colocacion.G()
        ly.controld(self.lbMinutos, 0, 0).control(self.edMinutos, 0, 1)
        ly.controld(self.lbSegundos, 0, 2).control(self.edSegundos, 0, 3)
        self.gbT = Controles.GB(self, _("Time"),
                                ly).to_connect(self.change_time)

        self.chb_fastmoves = Controles.CHB(self, _("Fast moves"), False)

        self.color = None

        ly = Colocacion.H().control(btBlancas).control(btNegras)
        ly.margen(10)
        layout = Colocacion.V().otro(ly).espacio(10).control(self.gbT).control(
            self.chb_fastmoves).margen(5)
        self.setLayout(layout)

        self.read_saved()
Exemple #21
0
    def __init__(self, liUsuarios):
        QtGui.QDialog.__init__(self, None)
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)

        main = liUsuarios[0]

        self.setWindowTitle(main.trlucas)
        self.setWindowIcon(Iconos.Usuarios())

        liOpciones = [(usuario.nombre, usuario) for usuario in liUsuarios]
        lbU = Controles.LB(self, main.trusuario + ":")
        self.cbU = Controles.CB(self, liOpciones, main)

        lbP = Controles.LB(self, main.trpassword + ":")
        self.edP = Controles.ED(self).password()

        btaceptar = Controles.PB(self,
                                 main.traceptar,
                                 rutina=self.accept,
                                 plano=False)
        btcancelar = Controles.PB(self,
                                  main.trcancelar,
                                  rutina=self.reject,
                                  plano=False)

        ly = Colocacion.G()
        ly.controld(lbU, 0, 0).control(self.cbU, 0, 1)
        ly.controld(lbP, 1, 0).control(self.edP, 1, 1)

        lybt = Colocacion.H().relleno().control(btaceptar).espacio(10).control(
            btcancelar)

        layout = Colocacion.V().otro(ly).espacio(10).otro(lybt).margen(10)

        self.setLayout(layout)
        self.edP.setFocus()
Exemple #22
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.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

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

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

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

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

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

        # # Rival
        self.rival = configuracion.x_rival_inicial
        self.rivalTipo = SelectEngines.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, ADJUST_BETTER).capturaCambiado(self.ajustesCambiado)
        lbAjustarRival = Controles.LB2P(self, _("Set strength"))
        self.btAjustarRival = Controles.PB(self, "", self.cambiaPersonalidades, plano=False).ponIcono(
            Iconos.Nuevo(), tamIcon=16
        )
        self.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)

        # #Color
        hAC = Colocacion.H().control(gbColor)

        # 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(self.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()
Exemple #23
0
 def nuevoG():
     ly_g = Colocacion.G()
     ly_g.filaActual = 0
     ly_g.setMargin(10)
     return ly_g
Exemple #24
0
    def __init__(self, procesador, titulo, save_at_end):

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

        font = Controles.TipoLetra(puntos=procesador.configuracion.x_menu_points)

        self.save_at_end = save_at_end

        self.setFont(font)

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

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

        self.motores = SelectEngines.SelectEngines(self.configuracion)

        # Toolbar
        li_acciones = [
            (_("Accept"), Iconos.Aceptar(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("Configurations"), Iconos.Configurar(), self.configuraciones),
            None,
        ]
        tb = QTVarios.LCTB(self, li_acciones)

        # Tab
        tab = Controles.Tab()
        tab.dispatchChange(self.cambiada_tab)

        self.tab_advanced = 4  # está en la posición 4
        self.tab_advanced_active = (
            False
        )  # Para no tener que leer las opciones uci to_sq que no sean necesarias, afecta a gridNumDatos

        def nueva_tab(layout, titulo):
            ly = Colocacion.V()
            ly.otro(layout)
            ly.relleno()
            w = QtWidgets.QWidget(self)
            w.setLayout(ly)
            w.setFont(font)
            tab.nuevaTab(w, titulo)

        def nuevoG():
            ly_g = Colocacion.G()
            ly_g.filaActual = 0
            ly_g.setMargin(10)
            return ly_g

        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;
                padding: 18px;
                margin-top: 5ex; /* leave space at the top for the title */
            }
            QGroupBox::title {
                subcontrol-origin: margin;
                subcontrol-position: top left; /* position at the top center */
                padding: 8px;
                border: 1px solid gray;
             }
        """

        def _label(ly_g, txt, xlayout, rutinaCHB=None, siCheck: object = False):
            groupbox = Controles.GB(self, txt, xlayout)
            if rutinaCHB:
                groupbox.conectar(rutinaCHB)
            elif siCheck:
                groupbox.setCheckable(True)
                groupbox.setChecked(False)

            groupbox.setStyleSheet(gbStyle)
            groupbox.setMinimumWidth(640)
            groupbox.setFont(font)
            ly_g.controlc(groupbox, ly_g.filaActual, 0)
            ly_g.filaActual += 1
            return groupbox

        # ##################################################################################################################################
        # TAB General
        # ##################################################################################################################################

        lyG = nuevoG()

        # # Motores

        # ## Rival
        self.rival = self.procesador.XTutor().confMotor
        self.rivalTipo = SelectEngines.INTERNO
        self.btRival = Controles.PB(self, "", self.cambiaRival, plano=False).ponFuente(font).altoFijo(48)

        lbTiempoSegundosR = Controles.LB2P(self, _("Fixed time in seconds")).ponFuente(font)
        self.edRtiempo = (
            Controles.ED(self).tipoFloat().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoTiempo)
        )
        bt_cancelar_tiempo = Controles.PB(self, "", rutina=self.cancelar_tiempo).ponIcono(Iconos.S_Cancelar())
        ly_tiempo = Colocacion.H().control(self.edRtiempo).control(bt_cancelar_tiempo).relleno(1)

        lb_depth = Controles.LB2P(self, _("Fixed depth")).ponFuente(font)
        self.edRdepth = Controles.ED(self).tipoInt().anchoMaximo(50).ponFuente(font).capturaCambiado(self.cambiadoDepth)
        bt_cancelar_depth = Controles.PB(self, "", rutina=self.cancelar_depth).ponIcono(Iconos.S_Cancelar())
        ly_depth = Colocacion.H().control(self.edRdepth).control(bt_cancelar_depth).relleno(1)

        ly = Colocacion.G()
        ly.controld(lbTiempoSegundosR, 0, 0).otro(ly_tiempo, 0, 1)
        ly.controld(lb_depth, 1, 0).otro(ly_depth, 1, 1)
        self.gb_thinks = Controles.GB(self, _("Limits of engine thinking"), ly)
        self.gb_thinks.setStyleSheet(
            """
            QGroupBox {
                font: bold %d;
                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;
                padding: 18px;
                margin-top: 5ex; /* leave space at the top for the title */
            }
            QGroupBox::title {
                subcontrol-position: top center; /* position at the top center */
                padding: 8px;
                border: 1px solid gray;
             }
        """
            % procesador.configuracion.x_menu_points
        )
        lyV = Colocacion.V().espacio(20).control(self.btRival).espacio(20).control(self.gb_thinks)

        _label(lyG, _("Opponent"), lyV)

        # # Color
        self.rbBlancas = Controles.RB(self, "").activa()
        self.rbBlancas.setIcon(Iconos.PeonBlanco())
        self.rbBlancas.setIconSize(QtCore.QSize(32, 32))
        self.rbNegras = Controles.RB(self, "")
        self.rbNegras.setIcon(Iconos.PeonNegro())
        self.rbNegras.setIconSize(QtCore.QSize(32, 32))
        self.rbRandom = Controles.RB(self, _("Random"))
        self.rbRandom.setFont(Controles.TipoLetra(puntos=16))
        hbox = (
            Colocacion.H()
            .relleno()
            .control(self.rbBlancas)
            .espacio(30)
            .control(self.rbNegras)
            .espacio(30)
            .control(self.rbRandom)
            .relleno()
        )
        _label(lyG, _("Side you play with"), hbox)

        nueva_tab(lyG, _("Basic configuration"))

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

        self.chbTakeback = Controles.CHB(
            self, _("Option takeback activated"), True
        ).ponFuente(font)

        # # Tutor
        lbAyudas = Controles.LB2P(self, _("Available hints")).ponFuente(font)
        liAyudas = [(_("Maximum"), 999)]
        for i in range(1, 21):
            liAyudas.append((str(i), i))
        for i in range(25, 51, 5):
            liAyudas.append((str(i), i))
        self.cbAyudas = Controles.CB(self, liAyudas, 999).ponFuente(font)
        self.chbChance = Controles.CHB(self, _("Second chance"), True).ponFuente(font)
        btTutorChange = (
            Controles.PB(self, _("Tutor change"), self.tutorChange, plano=False)
            .ponIcono(Iconos.Tutor(), tamIcon=16)
            .ponFuente(font)
        )

        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))
        lbThoughtTt = Controles.LB(self, _("It is showed") + ":").ponFuente(font)
        self.cbThoughtTt = Controles.CB(self, liThinks, -1).ponFuente(font)

        self.chbContinueTt = Controles.CHB(self, _("The tutor thinks while you think"), True).ponFuente(font)

        lbBoxHeight = Controles.LB2P(self, _("Box height")).ponFuente(font)
        self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font)

        lbArrows = Controles.LB2P(self, _("Arrows with the best moves")).ponFuente(font)
        self.sbArrowsTt = Controles.SB(self, 3, 0, 999).tamMaximo(50).ponFuente(font)

        lyT1 = Colocacion.H().control(lbAyudas).control(self.cbAyudas).relleno()
        lyT1.control(self.chbChance).relleno().control(btTutorChange)
        lyT2 = Colocacion.H().control(self.chbContinueTt).relleno()
        lyT2.control(lbBoxHeight).control(self.sbBoxHeight).relleno()
        lyT3 = Colocacion.H().control(lbThoughtTt).control(self.cbThoughtTt).relleno()
        lyT3.control(lbArrows).control(self.sbArrowsTt)

        ly = Colocacion.V().otro(lyT1).espacio(16).otro(lyT2).otro(lyT3).relleno()

        self.gbTutor = Controles.GB(self, _("Activate the tutor's help"), ly)
        self.gbTutor.setCheckable(True)
        self.gbTutor.setStyleSheet(gbStyle)

        lb = Controles.LB(self, _("It is showed") + ":").ponFuente(font)
        self.cbThoughtOp = Controles.CB(self, liThinks, -1).ponFuente(font)
        lbArrows = Controles.LB2P(self, _("Arrows to show")).ponFuente(font)
        self.sbArrows = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font)
        ly = Colocacion.H().control(lb).control(self.cbThoughtOp).relleno()
        ly.control(lbArrows).control(self.sbArrows).relleno()
        gbThoughtOp = Controles.GB(self, _("Opponent's thought information"), ly)
        gbThoughtOp.setStyleSheet(gbStyle)

        ly = Colocacion.V().espacio(16).control(self.gbTutor).control(gbThoughtOp)
        ly.espacio(16).control(self.chbSummary).control(self.chbTakeback).margen(6)

        nueva_tab(ly, _("Help configuration"))

        # ##################################################################################################################################
        # TAB Tiempo
        # ##################################################################################################################################
        lyG = nuevoG()

        self.lbMinutos = Controles.LB(self, _("Total minutes") + ":").ponFuente(font)
        self.edMinutos = Controles.ED(self).tipoFloat(10.0).ponFuente(font).anchoFijo(50)
        self.edSegundos, self.lbSegundos = QTUtil2.spinBoxLB(
            self, 6, -999, 999, maxTam=54, etiqueta=_("Seconds added per move"), fuente=font
        )
        self.edMinExtra, self.lbMinExtra = QTUtil2.spinBoxLB(
            self, 0, -999, 999, maxTam=70, etiqueta=_("Extra minutes for the player"), fuente=font
        )
        self.edZeitnot, self.lbZeitnot = QTUtil2.spinBoxLB(
            self, 0, -999, 999, maxTam=54, etiqueta=_("Zeitnot: alarm sounds when remaining seconds"), fuente=font
        )
        lyH = Colocacion.H()
        lyH.control(self.lbMinutos).control(self.edMinutos).espacio(30)
        lyH.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(lyH).otro(lyH2).otro(lyH3)
        self.chbTiempo = _label(lyG, _("Activate the time control"), ly, siCheck=True)

        nueva_tab(lyG, _("Time"))

        # ##################################################################################################################################
        # TAB Initial moves
        # ##################################################################################################################################
        lyG = nuevoG()

        # Posicion
        self.btPosicion = (
            Controles.PB(self, " " * 5 + _("Change") + " " * 5, self.posicionEditar).ponPlano(False).ponFuente(font)
        )
        self.fen = ""
        self.btPosicionQuitar = Controles.PB(self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No()).ponFuente(font)
        self.btPosicionPegar = (
            Controles.PB(self, "", self.posicionPegar).ponIcono(Iconos.Pegar16()).ponToolTip(_("Paste FEN position"))
        ).ponFuente(font)
        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)
            .ponFuente(font)
        )
        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.restore_pickle(fvar)
        self.listaLibros.comprueba()

        li_books = [(x.name, x) for x in self.listaLibros.lista]
        libInicial = li_books[0][1] if li_books else None

        li_resp_book = [
            (_("Selected by the player"), "su"),
            (_("Uniform random"), "au"),
            (_("Proportional random"), "ap"),
            (_("Always the highest percentage"), "mp"),
        ]

        ## Rival
        self.cbBooksR = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font)
        self.btNuevoBookR = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16)
        self.cbBooksRR = QTUtil2.comboBoxLB(self, li_resp_book, "mp").ponFuente(font)
        self.lbDepthBookR = Controles.LB2P(self, _("Max depth")).ponFuente(font)
        self.edDepthBookR = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30)

        hbox = (
            Colocacion.H()
            .control(self.cbBooksR)
            .control(self.btNuevoBookR)
            .relleno()
            .control(self.cbBooksRR)
            .relleno()
            .control(self.lbDepthBookR)
            .control(self.edDepthBookR)
        )
        self.chbBookR = _label(lyG, "%s: %s" % (_("Activate book"), _("Opponent")), hbox, siCheck=True)

        ## Player
        self.cbBooksP = QTUtil2.comboBoxLB(self, li_books, libInicial).ponFuente(font)
        self.btNuevoBookP = Controles.PB(self, "", self.nuevoBook, plano=True).ponIcono(Iconos.Mas(), tamIcon=16)
        self.lbDepthBookP = Controles.LB2P(self, _("Max depth")).ponFuente(font)
        self.edDepthBookP = Controles.ED(self).ponFuente(font).tipoInt(0).anchoFijo(30)
        hbox = (
            Colocacion.H()
            .control(self.cbBooksP)
            .control(self.btNuevoBookP)
            .relleno()
            .control(self.lbDepthBookP)
            .control(self.edDepthBookP)
        )
        self.chbBookP = _label(
            lyG, "%s: %s" % (_("Activate book"), self.configuracion.nom_player()), hbox, siCheck=True
        )

        nueva_tab(lyG, _("Initial moves"))

        # ##################################################################################################################################
        # TAB avanzada
        # ##################################################################################################################################
        lyG = nuevoG()

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

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

        self.lb_path_engine = Controles.LB(self, "").ponWrap()

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("OPTION", _("UCI option"), 240, centered=True)
        o_columns.nueva("VALUE", _("Value"), 200, centered=True, edicion=Delegados.MultiEditor(self))
        self.grid_uci = Grid.Grid(self, o_columns, siEditable=True)
        self.grid_uci.ponFuente(font)
        self.register_grid(self.grid_uci)

        lyH2 = (
            Colocacion.H().control(lbAjustarRival).control(self.cbAjustarRival).control(self.btAjustarRival).relleno()
        )
        lyH3 = Colocacion.H().control(lbResign).control(self.cbResign).relleno()
        ly = Colocacion.V().otro(lyH2).otro(lyH3).espacio(16).control(self.lb_path_engine).control(self.grid_uci)
        _label(lyG, _("Opponent"), ly)

        nueva_tab(lyG, _("Advanced"))

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

        self.setLayout(layout)

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

        dic = Util.restore_pickle(self.configuracion.ficheroEntMaquina)
        if not dic:
            dic = {}
        self.restore_dic(dic)

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

        self.restore_video()
    def creaBloqueInformacion(self):
        configuration = self.manager.configuration
        width_pgn = configuration.x_pgn_width
        with_each_color = (width_pgn - 52 - 24) // 2
        nAnchoLabels = max(int((width_pgn - 3) // 2), 140)
        # # Pgn
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUMBER", _("N."), 52, centered=True)
        si_figurines_pgn = configuration.x_pgn_withfigurines
        o_columns.nueva(
            "WHITE",
            _("White"),
            with_each_color,
            edicion=Delegados.EtiquetaPGN(True if si_figurines_pgn else None))
        o_columns.nueva(
            "BLACK",
            _("Black"),
            with_each_color,
            edicion=Delegados.EtiquetaPGN(False if si_figurines_pgn else None))
        self.pgn = Grid.Grid(self, o_columns, siCabeceraMovible=False)
        self.pgn.setMinimumWidth(width_pgn)
        self.pgn.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.pgn.tipoLetra(puntos=configuration.x_pgn_fontpoints)
        self.pgn.ponAltoFila(configuration.x_pgn_rowheight)
        self.pgn.set_right_button_without_rows(True)

        # # Blancas y negras
        f = Controles.TipoLetra(puntos=configuration.x_sizefont_infolabels + 2,
                                peso=75)
        self.lb_player_white = Controles.LB(self).anchoFijo(
            nAnchoLabels).align_center().ponFuente(f).set_wrap()
        style = "QWidget { border-style: groove; border-width: 2px; border-color: Gray; padding: 4px 4px 4px 4px;background-color:%s;color:%s;}"
        self.lb_player_white.setStyleSheet(style % ("white", "black"))

        self.lb_player_black = Controles.LB(self).anchoFijo(
            nAnchoLabels).align_center().ponFuente(f).set_wrap()
        self.lb_player_black.setStyleSheet(style % ("black", "white"))

        # # Capturas
        n_alto_fijo = 3 * (configuration.x_sizefont_infolabels + 2)
        self.lb_capt_white = Controles.LB(self).anchoFijo(
            nAnchoLabels).set_wrap().altoFijo(n_alto_fijo)
        style = "QWidget { border-style: groove; border-width: 1px; border-color: LightGray; padding: 2px 0px 2px 0px;}"
        self.lb_capt_white.setStyleSheet(style)

        self.lb_capt_black = Controles.LB(self).anchoFijo(
            nAnchoLabels).set_wrap().altoFijo(n_alto_fijo)
        self.lb_capt_black.setStyleSheet(style)

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

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

        self.lb_clock_white = lbReloj()
        self.lb_clock_black = lbReloj()

        f = Controles.TipoLetra(puntos=12)
        # Boton de tutor activo
        self.bt_active_tutor = Controles.PB(self,
                                            "",
                                            rutina=self.cambiaSiActivarTutor,
                                            plano=False).ponFuente(f)

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

        # Lo escondemos
        self.lb_player_white.hide()
        self.lb_player_black.hide()
        self.lb_capt_white.hide()
        self.lb_capt_black.hide()
        self.lb_clock_white.hide()
        self.lb_clock_black.hide()
        self.lb_capt_white.hide()
        self.lb_capt_black.hide()
        self.pgn.hide()
        self.bt_active_tutor.hide()
        self.lbRotulo1.hide()
        self.lbRotulo2.hide()
        self.lbRotulo3.hide()

        # Layout

        # Arriba
        ly_color = Colocacion.G()
        ly_color.controlc(self.lb_player_white, 0,
                          0).controlc(self.lb_player_black, 0, 1)
        ly_color.controlc(self.lb_clock_white, 2,
                          0).controlc(self.lb_clock_black, 2, 1)

        # Abajo
        ly_capturas = Colocacion.H().control(self.lb_capt_white).control(
            self.lb_capt_black)

        ly_abajo = Colocacion.V()
        ly_abajo.setSizeConstraint(ly_abajo.SetFixedSize)
        ly_abajo.otro(ly_capturas)
        ly_abajo.control(self.bt_active_tutor)
        ly_abajo.control(self.lbRotulo1).control(self.lbRotulo2).control(
            self.lbRotulo3)

        ly_v = Colocacion.V().otro(ly_color).control(self.pgn)
        ly_v.otro(ly_abajo)

        return ly_v
Exemple #26
0
    def __init__(self, tableroOriginal):
        pantalla = tableroOriginal.parent()
        titulo = _("Colors")
        icono = Iconos.EditarColores()
        extparam = "WColores"
        QTVarios.WDialogo.__init__(self, pantalla, titulo, icono, extparam)

        self.tableroOriginal = tableroOriginal
        self.configuracion = VarGen.configuracion
        self.confTablero = tableroOriginal.confTablero.copia(tableroOriginal.confTablero._id)
        self.siBase = tableroOriginal.confTablero._id == "BASE"

        # Temas #############################################################################################################################
        liOpciones = [(_("Your themes"), self.configuracion.ficheroTemas)]
        for entry in Util.listdir("Themes"):
            filename = entry.name
            if filename.endswith("lktheme"):
                ctema = filename[:-8]
                liOpciones.append((ctema, "Themes/" + filename))

        self.cbTemas = Controles.CB(self, liOpciones, liOpciones[0][1]).capturaCambiado(self.cambiadoTema)
        self.lbSecciones = Controles.LB(self, _("Section") + ":")
        self.cbSecciones = Controles.CB(self, [], None).capturaCambiado(self.cambiadoSeccion)

        lyTemas = Colocacion.G()
        self.liBT_Temas = []
        for i in range(12):
            for j in range(6):
                bt = BotonTema(self, self.ponTema)
                lyTemas.control(bt, i, j)
                bt.ponTema(None)
                self.liBT_Temas.append(bt)

        def creaLB(txt):
            return Controles.LB(self, txt + ": ").alinDerecha()

        # Casillas
        lbTrans = Controles.LB(self, _("Degree of transparency"))
        lbPNG = Controles.LB(self, _("Image"))

        # # Blancas
        lbBlancas = creaLB(_("White squares"))
        self.btBlancas = BotonColor(self, self.confTablero.colorBlancas, self.actualizaTablero)
        self.btBlancasPNG = BotonImagen(self, self.confTablero.png64Blancas, self.actualizaTablero, self.btBlancas)
        self.dialBlancasTrans = DialNum(self, self.confTablero.transBlancas, self.actualizaTablero)

        # # Negras
        lbNegras = creaLB(_("Black squares"))
        self.btNegras = BotonColor(self, self.confTablero.colorNegras, self.actualizaTablero)
        self.btNegrasPNG = BotonImagen(self, self.confTablero.png64Negras, self.actualizaTablero, self.btNegras)
        self.dialNegrasTrans = DialNum(self, self.confTablero.transNegras, self.actualizaTablero)

        # Background
        lbFondo = creaLB(_("Background"))
        self.btFondo = BotonColor(self, self.confTablero.colorFondo, self.actualizaTablero)
        self.btFondoPNG = BotonImagen(self, self.confTablero.png64Fondo, self.actualizaTablero, self.btFondo)
        self.chbExtended = Controles.CHB(self, _("Extended to outer border"),
                                         self.confTablero.extendedColor()).capturaCambiado(self, self.extendedColor)

        # Actual
        self.chbTemas = Controles.CHB(self, _("Default"), self.confTablero.siDefTema()).capturaCambiado(self,
                                                                                                        self.defectoTemas)
        if self.siBase:
            self.chbTemas.ponValor(False)
            self.chbTemas.setVisible(False)
        # Exterior
        lbExterior = creaLB(_("Outer Border"))
        self.btExterior = BotonColor(self, self.confTablero.colorExterior, self.actualizaTablero)
        # Texto
        lbTexto = creaLB(_("Coordinates"))
        self.btTexto = BotonColor(self, self.confTablero.colorTexto, self.actualizaTablero)
        # Frontera
        lbFrontera = creaLB(_("Inner Border"))
        self.btFrontera = BotonColor(self, self.confTablero.colorFrontera, self.actualizaTablero)

        # Flechas
        lbFlecha = creaLB(_("Move indicator"))
        self.lyF = BotonFlecha(self, self.confTablero.fTransicion, self.confTablero.flechaDefecto,
                               self.actualizaTablero)
        lbFlechaAlternativa = creaLB(_("Arrow alternative"))
        self.lyFAlternativa = BotonFlecha(self, self.confTablero.fAlternativa,
                                          self.confTablero.flechaAlternativaDefecto, self.actualizaTablero)
        lbFlechaActivo = creaLB(_("Active moves"))
        self.lyFActual = BotonFlecha(self, self.confTablero.fActivo, self.confTablero.flechaActivoDefecto,
                                     self.actualizaTablero)
        lbFlechaRival = creaLB(_("Opponent moves"))
        self.lyFRival = BotonFlecha(self, self.confTablero.fRival, self.confTablero.flechaRivalDefecto,
                                    self.actualizaTablero)

        lyActual = Colocacion.G()
        lyActual.control(self.chbTemas, 0, 0)
        lyActual.controlc(lbPNG, 0, 2).controlc(lbTrans, 0, 3)
        lyActual.controld(lbBlancas, 1, 0).control(self.btBlancas, 1, 1).otroc(self.btBlancasPNG, 1, 2).otroc(
                self.dialBlancasTrans, 1, 3)
        lyActual.controld(lbNegras, 2, 0).control(self.btNegras, 2, 1).otroc(self.btNegrasPNG, 2, 2).otroc(
                self.dialNegrasTrans, 2, 3)
        lyActual.controld(lbFondo, 3, 0).control(self.btFondo, 3, 1).otroc(self.btFondoPNG, 3, 2).control(
                self.chbExtended, 3, 3)
        lyActual.controld(lbExterior, 4, 0).control(self.btExterior, 4, 1)
        lyActual.controld(lbTexto, 5, 0).control(self.btTexto, 5, 1)
        lyActual.controld(lbFrontera, 6, 0).control(self.btFrontera, 6, 1)
        lyActual.controld(lbFlecha, 7, 0).otro(self.lyF, 7, 1, 1, 4)
        lyActual.controld(lbFlechaAlternativa, 8, 0).otro(self.lyFAlternativa, 8, 1, 1, 4)
        lyActual.controld(lbFlechaActivo, 9, 0).otro(self.lyFActual, 9, 1, 1, 4)
        lyActual.controld(lbFlechaRival, 10, 0).otro(self.lyFRival, 10, 1, 1, 4)

        gbActual = Controles.GB(self, _("Active theme"), lyActual)

        lySecciones = Colocacion.H().control(self.lbSecciones).control(self.cbSecciones).relleno()
        ly = Colocacion.V().control(self.cbTemas).otro(lySecciones).otro(lyTemas).control(gbActual).relleno()
        gbTemas = Controles.GB(self, "", ly)
        gbTemas.setFlat(True)

        # mas opciones ##############################################################################################################
        def xDefecto(siDefecto):
            if self.siBase:
                siDefecto = False
            chb = Controles.CHB(self, _("Default"), siDefecto).capturaCambiado(self, self.defectoTableroM)
            if self.siBase:
                chb.setVisible(False)
            return chb

        def l2mas1(lyG, fila, a, b, c):
            if a:
                ly = Colocacion.H().controld(a).control(b)
            else:
                ly = Colocacion.H().control(b)
            lyG.otro(ly, fila, 0).control(c, fila, 1)

        # Coordenadas
        lyG = Colocacion.G()
        # _nCoordenadas
        lbCoordenadas = creaLB(_("Number"))
        liOpciones = [("0", 0), ("4", 4), ("2a", 2), ("2b", 3), ("2c", 5), ("2d", 6)]
        self.cbCoordenadas = Controles.CB(self, liOpciones, self.confTablero.nCoordenadas()).capturaCambiado(self.actualizaTableroM)
        self.chbDefCoordenadas = xDefecto(self.confTablero.siDefCoordenadas())
        l2mas1(lyG, 0, lbCoordenadas, self.cbCoordenadas, self.chbDefCoordenadas)

        # _tipoLetra
        lbTipoLetra = creaLB(_("Font"))
        self.cbTipoLetra = QtGui.QFontComboBox()
        self.cbTipoLetra.setEditable(False)
        self.cbTipoLetra.setFontFilters(self.cbTipoLetra.ScalableFonts)
        self.cbTipoLetra.setCurrentFont(QtGui.QFont(self.confTablero.tipoLetra()))
        self.connect(self.cbTipoLetra, QtCore.SIGNAL("currentIndexChanged(int)"), self.actualizaTableroM)
        self.chbDefTipoLetra = xDefecto(self.confTablero.siDefTipoLetra())
        l2mas1(lyG, 1, lbTipoLetra, self.cbTipoLetra, self.chbDefTipoLetra)

        # _cBold
        self.chbBold = Controles.CHB(self, _("Bold"), self.confTablero.siBold()).capturaCambiado(self, self.actualizaTableroM)
        self.chbDefBold = xDefecto(self.confTablero.siDefBold())
        l2mas1(lyG, 2, None, self.chbBold, self.chbDefBold)

        # _tamLetra
        lbTamLetra = creaLB(_("Size") + " %")
        self.sbTamLetra = Controles.SB(self, self.confTablero.tamLetra(), 1, 200).tamMaximo(50).capturaCambiado(
                self.actualizaTableroM)
        self.chbDefTamLetra = xDefecto(self.confTablero.siDefTamLetra())
        l2mas1(lyG, 3, lbTamLetra, self.sbTamLetra, self.chbDefTamLetra)

        # _sepLetras
        lbSepLetras = creaLB(_("Separation") + " %")
        self.sbSepLetras = Controles.SB(self, self.confTablero.sepLetras(), -1000, 1000).tamMaximo(50).capturaCambiado(
                self.actualizaTableroM)
        self.chbDefSepLetras = xDefecto(self.confTablero.siDefSepLetras())
        l2mas1(lyG, 4, lbSepLetras, self.sbSepLetras, self.chbDefSepLetras)

        gbCoordenadas = Controles.GB(self, _("Coordinates"), lyG)

        lyOtros = Colocacion.G()
        # _nomPiezas
        li = []
        lbPiezas = creaLB(_("Pieces"))
        for entry in Util.listdir("Pieces"):
            if entry.is_dir():
                li.append((entry.name, entry.name))
        li.sort(key=lambda x: x[0])
        self.cbPiezas = Controles.CB(self, li, self.confTablero.nomPiezas()).capturaCambiado(self.actualizaTableroM)
        self.chbDefPiezas = xDefecto(self.confTablero.siDefPiezas())
        l2mas1(lyOtros, 0, lbPiezas, self.cbPiezas, self.chbDefPiezas)

        # _tamRecuadro
        lbTamRecuadro = creaLB(_("Outer Border Size") + " %")
        self.sbTamRecuadro = Controles.SB(self, self.confTablero.tamRecuadro(), 0, 10000).tamMaximo(50).capturaCambiado(
                self.actualizaTableroM)
        self.chbDefTamRecuadro = xDefecto(self.confTablero.siDefTamRecuadro())
        l2mas1(lyOtros, 1, lbTamRecuadro, self.sbTamRecuadro, self.chbDefTamRecuadro)

        # _tamFrontera
        lbTamFrontera = creaLB(_("Inner Border Size") + " %")
        self.sbTamFrontera = Controles.SB(self, self.confTablero.tamFrontera(), 0, 10000).tamMaximo(50).capturaCambiado(
                self.actualizaTableroM)
        self.chbDefTamFrontera = xDefecto(self.confTablero.siDefTamFrontera())
        l2mas1(lyOtros, 2, lbTamFrontera, self.sbTamFrontera, self.chbDefTamFrontera)

        ly = Colocacion.V().control(gbCoordenadas).espacio(50).otro(lyOtros).relleno()

        gbOtros = Controles.GB(self, "", ly)
        gbOtros.setFlat(True)

        # Tablero ##########################################################################################################################
        cp = ControlPosicion.ControlPosicion().leeFen("2kr1b1r/2p1pppp/p7/3pPb2/1q3P2/2N1P3/PPP3PP/R1BQK2R w KQ - 0 1")
        self.tablero = Tablero.Tablero(self, self.confTablero, siMenuVisual=False)
        self.tablero.crea()
        self.tablero.ponPosicion(cp)
        self.rehazFlechas()

        liAcciones = [(_("Accept"), Iconos.Aceptar(), self.aceptar), None,
                      (_("Cancel"), Iconos.Cancelar(), self.cancelar), None,
                      (_("Your themes"), Iconos.Temas(), self.temas), None,
                      (_("Import"), Iconos.Mezclar(), self.importar), None,
                      (_("Export"), Iconos.Grabar(), self.exportar), None,
                      ]
        tb = Controles.TBrutina(self, liAcciones)

        # tam tablero
        self.lbTamTablero = Controles.LB(self, "%d px" % self.tablero.width())

        # Juntamos
        lyT = Colocacion.V().control(tb).espacio(15).control(self.tablero).controli(self.lbTamTablero).relleno(
                1).margen(3)

        self.tab = Controles.Tab()
        self.tab.nuevaTab(gbTemas, _("Themes"))
        self.tab.nuevaTab(gbOtros, _("Other options"))
        ly = Colocacion.H().otro(lyT).control(self.tab)

        self.setLayout(ly)

        self.elegido = None

        self.liTemas = self.leeTemas()
        self.temaActual = {}
        if self.liTemas:
            txtTM = self.confTablero.grabaTema()
            txtBS = self.confTablero.grabaBase()
            for tema in self.liTemas:
                if tema:
                    if tema.get("TEXTO", "") == txtTM and txtBS == tema.get("BASE", ""):
                        self.temaActual = tema
                        break
        self.cambiadoTema()
        self.defectoTemas()

        self.extendedColor()

        self.siActualizando = False

        self.recuperarVideo(siTam=False)
Exemple #27
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 = QTVarios.LCTB(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()
Exemple #28
0
    def __init__(self, wParent, oColumnas, liFiltro):

        super(WFiltrar, self).__init__(wParent)

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

        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()
Exemple #29
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, 10000)
        # Draw-plys
        lbDrawMinPly = Controles.LB(self,
                                    _("Minimum moves to assign draw") + ": ")
        self.sbDrawMinPly = Controles.SB(self, torneo.drawMinPly(), 20, 9999)
        # 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="http://www.hoflink.com/~npollock/40H.html">?</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()
Exemple #30
0
 def nuevoG():
     lyG = Colocacion.G()
     lyG.filaActual = 0
     return lyG