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)
Example #2
0
    def __init__(self, side, rutina):
        QtWidgets.QWidget.__init__(self)

        self.dispatch = rutina
        self.side = side
        self.setFont(Controles.TipoLetra())

        ancho = 54

        bt_all = Controles.PB(self, _("All"), self.run_all, plano=False).anchoFijo(ancho + 16)
        bt_e4 = Controles.PB(self, "e4", self.run_e4, plano=False).anchoFijo(ancho)
        bt_d4 = Controles.PB(self, "d4", self.run_d4, plano=False).anchoFijo(ancho)
        bt_c4 = Controles.PB(self, "c4", self.run_c4, plano=False).anchoFijo(ancho)
        bt_nf3 = Controles.PB(self, "Nf3", self.run_nf3, plano=False).anchoFijo(ancho)
        bt_other = Controles.PB(self, _("Others"), self.run_other, plano=False).anchoFijo(ancho + 16)

        ply1 = Controles.PB(self, _("%d ply") % 1, self.run_p1, plano=False).anchoFijo(ancho)
        ply2 = Controles.PB(self, _("%d ply") % 2, self.run_p2, plano=False).anchoFijo(ancho)
        ply3 = Controles.PB(self, _("%d ply") % 3, self.run_p3, plano=False).anchoFijo(ancho)
        ply4 = Controles.PB(self, _("%d ply") % 4, self.run_p4, plano=False).anchoFijo(ancho)
        ply5 = Controles.PB(self, _("%d ply") % 5, self.run_p5, plano=False).anchoFijo(ancho)

        self.sbply = Controles.SB(self, 0, 0, 100)
        self.sbply.capture_changes(self.run_p)
        lbply = Controles.LB(self, _("Plies"))

        layout = Colocacion.H().relleno(1).control(bt_all)
        layout.control(bt_e4).control(bt_d4).control(bt_c4).control(bt_nf3).control(bt_other).relleno(1)
        layout.control(ply1).control(ply2).control(ply3).control(ply4).control(ply5)
        layout.control(lbply).control(self.sbply).relleno(1).margen(0)

        self.setLayout(layout)
Example #3
0
    def me_setEditor(self, parent):
        recno = self.gridValores.recno()
        key = self.liKibActual[recno][2]
        nk = self.krecno()
        kibitzer = self.kibitzers.kibitzer(nk)
        valor = control = lista = minimo = maximo = None
        if key is None:
            return None
        elif key == "nombre":
            control = "ed"
            valor = kibitzer.nombre
        elif key == "tipo":
            valor = kibitzer.tipo
            if valor == "I":  # Indices no se cambian
                return None
            control = "cb"
            lista = Kibitzers.Tipos().comboSinIndices()
        elif key == "prioridad":
            control = "cb"
            lista = EngineThread.priorities.combo()
            valor = kibitzer.prioridad
        elif key == "posicionBase":
            kibitzer.posicionBase = not kibitzer.posicionBase
            self.kibitzers.save()
            self.goto(nk)
        elif key == "visible":
            kibitzer.visible = not kibitzer.visible
            self.kibitzers.save()
            self.goto(nk)
        elif key == "info":
            control = "ed"
            valor = kibitzer.idInfo
        elif key.startswith("opcion"):
            opcion = kibitzer.liOpciones[int(key[7:])]
            tipo = opcion.tipo
            valor = opcion.valor
            if tipo == "spin":
                control = "sb"
                minimo = opcion.min
                maximo = opcion.max
            elif tipo in ("check", "button"):
                opcion.valor = not valor
                self.kibitzers.save()
                self.goto(nk)
            elif tipo == "combo":
                lista = [(var, var) for var in opcion.liVars]
                control = "cb"
            elif tipo == "string":
                control = "ed"

        self.me_control = control
        self.me_key = key

        if control == "ed":
            return Controles.ED(parent, valor)
        elif control == "cb":
            return Controles.CB(parent, lista, valor)
        elif control == "sb":
            return Controles.SB(parent, valor, minimo, maximo)
        return None
Example #4
0
def spinBoxLB(owner, valor, desde, hasta, etiqueta=None, maxTam=None):
    ed = Controles.SB(owner, valor, desde, hasta)
    if maxTam:
        ed.tamMaximo(maxTam)
    if etiqueta:
        label = Controles.LB(owner, etiqueta + ": ")
        return ed, label
    else:
        return ed
Example #5
0
    def __init__(self, tabsAnalisis, procesador, configuracion):
        QtWidgets.QWidget.__init__(self)

        self.analyzing = False
        self.position = None
        self.li_analysis = []
        self.gestor_motor = None
        self.current_mrm = None

        self.dbop = tabsAnalisis.dbop

        self.procesador = procesador
        self.configuracion = configuracion
        self.siFigurines = configuracion.x_pgn_withfigurines

        self.tabsAnalisis = tabsAnalisis
        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()

        self.lb_engine = Controles.LB(self, _("Engine") + ":")
        liMotores = configuracion.comboMotores()  # (name, key)
        default = configuracion.tutor.clave
        engine = self.dbop.getconfig("ENGINE", default)
        if len([key for name, key in liMotores if key == engine]) == 0:
            engine = default
        self.cb_engine = Controles.CB(self, liMotores, engine).capturaCambiado(self.reset_motor)

        multipv = self.dbop.getconfig("ENGINE_MULTIPV", 10)
        lb_multipv = Controles.LB(self, _("Multi PV") + ": ")
        self.sb_multipv = Controles.SB(self, multipv, 1, 500).tamMaximo(50)

        self.lb_analisis = (
            Controles.LB(self, "").ponFondoN("#C9D2D7").ponTipoLetra(puntos=configuracion.x_pgn_fontpoints)
        )

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("PDT", _("Evaluation"), 120, centered=True)
        delegado = Delegados.EtiquetaPOS(True, siLineas=False) if self.siFigurines else None
        o_columns.nueva("SOL", "", 100, centered=True, edicion=delegado)
        o_columns.nueva("PGN", _("Solution"), 860)

        self.grid_analysis = Grid.Grid(self, o_columns, siSelecFilas=True, siCabeceraVisible=False)
        self.grid_analysis.tipoLetra(puntos=configuracion.x_pgn_fontpoints)
        self.grid_analysis.ponAltoFila(configuracion.x_pgn_rowheight)
        # self.register_grid(self.grid_analysis)

        ly_lin1 = Colocacion.H().control(self.bt_start).control(self.bt_stop).control(self.lb_engine)
        ly_lin1.control(self.cb_engine)
        ly_lin1.espacio(50).control(lb_multipv).control(self.sb_multipv).relleno()
        ly = Colocacion.V().otro(ly_lin1).control(self.lb_analisis).control(self.grid_analysis).margen(3)

        self.setLayout(ly)

        self.reset_motor()
Example #6
0
    def me_set_editor(self, parent):
        recno = self.gridValores.recno()
        key = self.liKibActual[recno][2]
        nk = self.krecno()
        kibitzer = self.kibitzers.kibitzer(nk)
        valor = control = lista = minimo = maximo = None
        if key is None:
            return None
        elif key == "name":
            control = "ed"
            valor = kibitzer.name
        elif key == "prioridad":
            control = "cb"
            lista = Priorities.priorities.combo()
            valor = kibitzer.prioridad
        elif key == "pointofview":
            control = "cb"
            lista = Kibitzers.cb_pointofview_options()
            valor = kibitzer.pointofview
        elif key == "visible":
            kibitzer.visible = not kibitzer.visible
            self.kibitzers.save()
            self.goto(nk)
        elif key == "info":
            control = "ed"
            valor = kibitzer.id_info
        elif key.startswith("opcion"):
            opcion = kibitzer.li_uci_options_editable()[int(key[7:])]
            tipo = opcion.tipo
            valor = opcion.valor
            if tipo == "spin":
                control = "sb"
                minimo = opcion.minimo
                maximo = opcion.maximo
            elif tipo in ("check", "button"):
                opcion.valor = not valor
                self.kibitzers.save()
                self.goto(nk)
            elif tipo == "combo":
                lista = [(var, var) for var in opcion.li_vars]
                control = "cb"
            elif tipo == "string":
                control = "ed"

        self.me_control = control
        self.me_key = key

        if control == "ed":
            return Controles.ED(parent, valor)
        elif control == "cb":
            return Controles.CB(parent, lista, valor)
        elif control == "sb":
            return Controles.SB(parent, valor, minimo, maximo)
        return None
Example #7
0
def spinBoxLB(owner,
              valor,
              from_sq,
              to_sq,
              etiqueta=None,
              maxTam=None,
              fuente=None):
    ed = Controles.SB(owner, valor, from_sq, to_sq)
    if fuente:
        ed.setFont(fuente)
    if maxTam:
        ed.tamMaximo(maxTam)
    if etiqueta:
        label = Controles.LB(owner, etiqueta + ": ")
        if fuente:
            label.setFont(fuente)
        return ed, label
    else:
        return ed
Example #8
0
    def me_set_editor(self, parent):
        recno = self.gridValores.recno()
        key = self.li_options[recno][2]
        control = lista = minimo = maximo = None
        if key == "prioridad":
            control = "cb"
            lista = Priorities.priorities.combo()
            valor = self.kibitzer.prioridad
        elif key == "pointofview":
            control = "cb"
            lista = Kibitzers.cb_pointofview_options()
            valor = self.kibitzer.pointofview
        else:
            opcion = self.kibitzer.li_uci_options_editable()[int(key)]
            tipo = opcion.tipo
            valor = opcion.valor
            if tipo == "spin":
                control = "sb"
                minimo = opcion.minimo
                maximo = opcion.maximo
            elif tipo in ("check", "button"):
                opcion.valor = not valor
                self.li_options[recno][1] = opcion.valor
                self.gridValores.refresh()
            elif tipo == "combo":
                lista = [(var, var) for var in opcion.li_vars]
                control = "cb"
            elif tipo == "string":
                control = "ed"

        self.me_control = control
        self.me_key = key

        if control == "ed":
            return Controles.ED(parent, valor)
        elif control == "cb":
            return Controles.CB(parent, lista, valor)
        elif control == "sb":
            return Controles.SB(parent, valor, minimo, maximo)
        return None
Example #9
0
    def me_setEditor(self, parent):
        recno = self.gridValores.recno()
        key = self.liOpciones[recno][2]
        control = lista = minimo = maximo = None
        if key == "prioridad":
            control = "cb"
            lista = EngineThread.priorities.combo()
            valor = self.kibitzer.prioridad
        elif key == "posicionBase":
            self.kibitzer.posicionBase = not self.kibitzer.posicionBase
            self.liOpciones[recno][1] = self.kibitzer.posicionBase
            self.gridValores.refresh()
        else:
            opcion = self.kibitzer.liOpciones[int(key)]
            tipo = opcion.tipo
            valor = opcion.valor
            if tipo == "spin":
                control = "sb"
                minimo = opcion.min
                maximo = opcion.max
            elif tipo in ("check", "button"):
                opcion.valor = not valor
                self.liOpciones[recno][1] = opcion.valor
                self.gridValores.refresh()
            elif tipo == "combo":
                lista = [(var, var) for var in opcion.liVars]
                control = "cb"
            elif tipo == "string":
                control = "ed"

        self.me_control = control
        self.me_key = key

        if control == "ed":
            return Controles.ED(parent, valor)
        elif control == "cb":
            return Controles.CB(parent, lista, valor)
        elif control == "sb":
            return Controles.SB(parent, valor, minimo, maximo)
        return None
Example #10
0
    def me_set_editor(self, parent):
        recno = self.grid_uci.recno()
        opcion = self.rival.li_uci_options_editable()[recno]
        key = opcion.name
        value = opcion.valor
        for xkey, xvalue in self.rival.liUCI:
            if xkey == key:
                value = xvalue
                break
        if key is None:
            return None

        control = lista = minimo = maximo = None
        tipo = opcion.tipo
        if tipo == "spin":
            control = "sb"
            minimo = opcion.minimo
            maximo = opcion.maximo
        elif tipo in ("check", "button"):
            self.rival.ordenUCI(key, not value)
            self.grid_uci.refresh()
        elif tipo == "combo":
            lista = [(var, var) for var in opcion.li_vars]
            control = "cb"
        elif tipo == "string":
            control = "ed"

        self.me_control = control
        self.me_key = key

        if control == "ed":
            return Controles.ED(parent, value)
        elif control == "cb":
            return Controles.CB(parent, lista, value)
        elif control == "sb":
            return Controles.SB(parent, value, minimo, maximo)
        return None
Example #11
0
    def __init__(self, wParent, categoria, configuracion):
        super(wDatos, self).__init__(wParent)

        self.setWindowTitle(_("New game"))
        self.setWindowIcon(Iconos.Datos())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        tb = QTUtil2.tbAcceptCancel(self)

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

        self.maxNivel, self.maxNivelHecho, self.maxPuntos = configuracion.maxNivelCategoria(
            categoria)
        # self.maxNivel = maxNivel = categoria.nivelHecho+1
        # self.maxNivelHecho = categoria.hecho
        # self.maxPuntos = categoria.maxPuntos()

        self.ed = Controles.SB(self, self.maxNivel, 1,
                               self.maxNivel).tamMaximo(40)
        lb = Controles.LB(self, categoria.nombre() + " " + _("Level"))

        lb.ponFuente(f)
        self.lbPuntos = Controles.LB(self).alinDerecha()
        self.connect(self.ed, QtCore.SIGNAL("valueChanged(int)"),
                     self.nivelCambiado)

        siBlancas = not categoria.siHechoBlancas()
        self.rbBlancas = QtGui.QRadioButton(_("White"))
        self.rbBlancas.setChecked(siBlancas)
        self.rbNegras = QtGui.QRadioButton(_("Black"))
        self.rbNegras.setChecked(not siBlancas)
        self.connect(self.rbBlancas, QtCore.SIGNAL("clicked()"),
                     self.ponMaxPuntos)
        self.connect(self.rbNegras, QtCore.SIGNAL("clicked()"),
                     self.ponMaxPuntos)

        # Rival
        rival = configuracion.rival
        lbRMotor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Engine"),
             rival.nombre)).ponFuente(flb).ponWrap().anchoFijo(400)
        lbRAutor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Author"), rival.autor)).ponFuente(flb).ponWrap().anchoFijo(400)
        lbRWeb = Controles.LB(
            self, '<b>%s</b> : <a href="%s">%s</a>' %
            (_("Web"), rival.url,
             rival.url)).ponWrap().anchoFijo(400).ponFuente(flb)

        ly = Colocacion.V().control(lbRMotor).control(lbRAutor).control(
            lbRWeb).margen(10)
        gbR = Controles.GB(self, _("Opponent"), ly).ponFuente(f)

        # Tutor
        tutor = configuracion.tutor
        lbTMotor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Engine"),
             tutor.nombre)).ponFuente(flb).ponWrap().anchoFijo(400)
        lbTAutor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Author"), tutor.autor)).ponFuente(flb).ponWrap().anchoFijo(400)
        siURL = hasattr(tutor, "url")
        if siURL:
            lbTWeb = Controles.LB(
                self, '<b>%s</b> : <a href="%s">%s</a>' %
                ("Web", tutor.url,
                 tutor.url)).ponWrap().anchoFijo(400).ponFuente(flb)

        ly = Colocacion.V().control(lbTMotor).control(lbTAutor)
        if siURL:
            ly.control(lbTWeb)
        ly.margen(10)
        gbT = Controles.GB(self, _("Tutor"), ly).ponFuente(f)

        hbox = Colocacion.H().relleno().control(
            self.rbBlancas).espacio(10).control(self.rbNegras).relleno()
        gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(f)

        lyNivel = Colocacion.H().control(lb).control(
            self.ed).espacio(10).control(self.lbPuntos).relleno()

        vlayout = Colocacion.V().otro(lyNivel).espacio(10).control(
            gbColor).espacio(10).control(gbR).espacio(10).control(gbT).margen(
                30)

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

        self.setLayout(layout)

        self.ponMaxPuntos()
Example #12
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()
Example #13
0
    def __init__(self, procesador, titulo):

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

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

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

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

        # Toolbar

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

        # Tab

        tab = Controles.Tab()

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

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

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

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

        # TAB General

        lyG = nuevoG()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # TAB Tiempo

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

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

        # TAB Initial moves

        lyG = nuevoG()

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

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

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

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

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

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

        self.setLayout(layout)

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

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

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

        self.recuperarVideo()
Example #14
0
    def __init__(self, owner, tactica, ncopia=None):
        QtWidgets.QWidget.__init__(self)

        self.owner = owner
        self.tacticaINI = tactica
        if ncopia is not None:
            reg_historico = tactica.historico()[ncopia]
        else:
            reg_historico = None

        # Total por ficheros
        self.liFTOTAL = tactica.calculaTotales()
        total = sum(self.liFTOTAL)

        # N. puzzles
        if reg_historico:
            num = reg_historico["PUZZLES"]
        else:
            num = tactica.puzzles
        if not num or num > total:
            num = total

        lb_puzzles = Controles.LB(self, _("Max number of puzzles in each block") + ": ")
        self.sb_puzzles = Controles.SB(self, num, 1, total)

        # Reference
        lb_reference = Controles.LB(self, _("Reference") + ": ")
        self.ed_reference = Controles.ED(self)

        # Iconos
        ico_mas = Iconos.Add()
        ico_menos = Iconos.Delete()
        ico_cancel = Iconos.CancelarPeque()
        ico_reset = Iconos.MoverAtras()

        def tb_gen(prev):
            li_acciones = (
                (_("Add"), ico_mas, "%s_add" % prev),
                (_("Delete"), ico_menos, "%s_delete" % prev),
                None,
                (_("Delete all"), ico_cancel, "%s_delete_all" % prev),
                None,
                (_("Reset"), ico_reset, "%s_reset" % prev),
                None,
            )
            tb = Controles.TB(self, li_acciones, icon_size=16, with_text=False)
            return tb

        f = Controles.TipoLetra(peso=75)

        # Repeticiones de cada puzzle
        if reg_historico:
            self.liJUMPS = reg_historico["JUMPS"][:]
        else:
            self.liJUMPS = tactica.jumps[:]
        tb = tb_gen("jumps")
        o_col = Columnas.ListaColumnas()
        o_col.nueva("NUMBER", _("Repetition"), 80, centered=True)
        o_col.nueva("JUMPS_SEPARATION", _("Separation"), 80, centered=True, edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_jumps = Grid.Grid(self, o_col, siSelecFilas=True, siEditable=True, xid="j")
        self.grid_jumps.setMinimumWidth(self.grid_jumps.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_jumps)
        gb_jumps = Controles.GB(self, _("Repetitions of each puzzle"), ly).ponFuente(f)
        self.grid_jumps.gotop()

        # Repeticion del bloque
        if reg_historico:
            self.liREPEAT = reg_historico["REPEAT"][:]
        else:
            self.liREPEAT = tactica.repeat[:]
        tb = tb_gen("repeat")
        o_col = Columnas.ListaColumnas()
        o_col.nueva("NUMBER", _("Block"), 40, centered=True)
        self.liREPEATtxt = (_("Original"), _("Random"), _("Previous"))
        o_col.nueva("REPEAT_ORDER", _("Order"), 100, centered=True, edicion=Delegados.ComboBox(self.liREPEATtxt))
        self.grid_repeat = Grid.Grid(self, o_col, siSelecFilas=True, siEditable=True, xid="r")
        self.grid_repeat.setMinimumWidth(self.grid_repeat.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_repeat)
        gb_repeat = Controles.GB(self, _("Blocks"), ly).ponFuente(f)
        self.grid_repeat.gotop()

        # Penalizaciones
        if reg_historico:
            self.liPENAL = reg_historico["PENALIZATION"][:]
        else:
            self.liPENAL = tactica.penalization[:]
        tb = tb_gen("penal")
        o_col = Columnas.ListaColumnas()
        o_col.nueva("NUMBER", _("N."), 20, centered=True)
        o_col.nueva("PENAL_POSITIONS", _("Positions"), 100, centered=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_col.nueva("PENAL_%", _("Affected"), 100, centered=True)
        self.grid_penal = Grid.Grid(self, o_col, siSelecFilas=True, siEditable=True, xid="p")
        self.grid_penal.setMinimumWidth(self.grid_penal.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_penal)
        gb_penal = Controles.GB(self, _("Penalties"), ly).ponFuente(f)
        self.grid_penal.gotop()

        # ShowText
        if reg_historico:
            self.liSHOWTEXT = reg_historico["SHOWTEXT"][:]
        else:
            self.liSHOWTEXT = tactica.showtext[:]
        tb = tb_gen("show")
        o_col = Columnas.ListaColumnas()
        self.liSHOWTEXTtxt = (_("No"), _("Yes"))
        o_col.nueva("NUMBER", _("N."), 20, centered=True)
        o_col.nueva("SHOW_VISIBLE", _("Visible"), 100, centered=True, edicion=Delegados.ComboBox(self.liSHOWTEXTtxt))
        o_col.nueva("SHOW_%", _("Affected"), 100, centered=True)
        self.grid_show = Grid.Grid(self, o_col, siSelecFilas=True, siEditable=True, xid="s")
        self.grid_show.setMinimumWidth(self.grid_show.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_show)
        gbShow = Controles.GB(self, _("Show text associated with each puzzle"), ly).ponFuente(f)
        self.grid_show.gotop()

        # Reinforcement
        if reg_historico:
            self.reinforcement_errors = reg_historico["REINFORCEMENT_ERRORS"]
            self.reinforcement_cycles = reg_historico["REINFORCEMENT_CYCLES"]
        else:
            self.reinforcement_errors = tactica.reinforcement_errors
            self.reinforcement_cycles = tactica.reinforcement_cycles

        lb_r_errors = Controles.LB(self, _("Accumulated errors to launch reinforcement") + ": ")
        li_opciones = [(_("Disable"), 0), ("5", 5), ("10", 10), ("15", 15), ("20", 20)]
        self.cb_reinf_errors = Controles.CB(self, li_opciones, self.reinforcement_errors)
        lb_r_cycles = Controles.LB(self, _("Cycles") + ": ")
        self.sb_reinf_cycles = Controles.SB(self, self.reinforcement_cycles, 1, 10)
        ly = (
            Colocacion.H()
            .control(lb_r_errors)
            .control(self.cb_reinf_errors)
            .espacio(30)
            .control(lb_r_cycles)
            .control(self.sb_reinf_cycles)
        )
        gb_reinforcement = Controles.GB(self, _("Reinforcement"), ly).ponFuente(f)

        # Files
        if reg_historico:
            self.liFILES = reg_historico["FILESW"][:]
        else:
            self.liFILES = []
            for num, (fich, w, d, h) in enumerate(tactica.filesw):
                if not d or d < 1:
                    d = 1
                if not h or h > self.liFTOTAL[num] or h < 1:
                    h = self.liFTOTAL[num]
                if d > h:
                    d, h = h, d
                self.liFILES.append([fich, w, d, h])
        o_col = Columnas.ListaColumnas()
        o_col.nueva("FILE", _("File"), 220, centered=True)
        o_col.nueva("WEIGHT", _("Weight"), 100, centered=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_col.nueva("TOTAL", _("Total"), 100, centered=True)
        o_col.nueva("FROM", _("From"), 100, centered=True, edicion=Delegados.LineaTexto(siEntero=True))
        o_col.nueva("TO", _("To"), 100, centered=True, edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_files = Grid.Grid(self, o_col, siSelecFilas=True, siEditable=True, xid="f")
        self.grid_files.setMinimumWidth(self.grid_files.anchoColumnas() + 20)
        ly = Colocacion.V().control(self.grid_files)
        gb_files = Controles.GB(self, _("FNS files"), ly).ponFuente(f)
        self.grid_files.gotop()

        # Layout
        ly_reference = Colocacion.H().control(lb_reference).control(self.ed_reference)
        ly_puzzles = Colocacion.H().control(lb_puzzles).control(self.sb_puzzles)
        ly = Colocacion.G()
        ly.otro(ly_puzzles, 0, 0).otro(ly_reference, 0, 1)
        ly.filaVacia(1, 5)
        ly.controld(gb_jumps, 2, 0).control(gb_penal, 2, 1)
        ly.filaVacia(3, 5)
        ly.controld(gb_repeat, 4, 0)
        ly.control(gbShow, 4, 1)
        ly.filaVacia(5, 5)
        ly.control(gb_reinforcement, 6, 0, 1, 2)
        ly.filaVacia(6, 5)
        ly.control(gb_files, 7, 0, 1, 2)

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

        self.setLayout(layout)

        self.grid_repeat.gotop()
Example #15
0
    def __init__(self, owner, configuracion, dic_data):
        super(WOptionsDatabase, self).__init__(owner)

        self.new = len(dic_data) == 0

        self.dic_data = dic_data
        self.dic_data_resp = None

        def d_str(key):
            return dic_data.get(key, "")

        def d_true(key):
            return dic_data.get(key, True)

        def d_false(key):
            return dic_data.get(key, False)

        title = _("New database") if len(dic_data) == 0 else "%s: %s" % (_("Database"), d_str("NAME"))
        self.setWindowTitle(title)
        self.setWindowIcon(Iconos.DatabaseMas())
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.configuracion = configuracion
        self.resultado = None

        valid_rx = r'^[^<>:;,?"*|/\\]+'

        lb_name = Controles.LB2P(self, _("Name"))
        self.ed_name = Controles.ED(self, d_str("NAME")).controlrx(valid_rx)

        ly_name = Colocacion.H().control(lb_name).control(self.ed_name)

        folder = os.path.dirname(Util.relative_path(d_str("FILEPATH")))
        folder = folder[len(configuracion.folder_databases()):]
        if folder.strip():
            folder = folder.strip(os.sep)
            li = folder.split(os.sep)
            nli = len(li)
            group = li[0]
            subgroup1 = li[1] if nli > 1 else ""
            subgroup2 = li[2] if nli > 2 else ""
        else:
            group = ""
            subgroup1 = ""
            subgroup2 = ""

        lb_group = Controles.LB2P(self, _("Group"))
        self.ed_group = Controles.ED(self, group).controlrx(valid_rx)
        self.bt_group = (
            Controles.PB(self, "", self.mira_group).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_group = (
            Colocacion.H().control(lb_group).control(self.ed_group).espacio(-10).control(self.bt_group).relleno(1)
        )

        lb_subgroup_l1 = Controles.LB2P(self, _("Subgroup"))
        self.ed_subgroup_l1 = Controles.ED(self, subgroup1).controlrx(valid_rx)
        self.bt_subgroup_l1 = (
            Controles.PB(self, "", self.mira_subgroup_l1).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_subgroup_l1 = (
            Colocacion.H()
            .espacio(40)
            .control(lb_subgroup_l1)
            .control(self.ed_subgroup_l1)
            .espacio(-10)
            .control(self.bt_subgroup_l1)
            .relleno(1)
        )

        lb_subgroup_l2 = Controles.LB2P(self, "%s → %s" % (_("Subgroup"), _("Subgroup")))
        self.ed_subgroup_l2 = Controles.ED(self, subgroup2).controlrx(valid_rx)
        self.bt_subgroup_l2 = (
            Controles.PB(self, "", self.mira_subgroup_l2).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_subgroup_l2 = (
            Colocacion.H()
            .espacio(40)
            .control(lb_subgroup_l2)
            .control(self.ed_subgroup_l2)
            .espacio(-10)
            .control(self.bt_subgroup_l2)
            .relleno(1)
        )

        x1 = -8
        ly_group = Colocacion.V().otro(ly_group).espacio(x1).otro(ly_subgroup_l1).espacio(x1).otro(ly_subgroup_l2)

        gb_group = Controles.GB(self, "%s (%s)" % (_("Group"), "optional"), ly_group)

        lb_summary = Controles.LB2P(self, _("Summary depth (0=disable)"))
        self.sb_summary = Controles.SB(self, dic_data.get("SUMMARY_DEPTH", 12), 0, 999)
        ly_summary = Colocacion.H().control(lb_summary).control(self.sb_summary).relleno(1)

        self.external_folder = d_str("EXTERNAL_FOLDER")
        lb_external = Controles.LB2P(self, _("Store in an external folder"))
        self.bt_external = Controles.PB(self, self.external_folder, self.select_external, False)
        self.bt_external.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        )
        ly_external = Colocacion.H().control(lb_external).control(self.bt_external)

        self.chb_complete = Controles.CHB(self, _("Allow complete games"), d_true("ALLOWS_COMPLETE_GAMES"))
        self.chb_positions = Controles.CHB(self, _("Allow positions"), d_true("ALLOWS_POSITIONS"))
        self.chb_duplicate = Controles.CHB(self, _("Allow duplicates"), d_false("ALLOWS_DUPLICATES"))
        self.chb_zeromoves = Controles.CHB(self, _("Allow without moves"), d_false("ALLOWS_ZERO_MOVES"))
        ly_res = (
            Colocacion.V()
            .controlc(self.chb_complete)
            .controlc(self.chb_positions)
            .controlc(self.chb_duplicate)
            .controlc(self.chb_zeromoves)
        )

        gb_restrictions = Controles.GB(self, _("Import restrictions"), ly_res)

        li_acciones = [
            (_("Save"), Iconos.Aceptar(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.reject),
            None,
        ]
        self.tb = QTVarios.LCTB(self, li_acciones)

        x0 = 16

        layout = Colocacion.V().control(self.tb).espacio(x0)
        layout.otro(ly_name).espacio(x0).control(gb_group).espacio(x0)
        layout.otro(ly_summary).espacio(x0)
        layout.otro(ly_external).espacio(x0)
        layout.control(gb_restrictions)
        layout.margen(9)

        self.setLayout(layout)

        self.ed_name.setFocus()
Example #16
0
    def __init__(self, boardOriginal):
        main_window = boardOriginal.parent()
        titulo = _("Colors")
        icono = Iconos.EditarColores()
        extparam = "WColores"
        QTVarios.WDialogo.__init__(self, main_window, titulo, icono, extparam)

        self.boardOriginal = boardOriginal
        self.configuration = Code.configuration
        self.config_board = boardOriginal.config_board.copia(boardOriginal.config_board._id)
        self.is_base = boardOriginal.config_board._id == "BASE"

        # Temas #######################################################################################################
        li_options = [(_("Your themes"), self.configuration.ficheroTemas)]
        for entry in Util.listdir(Code.path_resource("Themes")):
            filename = entry.name
            if filename.endswith("lktheme3"):
                ctema = filename[:-9]
                li_options.append((ctema, Code.path_resource("Themes", filename)))

        self.cbTemas = Controles.CB(self, li_options, li_options[0][1]).capture_changes(self.cambiadoTema)
        self.lbSecciones = Controles.LB(self, _("Section") + ":")
        self.cbSecciones = Controles.CB(self, [], None).capture_changes(self.cambiadoSeccion)
        self.lb_help = Controles.LB(self, _("Left button to select, Right to show menu"))

        ly_temas = Colocacion.V()
        self.lista_bt_temas = []
        for i in range(12):
            ly = Colocacion.H()
            for j in range(6):
                bt = BotonTema(self, self.cambia_tema)
                ly.control(bt)
                bt.pon_tema(None)
                self.lista_bt_temas.append(bt)
            ly.relleno(1)
            ly_temas.otro(ly)
        ly_temas.relleno(1)

        def crea_lb(txt):
            return Controles.LB(self, txt + ": ").align_right()

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

        # # Blancas
        lbBlancas = crea_lb(_("White squares"))
        self.btBlancas = BotonColor(self, self.config_board.colorBlancas, self.actualizaBoard)
        self.btBlancasPNG = BotonImagen(self, self.config_board.png64Blancas, self.actualizaBoard, self.btBlancas)
        self.dialBlancasTrans = DialNum(self, self.config_board.transBlancas, self.actualizaBoard)

        # # Negras
        lbNegras = crea_lb(_("Black squares"))
        self.btNegras = BotonColor(self, self.config_board.colorNegras, self.actualizaBoard)
        self.btNegrasPNG = BotonImagen(self, self.config_board.png64Negras, self.actualizaBoard, self.btNegras)
        self.dialNegrasTrans = DialNum(self, self.config_board.transNegras, self.actualizaBoard)

        # Background
        lbFondo = crea_lb(_("Background"))
        self.btFondo = BotonColor(self, self.config_board.colorFondo, self.actualizaBoard)
        self.btFondoPNG = BotonImagen(self, self.config_board.png64Fondo, self.actualizaBoard, self.btFondo)
        self.chbExtended = Controles.CHB(self, _("Extended to outer border"), self.config_board.extendedColor()).capture_changes(self, self.extendedColor)

        # Actual
        self.chbTemas = Controles.CHB(self, _("Default"), self.config_board.siDefTema()).capture_changes(self, self.defectoTemas)
        if self.is_base:
            self.chbTemas.ponValor(False)
            self.chbTemas.setVisible(False)
        # Exterior
        lbExterior = crea_lb(_("Outer Border"))
        self.btExterior = BotonColor(self, self.config_board.colorExterior, self.actualizaBoard)
        self.btExteriorPNG = BotonImagen(self, self.config_board.png64Exterior, self.actualizaBoard, self.btExterior)

        # Texto
        lbTexto = crea_lb(_("Coordinates"))
        self.btTexto = BotonColor(self, self.config_board.colorTexto, self.actualizaBoard)
        # Frontera
        lbFrontera = crea_lb(_("Inner Border"))
        self.btFrontera = BotonColor(self, self.config_board.colorFrontera, self.actualizaBoard)

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

        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).otroc(self.btExteriorPNG, 4, 2)
        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).control(self.lb_help).relleno()
        ly = Colocacion.V().control(self.cbTemas).otro(lySecciones).otro(ly_temas).control(gbActual).relleno()
        gbTemas = Controles.GB(self, "", ly)
        gbTemas.setFlat(True)

        # mas options ################################################################################################
        def xDefecto(if_default):
            if self.is_base:
                if_default = False
            chb = Controles.CHB(self, _("Default"), if_default).capture_changes(self, self.defectoBoardM)
            if self.is_base:
                chb.setVisible(False)
            return chb

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

        # Coordenadas
        lyG = Colocacion.G()
        # _nCoordenadas
        lbCoordenadas = crea_lb(_("Number"))
        li_options = [("0", 0), ("4", 4), ("2a", 2), ("2b", 3), ("2c", 5), ("2d", 6)]
        self.cbCoordenadas = Controles.CB(self, li_options, self.config_board.nCoordenadas()).capture_changes(self.actualizaBoardM)
        self.chbDefCoordenadas = xDefecto(self.config_board.siDefCoordenadas())
        l2mas1(lyG, 0, lbCoordenadas, self.cbCoordenadas, self.chbDefCoordenadas)

        # _tipoLetra
        lbTipoLetra = crea_lb(_("Font"))
        self.cbTipoLetra = QtWidgets.QFontComboBox()
        self.cbTipoLetra.setEditable(False)
        self.cbTipoLetra.setFontFilters(self.cbTipoLetra.ScalableFonts)
        self.cbTipoLetra.setCurrentFont(QtGui.QFont(self.config_board.tipoLetra()))
        self.cbTipoLetra.currentIndexChanged.connect(self.actualizaBoardM)
        self.chbDefTipoLetra = xDefecto(self.config_board.siDefTipoLetra())
        l2mas1(lyG, 1, lbTipoLetra, self.cbTipoLetra, self.chbDefTipoLetra)

        # _cBold
        self.chbBold = Controles.CHB(self, _("Bold"), self.config_board.siBold()).capture_changes(self, self.actualizaBoardM)
        self.chbDefBold = xDefecto(self.config_board.siDefBold())
        l2mas1(lyG, 2, None, self.chbBold, self.chbDefBold)

        # _tamLetra
        lbTamLetra = crea_lb(_("Size") + " %")
        self.sbTamLetra = Controles.SB(self, self.config_board.tamLetra(), 1, 200).tamMaximo(50).capture_changes(self.actualizaBoardM)
        self.chbDefTamLetra = xDefecto(self.config_board.siDefTamLetra())
        l2mas1(lyG, 3, lbTamLetra, self.sbTamLetra, self.chbDefTamLetra)

        # _sepLetras
        lbSepLetras = crea_lb(_("Separation") + " %")
        self.sbSepLetras = Controles.SB(self, self.config_board.sepLetras(), -1000, 1000).tamMaximo(50).capture_changes(self.actualizaBoardM)
        self.chbDefSepLetras = xDefecto(self.config_board.siDefSepLetras())
        l2mas1(lyG, 4, lbSepLetras, self.sbSepLetras, self.chbDefSepLetras)

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

        ly_otros = Colocacion.G()
        # _nomPiezas
        li = []
        lbPiezas = crea_lb(_("Pieces"))
        for entry in Util.listdir(Code.path_resource("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.config_board.nomPiezas()).capture_changes(self.actualizaBoardM)
        self.chbDefPiezas = xDefecto(self.config_board.siDefPiezas())
        l2mas1(ly_otros, 0, lbPiezas, self.cbPiezas, self.chbDefPiezas)

        # _tamRecuadro
        lbTamRecuadro = crea_lb(_("Outer Border Size") + " %")
        self.sbTamRecuadro = Controles.SB(self, self.config_board.tamRecuadro(), 0, 10000).tamMaximo(50).capture_changes(self.actualizaBoardM)
        self.chbDefTamRecuadro = xDefecto(self.config_board.siDefTamRecuadro())
        l2mas1(ly_otros, 1, lbTamRecuadro, self.sbTamRecuadro, self.chbDefTamRecuadro)

        # _tamFrontera
        lbTamFrontera = crea_lb(_("Inner Border Size") + " %")
        self.sbTamFrontera = Controles.SB(self, self.config_board.tamFrontera(), 0, 10000).tamMaximo(50).capture_changes(self.actualizaBoardM)
        self.chbDefTamFrontera = xDefecto(self.config_board.siDefTamFrontera())
        l2mas1(ly_otros, 2, lbTamFrontera, self.sbTamFrontera, self.chbDefTamFrontera)

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

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

        # Board #####################################################################################################
        cp = Position.Position().read_fen("2kr1b1r/2p1pppp/p7/3pPb2/1q3P2/2N1P3/PPP3PP/R1BQK2R w KQ - 0 1")
        self.board = Board.Board(self, self.config_board, siMenuVisual=False)
        self.board.crea()
        self.board.set_position(cp)
        self.rehazFlechas()

        li_acciones = [
            (_("Accept"), Iconos.Aceptar(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            ("%s/%s" % (_("Save"), _("Save as")), Iconos.Grabar(), self.menu_save),
            None,
            (_("Import"), Iconos.Import8(), self.importar),
            None,
            (_("Export"), Iconos.Export8(), self.exportar),
            None,
        ]
        tb = QTVarios.LCTB(self, li_acciones)

        # tam board
        self.lbTamBoard = Controles.LB(self, "%d px" % self.board.width())

        # Juntamos
        lyT = Colocacion.V().control(tb).espacio(15).control(self.board).controli(self.lbTamBoard).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.li_themes = self.read_own_themes()
        self.current_theme = {"NOMBRE": "", "SECCION": "", "CHANGE_PIECES": True, "o_tema": self.config_board.grabaTema(), "o_base": self.config_board.grabaBase()}
        self.own_theme_selected = False
        self.cambiadoTema()
        self.defectoTemas()

        self.extendedColor()

        self.siActualizando = False

        self.restore_video(siTam=False)
Example #17
0
    def __init__(self, w_parent, rival, categorias, categoria, configuration):
        super(wDatos, self).__init__(w_parent)

        self.setWindowTitle(_("New game"))
        self.setWindowIcon(Iconos.Datos())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        tb = QTUtil2.tbAcceptCancel(self)

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

        self.max_level, self.maxNivelHecho, self.max_puntos = categorias.max_level_by_category(
            categoria)
        # self.max_level = max_level = categoria.level_done+1
        # self.maxNivelHecho = categoria.hecho
        # self.max_puntos = categoria.max_puntos()

        self.ed = Controles.SB(self, self.max_level, 1,
                               self.max_level).tamMaximo(40)
        lb = Controles.LB(self, categoria.name() + " " + _("Level"))

        lb.ponFuente(f)
        self.lbPuntos = Controles.LB(self).align_right()
        self.ed.valueChanged.connect(self.nivelCambiado)

        is_white = not categoria.done_with_white()
        self.rb_white = QtWidgets.QRadioButton(_("White"))
        self.rb_white.setChecked(is_white)
        self.rb_black = QtWidgets.QRadioButton(_("Black"))
        self.rb_black.setChecked(not is_white)

        self.rb_white.clicked.connect(self.ponMaxPuntos)
        self.rb_black.clicked.connect(self.ponMaxPuntos)

        # Rival
        lbRMotor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Engine"), rival.name)).ponFuente(flb).set_wrap().anchoFijo(400)
        lbRAutor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Author"),
             rival.autor)).ponFuente(flb).set_wrap().anchoFijo(400)
        lbRWeb = (Controles.LB(
            self, '<b>%s</b> : <a href="%s">%s</a>' %
            (_("Web"), rival.url,
             rival.url)).set_wrap().anchoFijo(400).ponFuente(flb))

        ly = Colocacion.V().control(lbRMotor).control(lbRAutor).control(
            lbRWeb).margen(10)
        gbR = Controles.GB(self, _("Opponent"), ly).ponFuente(f)

        # Tutor
        tutor = configuration.tutor
        lbTMotor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Engine"), tutor.name)).ponFuente(flb).set_wrap().anchoFijo(400)
        lbTAutor = Controles.LB(
            self, "<b>%s</b> : %s" %
            (_("Author"),
             tutor.autor)).ponFuente(flb).set_wrap().anchoFijo(400)
        siURL = hasattr(tutor, "url")
        if siURL:
            lbTWeb = (Controles.LB(
                self, '<b>%s</b> : <a href="%s">%s</a>' %
                ("Web", tutor.url,
                 tutor.url)).set_wrap().anchoFijo(400).ponFuente(flb))

        ly = Colocacion.V().control(lbTMotor).control(lbTAutor)
        if siURL:
            ly.control(lbTWeb)
        ly.margen(10)
        gbT = Controles.GB(self, _("Tutor"), ly).ponFuente(f)

        hbox = Colocacion.H().relleno().control(
            self.rb_white).espacio(10).control(self.rb_black).relleno()
        gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(f)

        lyNivel = Colocacion.H().control(lb).control(
            self.ed).espacio(10).control(self.lbPuntos).relleno()

        vlayout = Colocacion.V().otro(lyNivel).espacio(10).control(
            gbColor).espacio(10).control(gbR).espacio(10).control(gbT).margen(
                30)

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

        self.setLayout(layout)

        self.ponMaxPuntos()
Example #18
0
    def __init__(self, wParent, nombre_torneo):

        torneo = self.torneo = Tournament.Tournament(nombre_torneo)

        titulo = nombre_torneo
        icono = Iconos.Torneos()
        extparam = "untorneo_v1"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        self.configuracion = Code.configuracion

        # Datos

        self.liEnActual = []
        self.xjugar = None
        self.liResult = None
        self.last_change = Util.today()
        self.li_results = []

        # Toolbar
        tb = Controles.TBrutina(self, tamIcon=24)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        tb.new(_("Launch a worker"), Iconos.Lanzamiento(), self.gm_launch)

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

        # Tab-configuracion --------------------------------------------------
        w = QtWidgets.QWidget()

        # Adjudicator
        lb_resign = Controles.LB(
            self, "%s (%s): " %
            (_("Minimum centipawns to assign winner"), _("0=disable")))
        self.ed_resign = Controles.ED(self).tipoInt(
            torneo.resign()).anchoFijo(30)
        bt_resign = Controles.PB(self, "", rutina=self.borra_resign).ponIcono(
            Iconos.Reciclar())

        # Draw-plys
        lbDrawMinPly = Controles.LB(
            self,
            "%s (%s): " % (_("Minimum moves to assign draw"), _("0=disable")))
        self.sbDrawMinPly = Controles.SB(self, torneo.drawMinPly(), 20, 1000)
        # Draw-puntos
        lb_draw_range = Controles.LB(
            self,
            _("Maximum centipawns to assign draw") + ": ")
        self.ed_draw_range = Controles.ED(self).tipoInt(
            torneo.drawRange()).anchoFijo(30)
        bt_draw_range = Controles.PB(
            self, "", rutina=self.borra_draw_range).ponIcono(Iconos.Reciclar())

        # adjudicator
        self.liMotores = self.configuracion.comboMotoresMultiPV10()
        self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB(
            self, self.liMotores, torneo.adjudicator(), _("Engine"))
        self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat(
            1.0).anchoFijo(50).ponFloat(torneo.adjudicator_time())
        self.lbJtiempo = Controles.LB2P(self, _("Time in seconds"))
        layout = Colocacion.G()
        layout.controld(self.lbJmotor, 3, 0).control(self.cbJmotor, 3, 1)
        layout.controld(self.lbJtiempo, 4, 0).control(self.edJtiempo, 4, 1)
        self.gbJ = Controles.GB(self, _("Adjudicator"), layout)
        self.gbJ.setCheckable(True)
        self.gbJ.setChecked(torneo.adjudicator_active())

        lbBook = Controles.LB(self, _("Opening book") + ": ")
        fvar = self.configuracion.ficheroBooks
        self.listaLibros = Books.ListaLibros()
        self.listaLibros.restore_pickle(fvar)
        # Comprobamos que todos esten accesibles
        self.listaLibros.comprueba()
        li = [(x.name, x.path) for x in self.listaLibros.lista]
        li.insert(0, ("* " + _("None"), "-"))
        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()

        lbBookDepth = Controles.LB(self,
                                   _("Max depth of book (0=Maximum)") + ": ")
        self.sbBookDepth = Controles.SB(self, torneo.bookDepth(), 0, 200)

        # 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()
        ly_res = Colocacion.H().control(
            self.ed_resign).control(bt_resign).relleno()
        ly_dra = Colocacion.H().control(
            self.ed_draw_range).control(bt_draw_range).relleno()
        layout.controld(lb_resign, 0, 0).otro(ly_res, 0, 1)
        layout.controld(lbDrawMinPly, 1, 0).control(self.sbDrawMinPly, 1, 1)
        layout.controld(lb_draw_range, 2, 0).otro(ly_dra, 2, 1)
        layout.controld(lbBook, 3, 0).otro(lyBook, 3, 1)
        layout.controld(lbBookDepth, 4, 0).control(self.sbBookDepth, 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).control(
            self.gbJ).relleno()
        layoutH = Colocacion.H().relleno().otro(layoutV).relleno()

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

        # Tab-engines --------------------------------------------------
        self.splitterEngines = QtWidgets.QSplitter(self)
        self.register_splitter(self.splitterEngines, "engines")
        # TB
        li_acciones = [
            (_("New"), Iconos.TutorialesCrear(), self.enNuevo),
            None,
            (_("Modify"), Iconos.Modificar(), self.enModificar),
            None,
            (_("Remove"), Iconos.Borrar(), self.enBorrar),
            None,
            (_("Copy"), Iconos.Copiar(), self.enCopiar),
            None,
            (_("Import"), Iconos.MasDoc(), self.enImportar),
            None,
        ]
        tbEnA = Controles.TBrutina(self,
                                   li_acciones,
                                   tamIcon=16,
                                   style=QtCore.Qt.ToolButtonTextBesideIcon)

        # Grid engine
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 50, centered=True)
        o_columns.nueva("ALIAS", _("Alias"), 209)
        self.gridEnginesAlias = Grid.Grid(self,
                                          o_columns,
                                          siSelecFilas=True,
                                          siSeleccionMultiple=True,
                                          xid=GRID_ALIAS)
        self.register_grid(self.gridEnginesAlias)

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

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

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

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

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

        # Creamos

        # Tab-games queued--------------------------------------------------
        w = QtWidgets.QWidget()
        # TB
        li_acciones = [
            (_("New"), Iconos.TutorialesCrear(), self.gm_crear_queued),
            None,
            (_("Remove"), Iconos.Borrar(), self.gm_borrar_queued),
            None,
        ]
        tbEnG = Controles.TBrutina(self,
                                   li_acciones,
                                   tamIcon=16,
                                   style=QtCore.Qt.ToolButtonTextBesideIcon)

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 50, centered=True)
        o_columns.nueva("WHITE", _("White"), 190, centered=True)
        o_columns.nueva("BLACK", _("Black"), 190, centered=True)
        o_columns.nueva("TIME", _("Time"), 170, centered=True)
        # o_columns.nueva("STATE", _("State"), 190, centered=True)
        self.gridGamesQueued = Grid.Grid(self,
                                         o_columns,
                                         siSelecFilas=True,
                                         siSeleccionMultiple=True,
                                         xid=GRID_GAMES_QUEUED)
        self.register_grid(self.gridGamesQueued)
        # Layout
        layout = Colocacion.V().control(tbEnG).control(self.gridGamesQueued)

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

        # Tab-games terminados--------------------------------------------------
        w = QtWidgets.QWidget()
        # TB
        li_acciones = [
            (_("Remove"), Iconos.Borrar(), self.gm_borrar_finished),
            None,
            (_("Show"), Iconos.PGN(), self.gm_show_finished),
            None,
            (_("Save") + "(%s)" % _("PGN"), Iconos.GrabarComo(),
             self.gm_save_pgn),
            None,
        ]
        tbEnGt = Controles.TBrutina(self,
                                    li_acciones,
                                    tamIcon=16,
                                    style=QtCore.Qt.ToolButtonTextBesideIcon)

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 50, centered=True)
        o_columns.nueva("WHITE", _("White"), 190, centered=True)
        o_columns.nueva("BLACK", _("Black"), 190, centered=True)
        o_columns.nueva("TIME", _("Time"), 170, centered=True)
        o_columns.nueva("RESULT", _("Result"), 190, centered=True)
        self.gridGamesFinished = Grid.Grid(self,
                                           o_columns,
                                           siSelecFilas=True,
                                           siSeleccionMultiple=True,
                                           xid=GRID_GAMES_FINISHED)
        self.register_grid(self.gridGamesFinished)
        # Layout
        layout = Colocacion.V().control(tbEnGt).control(self.gridGamesFinished)

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

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

        # Grid
        wh = _("W")
        bl = _("B")
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 35, centered=True)
        o_columns.nueva("ENGINE", _("Engine"), 120, centered=True)
        o_columns.nueva("SCORE", _("Score") + "%", 50, centered=True)
        o_columns.nueva("WIN", _("Wins"), 50, centered=True)
        o_columns.nueva("DRAW", _("Draws"), 50, centered=True)
        o_columns.nueva("LOST", _("Losses"), 50, centered=True)
        o_columns.nueva("WIN-WHITE",
                        "%s %s" % (wh, _("Wins")),
                        60,
                        centered=True)
        o_columns.nueva("DRAW-WHITE",
                        "%s %s" % (wh, _("Draws")),
                        60,
                        centered=True)
        o_columns.nueva("LOST-WHITE",
                        "%s %s" % (wh, _("Losses")),
                        60,
                        centered=True)
        o_columns.nueva("WIN-BLACK",
                        "%s %s" % (bl, _("Wins")),
                        60,
                        centered=True)
        o_columns.nueva("DRAW-BLACK",
                        "%s %s" % (bl, _("Draws")),
                        60,
                        centered=True)
        o_columns.nueva("LOST-BLACK",
                        "%s %s" % (bl, _("Losses")),
                        60,
                        centered=True)
        o_columns.nueva("GAMES", _("Games"), 50, centered=True)
        self.gridResults = Grid.Grid(self,
                                     o_columns,
                                     siSelecFilas=True,
                                     xid=GRID_RESULTS)
        self.register_grid(self.gridResults)

        self.qtColor = {
            "WHITE": QTUtil.qtColorRGB(255, 250, 227),
            "BLACK": QTUtil.qtColorRGB(221, 255, 221),
            "SCORE": QTUtil.qtColorRGB(170, 170, 170),
        }

        # Layout
        layout = Colocacion.V().control(self.gridResults)

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

        # Layout
        # tab.setposition("W")
        layout = Colocacion.V().control(tb).espacio(-3).control(tab).margen(2)
        self.setLayout(layout)

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

        self.gridEnginesAlias.gotop()

        self.ed_resign.setFocus()

        self.muestraPosicion()

        QtCore.QTimer.singleShot(5000, self.comprueba_cambios)
        self.rotulos_tabs()
Example #19
0
    def __init__(self, owner, tactica, ncopia=None):
        QtGui.QWidget.__init__(self)

        self.owner = owner
        self.tacticaINI = tactica
        if ncopia is not None:
            regHistorico = tactica.historico()[ncopia]
        else:
            regHistorico = None

        # Total por ficheros
        self.liFTOTAL = tactica.calculaTotales()
        total = sum(self.liFTOTAL)

        # N. puzzles
        if regHistorico:
            num = regHistorico["PUZZLES"]
        else:
            num = tactica.PUZZLES
        if not num or num > total:
            num = total

        lbPuzzles = Controles.LB(
            self,
            _("Max number of puzzles in each block") + ": ")
        self.sbPuzzles = Controles.SB(self, num, 1, total)

        # Reference
        lbReference = Controles.LB(self, _("Reference") + ": ")
        self.edReference = Controles.ED(self)

        # Iconos
        icoMas = Iconos.Add()
        icoMenos = Iconos.Delete()
        icoCancel = Iconos.CancelarPeque()
        icoReset = Iconos.MoverAtras()

        def tbGen(prev):
            liAcciones = (
                (_("Add"), icoMas, "%s_add" % prev),
                (_("Delete"), icoMenos, "%s_delete" % prev),
                None,
                (_("Delete all"), icoCancel, "%s_delete_all" % prev),
                None,
                (_("Reset"), icoReset, "%s_reset" % prev),
                None,
            )
            tb = Controles.TB(self, liAcciones, tamIcon=16, siTexto=False)
            return tb

        f = Controles.TipoLetra(peso=75)

        # Repeticiones de cada puzzle
        if regHistorico:
            self.liJUMPS = regHistorico["JUMPS"][:]
        else:
            self.liJUMPS = tactica.JUMPS[:]
        tb = tbGen("jumps")
        oCol = Columnas.ListaColumnas()
        oCol.nueva("NUMERO", _("Repetition"), 80, siCentrado=True)
        oCol.nueva("JUMPS_SEPARATION",
                   _("Separation"),
                   80,
                   siCentrado=True,
                   edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_jumps = Grid.Grid(self,
                                    oCol,
                                    siSelecFilas=True,
                                    siEditable=True,
                                    id="j")
        self.grid_jumps.setMinimumWidth(self.grid_jumps.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_jumps)
        gbJumps = Controles.GB(self, _("Repetitions of each puzzle"),
                               ly).ponFuente(f)
        self.grid_jumps.gotop()

        # Repeticion del bloque
        if regHistorico:
            self.liREPEAT = regHistorico["REPEAT"][:]
        else:
            self.liREPEAT = tactica.REPEAT[:]
        tb = tbGen("repeat")
        oCol = Columnas.ListaColumnas()
        oCol.nueva("NUMERO", _("Block"), 40, siCentrado=True)
        self.liREPEATtxt = (_("Original"), _("Random"), _("Previous"))
        oCol.nueva("REPEAT_ORDER",
                   _("Order"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.ComboBox(self.liREPEATtxt))
        self.grid_repeat = Grid.Grid(self,
                                     oCol,
                                     siSelecFilas=True,
                                     siEditable=True,
                                     id="r")
        self.grid_repeat.setMinimumWidth(self.grid_repeat.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_repeat)
        gbRepeat = Controles.GB(self, _("Blocks"), ly).ponFuente(f)
        self.grid_repeat.gotop()

        # Penalizaciones
        if regHistorico:
            self.liPENAL = regHistorico["PENALIZATION"][:]
        else:
            self.liPENAL = tactica.PENALIZATION[:]
        tb = tbGen("penal")
        oCol = Columnas.ListaColumnas()
        oCol.nueva("NUMERO", _("N."), 20, siCentrado=True)
        oCol.nueva("PENAL_POSITIONS",
                   _("Positions"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.LineaTexto(siEntero=True))
        oCol.nueva("PENAL_%", _("Affected"), 100, siCentrado=True)
        self.grid_penal = Grid.Grid(self,
                                    oCol,
                                    siSelecFilas=True,
                                    siEditable=True,
                                    id="p")
        self.grid_penal.setMinimumWidth(self.grid_penal.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_penal)
        gbPenal = Controles.GB(self, _("Penalties"), ly).ponFuente(f)
        self.grid_penal.gotop()

        # ShowText
        if regHistorico:
            self.liSHOWTEXT = regHistorico["SHOWTEXT"][:]
        else:
            self.liSHOWTEXT = tactica.SHOWTEXT[:]
        tb = tbGen("show")
        oCol = Columnas.ListaColumnas()
        self.liSHOWTEXTtxt = (_("No"), _("Yes"))
        oCol.nueva("NUMERO", _("N."), 20, siCentrado=True)
        oCol.nueva("SHOW_VISIBLE",
                   _("Visible"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.ComboBox(self.liSHOWTEXTtxt))
        oCol.nueva("SHOW_%", _("Affected"), 100, siCentrado=True)
        self.grid_show = Grid.Grid(self,
                                   oCol,
                                   siSelecFilas=True,
                                   siEditable=True,
                                   id="s")
        self.grid_show.setMinimumWidth(self.grid_show.anchoColumnas() + 20)
        ly = Colocacion.V().control(tb).control(self.grid_show)
        gbShow = Controles.GB(self, _("Show text associated with each puzzle"),
                              ly).ponFuente(f)
        self.grid_show.gotop()

        # Files
        if regHistorico:
            self.liFILES = regHistorico["FILESW"][:]
        else:
            self.liFILES = []
            for num, (fich, w, d, h) in enumerate(tactica.filesw):
                if not d or d < 1:
                    d = 1
                if not h or h > self.liFTOTAL[num] or h < 1:
                    h = self.liFTOTAL[num]
                if d > h:
                    d, h = h, d
                self.liFILES.append([fich, w, d, h])
        oCol = Columnas.ListaColumnas()
        oCol.nueva("FILE", _("File"), 220, siCentrado=True)
        oCol.nueva("WEIGHT",
                   _("Weight"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.LineaTexto(siEntero=True))
        oCol.nueva("TOTAL", _("Total"), 100, siCentrado=True)
        oCol.nueva("FROM",
                   _("From"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.LineaTexto(siEntero=True))
        oCol.nueva("TO",
                   _("To"),
                   100,
                   siCentrado=True,
                   edicion=Delegados.LineaTexto(siEntero=True))
        self.grid_files = Grid.Grid(self,
                                    oCol,
                                    siSelecFilas=True,
                                    siEditable=True,
                                    id="f")
        self.grid_files.setMinimumWidth(self.grid_files.anchoColumnas() + 20)
        ly = Colocacion.V().control(self.grid_files)
        gbFiles = Controles.GB(self, _("FNS files"), ly).ponFuente(f)
        self.grid_files.gotop()

        # Layout
        lyReference = Colocacion.H().control(lbReference).control(
            self.edReference)
        lyPuzzles = Colocacion.H().control(lbPuzzles).control(self.sbPuzzles)
        ly = Colocacion.G()
        ly.otro(lyPuzzles, 0, 0).otro(lyReference, 0, 1)
        ly.filaVacia(1, 5)
        ly.controld(gbJumps, 2, 0).control(gbPenal, 2, 1)
        ly.filaVacia(3, 5)
        ly.controld(gbRepeat, 4, 0)
        ly.control(gbShow, 4, 1)
        ly.filaVacia(5, 5)
        ly.control(gbFiles, 6, 0, 1, 2)

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

        self.setLayout(layout)

        self.grid_repeat.gotop()
    def __init__(self, w_parent, listaMotores, engine, siTorneo=False):

        super(WEngine, self).__init__(w_parent)

        self.setWindowTitle(engine.version)
        self.setWindowIcon(Iconos.Motor())
        self.setWindowFlags(
            QtCore.Qt.WindowCloseButtonHint
            | QtCore.Qt.Dialog
            | QtCore.Qt.WindowTitleHint
            | QtCore.Qt.WindowMinimizeButtonHint
            | QtCore.Qt.WindowMaximizeButtonHint
        )

        scrollArea = wgen_options_engine(self, engine)

        self.motorExterno = engine
        self.liMotores = listaMotores
        self.siTorneo = siTorneo

        # Toolbar
        tb = QTUtil2.tbAcceptCancel(self)

        lbAlias = Controles.LB2P(self, _("Alias"))
        self.edAlias = Controles.ED(self, engine.key).anchoMinimo(360)

        lbNombre = Controles.LB2P(self, _("Name"))
        self.edNombre = Controles.ED(self, engine.name).anchoMinimo(360)

        lbInfo = Controles.LB(self, _("Information") + ": ")
        self.emInfo = Controles.EM(self, engine.id_info, siHTML=False).anchoMinimo(360).altoFijo(60)

        lbElo = Controles.LB(self, "ELO: ")
        self.sbElo = Controles.SB(self, engine.elo, 0, 4000)

        lbExe = Controles.LB(self, "%s: %s" % (_("File"), Util.relative_path(engine.path_exe)))

        if siTorneo:
            lbDepth = Controles.LB(self, _("Maximum depth") + ": ")
            self.sbDepth = Controles.SB(self, engine.depth, 0, 50)

            lbTime = Controles.LB(self, _("Maximum seconds to think") + ": ")
            self.sbTime = Controles.SB(self, engine.time, 0, 9999)

            lbBook = Controles.LB(self, _("Opening book") + ": ")
            fvar = Code.configuration.file_books
            self.list_books = Books.ListBooks()
            self.list_books.restore_pickle(fvar)
            # # Comprobamos que todos esten accesibles
            self.list_books.check()
            li = [(x.name, x.path) for x in self.list_books.lista]
            li.insert(0, ("* " + _("None"), "-"))
            li.insert(0, ("* " + _("Default"), "*"))
            self.cbBooks = Controles.CB(self, li, engine.book)
            btNuevoBook = Controles.PB(self, "", self.nuevoBook, plano=False).ponIcono(Iconos.Nuevo(), icon_size=16)
            # # Respuesta rival
            li = (
                (_("Uniform random"), "au"),
                (_("Proportional random"), "ap"),
                (_("Always the highest percentage"), "mp"),
            )
            self.cbBooksRR = QTUtil2.comboBoxLB(self, li, engine.bookRR)
            lyBook = (
                Colocacion.H()
                .control(lbBook)
                .control(self.cbBooks)
                .control(self.cbBooksRR)
                .control(btNuevoBook)
                .relleno()
            )
            lyDT = (
                Colocacion.H()
                .control(lbDepth)
                .control(self.sbDepth)
                .espacio(40)
                .control(lbTime)
                .control(self.sbTime)
                .relleno()
            )
            lyTorneo = Colocacion.V().otro(lyDT).otro(lyBook)

        # Layout
        ly = Colocacion.G()
        ly.controld(lbAlias, 0, 0).control(self.edAlias, 0, 1)
        ly.controld(lbNombre, 1, 0).control(self.edNombre, 1, 1)
        ly.controld(lbInfo, 2, 0).control(self.emInfo, 2, 1)
        ly.controld(lbElo, 3, 0).control(self.sbElo, 3, 1)
        ly.control(lbExe, 4, 0, 1, 2)

        if siTorneo:
            ly.otro(lyTorneo, 5, 0, 1, 2)

        layout = Colocacion.V().control(tb).espacio(30).otro(ly).control(scrollArea)
        self.setLayout(layout)

        self.edAlias.setFocus()
Example #21
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)
Example #22
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()
Example #23
0
    def __init__(self, wParent, listaMotores, motorExterno, siTorneo=False):

        super(WMotor, self).__init__(wParent)

        self.setWindowTitle(motorExterno.idName)
        self.setWindowIcon(Iconos.Motor())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowMinimizeButtonHint
                            | QtCore.Qt.WindowMaximizeButtonHint)

        scrollArea = genOpcionesME(self, motorExterno)

        self.motorExterno = motorExterno
        self.liMotores = listaMotores if siTorneo else listaMotores.liMotores
        self.siTorneo = siTorneo

        # Toolbar
        tb = QTUtil2.tbAcceptCancel(self)

        lbAlias = Controles.LB(self, _("Alias") + ": ")
        self.edAlias = Controles.ED(self, motorExterno.alias).anchoMinimo(360)

        lbInfo = Controles.LB(self, _("Information") + ": ")
        self.emInfo = Controles.EM(self, motorExterno.idInfo,
                                   siHTML=False).anchoMinimo(360).altoFijo(60)

        lbElo = Controles.LB(self, "ELO" + ": ")
        self.sbElo = Controles.SB(self, motorExterno.elo, 0, 4000)

        if siTorneo:
            lbDepth = Controles.LB(self, _("Maximum depth") + ": ")
            self.sbDepth = Controles.SB(self, motorExterno.depth(), 0, 50)

            lbTime = Controles.LB(self, _("Maximum seconds to think") + ": ")
            self.sbTime = Controles.SB(self, motorExterno.time(), 0, 9999)

            lbBook = Controles.LB(self, _("Opening book") + ": ")
            fvar = VarGen.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, ("* " + _("Engine book"), "-"))
            li.insert(0, ("* " + _("Default"), "*"))
            self.cbBooks = Controles.CB(self, li, motorExterno.book())
            btNuevoBook = Controles.PB(self, "", self.nuevoBook,
                                       plano=False).ponIcono(Iconos.Nuevo(),
                                                             tamIcon=16)
            # # Respuesta rival
            li = (
                (_("Uniform random"), "au"),
                (_("Proportional random"), "ap"),
                (_("Always the highest percentage"), "mp"),
            )
            self.cbBooksRR = QTUtil2.comboBoxLB(self, li,
                                                motorExterno.bookRR())
            lyBook = Colocacion.H().control(lbBook).control(
                self.cbBooks).control(
                    self.cbBooksRR).control(btNuevoBook).relleno()
            lyDT = Colocacion.H().control(lbDepth).control(
                self.sbDepth).espacio(40).control(lbTime).control(
                    self.sbTime).relleno()
            lyTorneo = Colocacion.V().otro(lyDT).otro(lyBook)

        # Layout
        ly = Colocacion.G()
        ly.controld(lbAlias, 0, 0).control(self.edAlias, 0, 1)
        ly.controld(lbInfo, 1, 0).control(self.emInfo, 1, 1)
        ly.controld(lbElo, 2, 0).control(self.sbElo, 2, 1)

        if siTorneo:
            ly.otro(lyTorneo, 3, 0, 1, 2)

        layout = Colocacion.V().control(tb).espacio(30).otro(ly).control(
            scrollArea)
        self.setLayout(layout)

        self.edAlias.setFocus()
Example #24
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()
Example #25
0
    def __init__(self, wParent, sts, work):
        super(WWork, self).__init__(wParent)

        self.work = work

        self.setWindowTitle(sts.name)
        self.setWindowIcon(Iconos.Motor())
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowMinimizeButtonHint
                            | QtCore.Qt.WindowMaximizeButtonHint)

        tb = QTUtil2.tbAcceptCancel(self)

        # Tabs
        tab = Controles.Tab()

        # Tab-basic --------------------------------------------------
        lbRef = Controles.LB(self, _("Reference") + ": ")
        self.edRef = Controles.ED(self, work.ref).anchoMinimo(360)

        lbInfo = Controles.LB(self, _("Information") + ": ")
        self.emInfo = Controles.EM(self, work.info,
                                   siHTML=False).anchoMinimo(360).altoFijo(60)

        lbDepth = Controles.LB(self, _("Maximum depth") + ": ")
        self.sbDepth = Controles.SB(self, work.depth, 0, 50)

        lbSeconds = Controles.LB(self, _("Maximum seconds to think") + ": ")
        self.sbSeconds = Controles.SB(self, work.seconds, 0, 9999)

        lbSample = Controles.LB(self, _("Sample") + ": ")
        self.sbIni = Controles.SB(self, work.ini + 1, 1,
                                  100).capturaCambiado(self.changeSample)
        self.sbIni.isIni = True
        lbGuion = Controles.LB(self, _("to"))
        self.sbEnd = Controles.SB(self, work.end + 1, 1,
                                  100).capturaCambiado(self.changeSample)
        self.sbEnd.isIni = False

        # self.lbError = Controles.LB(self).ponTipoLetra(peso=75).ponColorN("red")
        # self.lbError.hide()

        lySample = Colocacion.H().control(self.sbIni).control(lbGuion).control(
            self.sbEnd)
        ly = Colocacion.G()
        ly.controld(lbRef, 0, 0).control(self.edRef, 0, 1)
        ly.controld(lbInfo, 1, 0).control(self.emInfo, 1, 1)
        ly.controld(lbDepth, 2, 0).control(self.sbDepth, 2, 1)
        ly.controld(lbSeconds, 3, 0).control(self.sbSeconds, 3, 1)
        ly.controld(lbSample, 4, 0).otro(lySample, 4, 1)

        w = QtGui.QWidget()
        w.setLayout(ly)
        tab.nuevaTab(w, _("Basic data"))

        # Tab-Engine
        scrollArea = PantallaMotores.genOpcionesME(self, work.me)
        tab.nuevaTab(scrollArea, _("Engine options"))

        # Tab-Groups
        btAll = Controles.PB(self, _("All"), self.setAll, plano=False)
        btNone = Controles.PB(self, _("None"), self.setNone, plano=False)
        lyAN = Colocacion.H().control(btAll).espacio(10).control(btNone)
        self.liGroups = []
        ly = Colocacion.G()
        ly.columnaVacia(1, 10)
        fil = 0
        col = 0
        num = len(sts.groups)
        mitad = num / 2 + num % 2

        for x in range(num):
            group = sts.groups.group(x)
            chb = Controles.CHB(self, _F(group.name), work.liGroupActive[x])
            self.liGroups.append(chb)
            col = 0 if x < mitad else 2
            fil = x % mitad

            ly.control(chb, fil, col)
        ly.otroc(lyAN, mitad, 0, numColumnas=3)

        w = QtGui.QWidget()
        w.setLayout(ly)
        tab.nuevaTab(w, _("Groups"))

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

        self.edRef.setFocus()