Exemple #1
0
    def __init__(self, wParent, dicValoracion, dicVentaja):
        icono = Iconos.TutorialesCrear()
        extparam = "trainingMyOwnBook"
        titulo = _("Create a training")
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        tb = QTUtil2.tbAcceptCancel(self)

        lbName = Controles.LB(self, _("Name") + ": ")
        self.name = Controles.ED(self).anchoFijo(200)
        lyName = Colocacion.H().relleno().control(lbName).control(
            self.name).relleno()

        self.chbAddSTD = Controles.CHB(
            self, _("Add a label with the standard opening"), True)
        lyNameSTD = Colocacion.V().otro(lyName).control(
            self.chbAddSTD).relleno()

        self.sbDepth, lbDepth = QTUtil2.spinBoxLB(self,
                                                  30,
                                                  2,
                                                  999,
                                                  etiqueta=_("Depth"),
                                                  maxTam=48)
        lyDepth = Colocacion.H().relleno().control(lbDepth).control(
            self.sbDepth).relleno()

        self.rbBlancas = Controles.RB(self, _("White")).activa()
        self.rbNegras = Controles.RB(self, _("Black"))
        hbox = Colocacion.H().control(self.rbBlancas).control(self.rbNegras)
        gbColor = Controles.GB(self, _("Play with"), hbox)

        self.tcWhite = TConf(dicValoracion, dicVentaja)
        ly = Colocacion.H().control(self.tcWhite)
        gbWhite = Controles.GB(self, "", ly)
        gbWhite.setStyleSheet("QWidget { background-color: %s }" % "Ivory")

        self.tcBlack = TConf(dicValoracion, dicVentaja)
        ly = Colocacion.H().control(self.tcBlack)
        gbBlack = Controles.GB(self, "", ly)
        gbBlack.setStyleSheet("QWidget { background-color: %s }" % "Lavender")

        tab = Controles.Tab()
        tab.nuevaTab(gbWhite, _("Conditions to White"))
        tab.nuevaTab(gbBlack, _("Conditions to Black"))

        lyHead = Colocacion.H().otro(lyNameSTD).espacio(15).otro(
            lyDepth).espacio(15).control(gbColor)

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

        self.setLayout(layout)

        self.recuperarVideo()

        self.siAceptado = False
Exemple #2
0
    def __init__(self, wParent, configuracion, dic, siGestorSolo):
        super(WCambioRival, self).__init__(wParent)

        if not dic:
            dic = {}

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.setLayout(layout)

        self.dic = dic
        self.recuperaDic()

        self.ajustesCambiado()
        self.ponRival()
Exemple #3
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()
Exemple #4
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()
    def __init__(self, wparent, is_game, game):
        self.game = game
        self.position = game.first_position
        self.configuration = configuration = Code.configuration

        self.is_game = is_game

        self.wparent = wparent

        QtWidgets.QWidget.__init__(self, wparent)

        li_acciones = (
            (_("Save"), Iconos.GrabarComo(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("Start position"), Iconos.Inicio(), self.inicial),
            None,
            (_("Clear board"), Iconos.Borrar(), self.limpiaBoard),
            (_("Paste FEN position"), Iconos.Pegar16(), self.pegar),
            (_("Copy FEN position"), Iconos.Copiar(), self.copiar),
            (_("Scanner"), Iconos.Scanner(), self.scanner),
        )

        self.tb = Controles.TBrutina(self,
                                     li_acciones,
                                     with_text=False,
                                     icon_size=20)

        config_board = configuration.config_board("VOYAGERPOS", 24)
        self.board = Board.PosBoard(self, config_board)
        self.board.crea()
        self.board.set_dispatcher(self.mueve)
        self.board.mensBorrar = self.borraCasilla
        self.board.mensCrear = self.creaCasilla
        self.board.mensRepetir = self.repitePieza
        self.board.ponDispatchDrop(self.dispatchDrop)
        self.board.baseCasillasSC.setAcceptDrops(True)

        dragDropWB = QTVarios.ListaPiezas(self,
                                          "P,N,B,R,Q,K",
                                          self.board,
                                          margen=0)
        dragDropBA = QTVarios.ListaPiezas(self,
                                          "k,q,r,b,n,p",
                                          self.board,
                                          margen=0)

        self.rbWhite = Controles.RB(self, _("White"), rutina=self.cambiaColor)
        self.rbBlack = Controles.RB(self, _("Black"), rutina=self.cambiaColor)

        self.cbWoo = Controles.CHB(self, _("White") + " O-O", True)
        self.cbWooo = Controles.CHB(self, _("White") + " O-O-O", True)
        self.cbBoo = Controles.CHB(self, _("Black") + " O-O", True)
        self.cbBooo = Controles.CHB(self, _("Black") + " O-O-O", True)

        lbEnPassant = Controles.LB(self, _("En passant") + ":")
        self.edEnPassant = Controles.ED(self).controlrx(
            "(-|[a-h][36])").anchoFijo(30)

        self.edMovesPawn, lbMovesPawn = QTUtil2.spinBoxLB(
            self, 0, 0, 999, etiqueta=_("Halfmove clock"), maxTam=50)

        self.edFullMoves, lbFullMoves = QTUtil2.spinBoxLB(
            self, 1, 1, 999, etiqueta=_("Fullmove number"), maxTam=50)

        self.vars_scanner = Scanner.Scanner_vars(
            self.configuration.carpetaScanners)

        self.lb_scanner = Controles.LB(self)

        pb_scanner_deduce = Controles.PB(self,
                                         _("Deduce"),
                                         self.scanner_deduce,
                                         plano=False)
        self.chb_scanner_flip = Controles.CHB(self, _("Flip the board"),
                                              False).capture_changes(
                                                  self, self.scanner_flip)
        self.pb_scanner_learn = Controles.PB(self,
                                             _("Learn"),
                                             self.scanner_learn,
                                             plano=False)
        self.pb_scanner_learn_quit = Controles.PB(
            self, "", self.scanner_learn_quit).ponIcono(Iconos.Menos(),
                                                        icon_size=24)
        self.pb_scanner_learn_quit.ponToolTip(
            _("Remove last learned")).anchoFijo(24)

        self.sb_scanner_tolerance, lb_scanner_tolerance = QTUtil2.spinBoxLB(
            self,
            self.vars_scanner.tolerance,
            3,
            20,
            etiqueta=_("Deduction tolerance"),
            maxTam=50)
        self.sb_scanner_tolerance_learns, lb_scanner_tolerance_learns = QTUtil2.spinBoxLB(
            self,
            self.vars_scanner.tolerance_learns,
            1,
            6,
            etiqueta=_("Learning tolerance"),
            maxTam=50)

        self.chb_rem_ghost_deductions = Controles.CHB(
            self, _("Remove ghost deductions"), self.vars_scanner.rem_ghost)

        self.cb_scanner_select, lb_scanner_select = QTUtil2.comboBoxLB(
            self, [], None, _("OPR"))
        self.cb_scanner_select.capture_changes(self.scanner_change)
        pb_scanner_more = Controles.PB(self, "", self.scanner_more).ponIcono(
            Iconos.Mas())

        self.chb_scanner_ask = Controles.CHB(self, _("Ask before new capture"),
                                             self.vars_scanner.ask)

        self.li_scan_pch = []
        self.is_scan_init = False

        # LAYOUT -------------------------------------------------------------------------------------------
        hbox = Colocacion.H().control(self.rbWhite).espacio(15).control(
            self.rbBlack)
        gbColor = Controles.GB(self, _("Side to play"), hbox)

        ly = Colocacion.G().control(self.cbWoo, 0, 0).control(self.cbBoo, 0, 1)
        ly.control(self.cbWooo, 1, 0).control(self.cbBooo, 1, 1)
        gbEnroques = Controles.GB(self, _("Castling moves possible"), ly)

        ly = Colocacion.G()
        ly.controld(lbMovesPawn, 0, 0, 1, 3).control(self.edMovesPawn, 0, 3)
        ly.controld(lbEnPassant, 1, 0).control(self.edEnPassant, 1, 1)
        ly.controld(lbFullMoves, 1, 2).control(self.edFullMoves, 1, 3)
        gbOtros = Controles.GB(self, "", ly)

        lyT = (Colocacion.H().relleno().control(lb_scanner_tolerance).espacio(
            5).control(self.sb_scanner_tolerance).relleno())
        lyTL = (Colocacion.H().relleno().control(
            lb_scanner_tolerance_learns).espacio(5).control(
                self.sb_scanner_tolerance_learns).relleno())
        lyL = Colocacion.H().control(self.pb_scanner_learn).control(
            self.pb_scanner_learn_quit)
        lyS = Colocacion.H().control(lb_scanner_select).control(
            self.cb_scanner_select).control(pb_scanner_more)
        ly = Colocacion.V().control(self.chb_scanner_flip).control(
            pb_scanner_deduce).otro(lyL).otro(lyT).otro(lyTL)
        ly.control(self.chb_rem_ghost_deductions).otro(lyS)
        ly.control(self.chb_scanner_ask)
        self.gb_scanner = Controles.GB(self, _("Scanner"), ly)

        lyG = Colocacion.G()
        lyG.controlc(dragDropBA, 0, 0)
        lyG.control(self.board, 1, 0).control(self.lb_scanner, 1, 1)
        lyG.controlc(dragDropWB, 2, 0).controlc(self.gb_scanner,
                                                2,
                                                1,
                                                numFilas=4)
        lyG.controlc(gbColor, 3, 0)
        lyG.controlc(gbEnroques, 4, 0)
        lyG.controlc(gbOtros, 5, 0)

        layout = Colocacion.V()
        layout.controlc(self.tb)
        layout.otro(lyG)
        layout.margen(1)
        self.setLayout(layout)

        self.ultimaPieza = "P"
        self.piezas = self.board.piezas
        self.resetPosicion()
        self.ponCursor()

        self.lb_scanner.hide()
        self.pb_scanner_learn_quit.hide()
        self.gb_scanner.hide()
Exemple #6
0
    def __init__(self, procesador):
        w_parent = procesador.main_window
        self.configuration = procesador.configuration
        self.procesador = procesador

        titulo = _("Training with a book")
        icono = Iconos.Libros()

        QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, "bookstrain")

        self.setMinimumWidth(450)

        flb = Controles.TipoLetra(puntos=10)

        # Variables antiguas
        dic_data = self.restore()

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

        # Side
        self.rb_white = Controles.RB(self, _("White"))
        self.rb_white.setChecked(dic_data.get(self.ISWHITE, True))
        self.rb_black = Controles.RB(self, _("Black"))
        self.rb_black.setChecked(not dic_data.get(self.ISWHITE, True))

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

        # Books
        fvar = self.configuration.file_books
        self.list_books = Books.ListBooks()
        self.list_books.restore_pickle(fvar)
        self.list_books.check()
        li = [(x.name, x) for x in self.list_books.lista]

        # Player
        book_player = li[0][1] if li else None

        nom_book_player = dic_data.get(self.BOOK_PLAYER)
        if nom_book_player:
            for nom, book in li:
                if nom == nom_book_player:
                    book_player = book
                    break
        self.cb_player = Controles.CB(self, li, book_player)

        btNuevo = Controles.PB(self, "", self.nuevo,
                               plano=False).ponIcono(Iconos.Nuevo(),
                                                     icon_size=16)
        btBorrar = Controles.PB(self, "", self.borrar,
                                plano=False).ponIcono(Iconos.Borrar(),
                                                      icon_size=16)

        self.chb_highest = Controles.CHB(
            self, _("Always the highest percentage"),
            dic_data.get(self.ALWAYS_HIGHEST, False))

        lybook = Colocacion.H().relleno().control(
            self.cb_player).control(btNuevo).control(btBorrar).relleno()
        ly_select = Colocacion.H().relleno().control(
            self.chb_highest).relleno()

        ly = Colocacion.V().otro(lybook).espacio(10).otro(ly_select)
        gb_player = Controles.GB(self, _("Player's book"), ly).ponFuente(flb)

        # Rival
        book_rival = book_player

        nom_book_rival = dic_data.get(self.BOOK_RIVAL)
        if nom_book_rival:
            for nom, book in li:
                if nom == nom_book_rival:
                    book_rival = book
                    break
        self.cb_rival = Controles.CB(self, li, book_rival)

        li = (
            (_("Selected by the player"), "su"),
            (_("Uniform random"), "au"),
            (_("Proportional random"), "ap"),
            (_("Always the highest percentage"), "mp"),
        )
        self.cb_resp_rival = Controles.CB(self, li,
                                          dic_data.get(self.RESP_RIVAL, "au"))

        ly = Colocacion.V().controlc(self.cb_rival).espacio(10).controlc(
            self.cb_resp_rival)
        gb_rival = Controles.GB(self, _("Rival book"), ly).ponFuente(flb)

        self.chb_showmenu = Controles.CHB(
            self, _("Display a menu of alternatives if move is invalid"),
            dic_data.get(self.SHOW_MENU, True))

        vlayout = Colocacion.V()
        vlayout.control(gb_side).espacio(5)
        vlayout.control(gb_player).espacio(5)
        vlayout.control(gb_rival).espacio(5)
        vlayout.control(self.chb_showmenu).espacio(5)
        vlayout.margen(20)

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

        self.setLayout(layout)

        self.restore_video()
Exemple #7
0
    def __init__(self, wowner, gestor, alm, muestraAnalisis):
        titulo = _("Result of analysis")
        icono = Iconos.Estadisticas()
        extparam = "estadisticasv1"
        QTVarios.WDialogo.__init__(self, wowner, titulo, icono, extparam)
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowMinimizeButtonHint)

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

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

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

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

        self.tabGrid = tabGrid = Controles.Tab()
        tabGrid.nuevaTab(gridAll, _("All moves"))
        tabGrid.nuevaTab(gridW, _("White"))
        tabGrid.nuevaTab(gridB, _("Black"))
        tabGrid.nuevaTab(wIdx, _("Indexes"))
        tabGrid.dispatchChange(self.tabChanged)
        self.tabActive = 0

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

        self.capturas = WCapturas.CapturaLista(self, self.tablero)
        ly_tc = Colocacion.H().control(self.tablero).control(self.capturas)

        self.rbShowValues = Controles.RB(self,
                                         _("Values"),
                                         rutina=self.cambiadoShow).activa(True)
        self.rbShowElo = Controles.RB(self,
                                      _("Elo perfomance"),
                                      rutina=self.cambiadoShow)
        self.chbShowLostPoints = Controles.CHB(
            self, _("Show lost points"),
            self.getShowLostPoints()).capturaCambiado(
                self, self.showLostPointsChanged)
        ly_rb = Colocacion.H().espacio(40).control(
            self.rbShowValues).espacio(20).control(
                self.rbShowElo).espacio(30).control(
                    self.chbShowLostPoints).relleno(1)

        layout = Colocacion.G()
        layout.controlc(tabGrid, 0, 0)
        layout.otroc(ly_rb, 1, 0)
        layout.otroc(ly_tc, 0, 1, numFilas=2)

        Controles.Tab().ponPosicion("W")
        ancho = self.tablero.width() + anchoGrid
        self.htotal = [
            Histogram.Histogram(self, alm.hgame, gridAll, ancho, True),
            Histogram.Histogram(self, alm.hwhite, gridW, ancho, True),
            Histogram.Histogram(self, alm.hblack, gridB, ancho, True),
            Histogram.Histogram(self, alm.hgame, gridAll, ancho, False,
                                alm.eloT),
            Histogram.Histogram(self, alm.hwhite, gridW, ancho, False,
                                alm.eloW),
            Histogram.Histogram(self, alm.hblack, gridB, ancho, False,
                                alm.eloB)
        ]
        lh = Colocacion.V()
        for x in range(6):
            lh.control(self.htotal[x])
            if x:
                self.htotal[x].hide()

        layout.otroc(lh, 2, 0, 1, 3)
        self.setLayout(layout)

        self.recuperarVideo(siTam=False)

        gridAll.gotop()
        gridB.gotop()
        gridW.gotop()
        self.gridBotonIzquierdo(gridAll, 0, None)
        self.tabGrid.setFixedHeight(self.tablero.height())
        self.adjustSize()
Exemple #8
0
    def __init__(self, procesador):
        self.configuration = procesador.configuration
        self.procesador = procesador

        self.db_histo = UtilSQL.DictSQL(self.configuration.ficheroGMhisto)
        self.opening_block = None
        self.li_preferred_openings = []

        w_parent = procesador.main_window
        titulo = _("Play like a Grandmaster")
        icono = Iconos.GranMaestro()

        extparam = "gm"
        QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam)

        flb = Controles.TipoLetra(puntos=procesador.configuration.x_menu_points)

        # Toolbar
        li_acciones = [
            (_("Accept"), Iconos.Aceptar(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("One game"), Iconos.Uno(), self.unJuego),
            None,
            (_("Import"), Iconos.ImportarGM(), self.importar),
        ]
        tb = Controles.TBrutina(self, li_acciones)

        # Grandes maestros
        self.li_gm = GM.lista_gm()
        gb_style = Common.gb_style()
        li = [(x[0], x[1]) for x in self.li_gm]
        li.insert(0, ("-", None))
        self.cb_gm = QTUtil2.comboBoxLB(self, li, li[0][1] if len(self.li_gm) == 0 else li[1][1])
        self.cb_gm.capture_changes(self.check_gm)
        hbox = Colocacion.H().relleno().control(self.cb_gm).relleno()
        gbGM = Controles.GB(self, _("Choose a Grandmaster"), hbox).ponFuente(flb)
        gbGM.setStyleSheet(gb_style)

        # Personales
        self.li_personal = GM.lista_gm_personal(self.procesador.configuration.personal_training_folder)
        if self.li_personal:
            li = [(x[0], x[1]) for x in self.li_personal]
            li.insert(0, ("-", None))
            self.cbPersonal = QTUtil2.comboBoxLB(self, li, li[0][1])
            self.cbPersonal.capture_changes(self.check_personal)
            btBorrar = Controles.PB(self, "", self.borrarPersonal).ponIcono(Iconos.Borrar(), icon_size=24)
            hbox = Colocacion.H().relleno().control(self.cbPersonal).control(btBorrar).relleno()
            gb_personal = Controles.GB(self, _("Personal games"), hbox).ponFuente(flb)
            gb_personal.setStyleSheet(gb_style)

        # Color
        self.rb_white = Controles.RB(self, _("White"), rutina=self.check_color)
        self.rb_white.setFont(flb)
        self.rb_white.activa(True)
        self.rb_black = Controles.RB(self, _("Black"), rutina=self.check_color)
        self.rb_black.setFont(flb)
        self.rb_black.activa(False)

        # Contrario
        self.chContrario = Controles.CHB(self, _("Choose the opponent's move, when there are multiple possible answers"), False)

        # Juez
        liDepths = [("--", 0)]
        for x in range(1, 31):
            liDepths.append((str(x), x))
        self.liMotores = self.configuration.comboMotoresMultiPV10()
        self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB(self, self.liMotores, self.configuration.tutor_inicial, _("Engine"))
        self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat(1.0).anchoFijo(50)
        self.lbJtiempo = Controles.LB2P(self, _("Time in seconds"))
        self.cbJdepth = Controles.CB(self, liDepths, 0).capture_changes(self.change_depth)
        self.lbJdepth = Controles.LB2P(self, _("Depth"))
        self.lbJshow = Controles.LB2P(self, _("Show rating"))
        self.chbEvals = Controles.CHB(self, _("Show all evaluations"), False)
        li_options = [(_("All moves"), None), (_("Moves are different"), True), (_("Never"), False)]
        self.cbJshow = Controles.CB(self, li_options, True)
        self.lbJmultiPV = Controles.LB2P(self, _("Number of moves evaluated by engine(MultiPV)"))
        li = [(_("Default"), "PD"), (_("Maximum"), "MX")]
        for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200):
            li.append((str(x), str(x)))
        self.cbJmultiPV = Controles.CB(self, li, "PD")

        self.li_adjudicator_controls = (
            self.cbJmotor,
            self.lbJmotor,
            self.edJtiempo,
            self.lbJtiempo,
            self.lbJdepth,
            self.cbJdepth,
            self.lbJshow,
            self.cbJshow,
            self.lbJmultiPV,
            self.cbJmultiPV,
            self.chbEvals,
        )

        for control in self.li_adjudicator_controls:
            control.setFont(flb)

        # Inicial
        self.edJugInicial, lbInicial = QTUtil2.spinBoxLB(self, 1, 1, 99, etiqueta=_("Initial move"), maxTam=40)

        # Libros
        fvar = self.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) for x in self.list_books.lista]
        li.insert(0, ("--", None))
        self.cbBooks, lbBooks = QTUtil2.comboBoxLB(self, li, None, _("Bypass moves in the book"))

        # Openings

        self.btOpening = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.aperturasEditar).ponPlano(False)
        self.btOpeningsFavoritas = Controles.PB(self, "", self.preferred_openings).ponIcono(Iconos.Favoritos())
        self.btOpeningsQuitar = Controles.PB(self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No())
        hbox = Colocacion.H().control(self.btOpeningsQuitar).control(self.btOpening).control(self.btOpeningsFavoritas).relleno()
        gbOpening = Controles.GB(self, _("Opening"), hbox)

        # gbBasic
        # # Color
        hbox = Colocacion.H().relleno().control(self.rb_white).espacio(10).control(self.rb_black).relleno()
        gbColor = Controles.GB(self, _("Play with"), hbox).ponFuente(flb)
        gbColor.setStyleSheet(gb_style)

        # Tiempo
        ly1 = Colocacion.H().control(self.lbJmotor).control(self.cbJmotor).relleno().control(self.lbJshow).control(self.cbJshow)
        ly2 = Colocacion.H().control(self.lbJtiempo).control(self.edJtiempo)
        ly2.control(self.lbJdepth).control(self.cbJdepth).relleno().control(self.chbEvals)
        ly3 = Colocacion.H().control(self.lbJmultiPV).control(self.cbJmultiPV).relleno()
        ly = Colocacion.V().otro(ly1).otro(ly2).otro(ly3)
        self.gbJ = Controles.GB(self, _("Adjudicator"), ly).to_connect(self.change_adjudicator)
        self.gbJ.setStyleSheet(gb_style)

        # Opciones
        vlayout = Colocacion.V().control(gbColor)
        vlayout.espacio(5).control(self.gbJ)
        vlayout.margen(20)
        gbBasic = Controles.GB(self, "", vlayout)
        gbBasic.setFlat(True)

        # Opciones avanzadas
        lyInicial = Colocacion.H().control(lbInicial).control(self.edJugInicial).relleno().control(lbBooks).control(self.cbBooks).relleno()
        vlayout = Colocacion.V().otro(lyInicial).control(gbOpening)
        vlayout.espacio(5).control(self.chContrario).margen(20).relleno()
        gbAdvanced = Controles.GB(self, "", vlayout)
        gbAdvanced.setFlat(True)

        # Historico
        self.liHisto = []
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("FECHA", _("Date"), 100, centered=True)
        o_columns.nueva("PACIERTOS", _("Hints"), 90, centered=True)
        o_columns.nueva("PUNTOS", _("Points accumulated"), 140, centered=True)
        o_columns.nueva("ENGINE", _("Adjudicator"), 100, centered=True)
        o_columns.nueva("RESUMEN", _("Game played"), 280)

        self.grid = grid = Grid.Grid(self, o_columns, siSelecFilas=True, background=None)
        self.grid.coloresAlternados()
        self.register_grid(grid)

        # Tabs
        self.tab = Controles.Tab().set_position("S")
        self.tab.nuevaTab(gbBasic, _("Basic"))
        self.tab.nuevaTab(gbAdvanced, _("Advanced"))
        self.tab.nuevaTab(self.grid, _("Track record"))
        self.tab.setFont(flb)

        # Cabecera
        lyCab = Colocacion.H().control(gbGM)
        if self.li_personal:
            lyCab.control(gb_personal)

        layout = Colocacion.V().control(tb).otro(lyCab).control(self.tab).margen(6)

        self.setLayout(layout)

        self.restore_dic()
        self.change_adjudicator()
        self.check_gm()
        self.check_personal()
        self.check_histo()
        self.aperturaMuestra()
        self.btOpeningsFavoritas.hide()

        self.restore_video(anchoDefecto=750)
    def __init__(self, procesador):
        self.configuracion = procesador.configuracion
        self.procesador = procesador

        self.dbHisto = Util.DicSQL(self.configuracion.ficheroGMhisto)
        self.bloqueApertura = None
        self.liAperturasFavoritas = []

        wParent = procesador.pantalla
        titulo = _("Play like a grandmaster")
        icono = Iconos.GranMaestro()
        extparam = "gm"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        flb = Controles.TipoLetra(puntos=10)

        # Toolbar
        liAcciones = [(_("Accept"), Iconos.Aceptar(), self.aceptar), None,
                      (_("Cancel"), Iconos.Cancelar(), self.cancelar), None,
                      (_("One game"), Iconos.Uno(), self.unJuego), None,
                      (_("Import"), Iconos.ImportarGM(), self.importar)
                      ]
        tb = Controles.TBrutina(self, liAcciones)

        # Grandes maestros
        self.liGM = GM.listaGM()
        li = [(x[0], x[1]) for x in self.liGM]
        li.insert(0, ("-", None))
        self.cbGM = QTUtil2.comboBoxLB(self, li, li[0][1] if len(self.liGM) == 0 else li[1][1])
        self.cbGM.capturaCambiado(self.compruebaGM)
        hbox = Colocacion.H().relleno().control(self.cbGM).relleno()
        gbGM = Controles.GB(self, _("Choose a grandmaster"), hbox).ponFuente(flb)

        # Personales
        self.liPersonal = GM.listaGMpersonal(self.procesador.configuracion.dirPersonalTraining)
        if self.liPersonal:
            li = [(x[0], x[1]) for x in self.liPersonal]
            li.insert(0, ("-", None))
            self.cbPersonal = QTUtil2.comboBoxLB(self, li, li[0][1])
            self.cbPersonal.capturaCambiado(self.compruebaP)
            btBorrar = Controles.PB(self, "", self.borrarPersonal, plano=False).ponIcono(Iconos.Borrar(), tamIcon=16)
            hbox = Colocacion.H().relleno().control(self.cbPersonal).control(btBorrar).relleno()
            gbPersonal = Controles.GB(self, _("Personal games"), hbox).ponFuente(flb)

        # Color
        self.rbBlancas = Controles.RB(self, _("White"), rutina=self.compruebaColor)
        self.rbBlancas.activa(True)
        self.rbNegras = Controles.RB(self, _("Black"), rutina=self.compruebaColor)
        self.rbNegras.activa(False)

        # Contrario
        self.chContrario = Controles.CHB(self, _("Choose the opponent's move, when there are multiple possible answers"),
                                         False)

        # Juez
        liDepths = [("--", 0)]
        for x in range(1, 31):
            liDepths.append((str(x), x))
        self.liMotores = self.configuracion.comboMotoresMultiPV10()
        self.cbJmotor, self.lbJmotor = QTUtil2.comboBoxLB(self, self.liMotores, self.configuracion.tutorInicial, _("Engine"))
        self.edJtiempo = Controles.ED(self).tipoFloat().ponFloat(1.0).anchoFijo(50)
        self.lbJtiempo = Controles.LB2P(self, _("Time in seconds"))
        self.cbJdepth = Controles.CB(self, liDepths, 0).capturaCambiado(self.cambiadoDepth)
        self.lbJdepth = Controles.LB2P(self, _("Depth"))
        self.lbJshow = Controles.LB2P(self, _("Show rating"))
        self.chbEvals = Controles.CHB(self, _("Show all evaluations"), False)
        liOptions = [(_("All moves"), None), (_("Moves are different"), True), (_("Never"), False)]
        self.cbJshow = Controles.CB(self, liOptions, True)
        self.lbJmultiPV = Controles.LB2P(self, _("Number of moves evaluated by engine(MultiPV)"))
        li = [(_("Default"), "PD"),
              (_("Maximum"), "MX")]
        for x in (1, 3, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200):
            li.append((str(x), str(x)))
        self.cbJmultiPV = Controles.CB(self, li, "PD")

        # Inicial
        self.edJugInicial, lbInicial = QTUtil2.spinBoxLB(self, 1, 1, 99, etiqueta=_("Initial move"), maxTam=40)

        # 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]
        li.insert(0, ("--", None))
        self.cbBooks, lbBooks = QTUtil2.comboBoxLB(self, li, None, _("Bypass moves in the book"))

        # Aperturas

        self.btApertura = Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.aperturasEditar).ponPlano(
                False)
        self.btAperturasFavoritas = Controles.PB(self, "", self.aperturasFavoritas).ponIcono(Iconos.Favoritos())
        self.btAperturasQuitar = Controles.PB(self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No())
        hbox = Colocacion.H().control(self.btAperturasQuitar).control(self.btApertura).control(
                self.btAperturasFavoritas).relleno()
        gbOpening = Controles.GB(self, _("Opening"), hbox)

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

        # Tiempo
        ly1 = Colocacion.H().control(self.lbJmotor).control(self.cbJmotor).control(self.lbJshow).control(
                self.cbJshow).relleno()
        ly2 = Colocacion.H().control(self.lbJtiempo).control(self.edJtiempo)
        ly2.control(self.lbJdepth).control(self.cbJdepth).espacio(15).control(self.chbEvals).relleno()
        ly3 = Colocacion.H().control(self.lbJmultiPV).control(self.cbJmultiPV).relleno()
        ly = Colocacion.V().otro(ly1).otro(ly2).otro(ly3)
        self.gbJ = Controles.GB(self, _("Adjudicator"), ly).conectar(self.cambiaJuez)

        # Opciones
        vlayout = Colocacion.V().control(gbColor)
        vlayout.espacio(5).control(self.gbJ)
        vlayout.margen(20)
        gbBasic = Controles.GB(self, "", vlayout)
        gbBasic.setFlat(True)

        # Opciones avanzadas
        lyInicial = Colocacion.H().control(lbInicial).control(self.edJugInicial).relleno().control(lbBooks).control(
                self.cbBooks).relleno()
        vlayout = Colocacion.V().relleno().otro(lyInicial).control(gbOpening)
        vlayout.espacio(5).control(self.chContrario).margen(20).relleno()
        gbAdvanced = Controles.GB(self, "", vlayout)
        gbAdvanced.setFlat(True)

        # Historico
        self.liHisto = []
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("FECHA", _("Date"), 80, siCentrado=True)
        oColumnas.nueva("PACIERTOS", _("Hints"), 90, siCentrado=True)
        oColumnas.nueva("PUNTOS", _("Points accumulated"), 120, siCentrado=True)
        oColumnas.nueva("ENGINE", _("Adjudicator"), 100, siCentrado=True)
        oColumnas.nueva("RESUMEN", _("Game played"), 150)

        self.grid = grid = Grid.Grid(self, oColumnas, siSelecFilas=True, background=None)
        self.grid.coloresAlternados()
        self.registrarGrid(grid)

        # Tabs
        self.tab = Controles.Tab().ponPosicion("S")
        self.tab.nuevaTab(gbBasic, _("Basic"))
        self.tab.nuevaTab(gbAdvanced, _("Advanced"))
        self.tab.nuevaTab(self.grid, _("Track record"))

        # Cabecera
        lyCab = Colocacion.H().control(gbGM)
        if self.liPersonal:
            lyCab.control(gbPersonal)

        layout = Colocacion.V().control(tb).otro(lyCab).control(self.tab).margen(3)

        self.setLayout(layout)

        self.recuperaDic()
        self.cambiaJuez()
        self.compruebaGM()
        self.compruebaP()
        self.compruebaHisto()
        self.aperturaMuestra()
        self.btAperturasFavoritas.hide()

        self.recuperarVideo(anchoDefecto=450)
Exemple #10
0
    def __init__(self, wowner, manager, alm, show_analysis):
        titulo = _("Result of analysis")
        icono = Iconos.Estadisticas()
        extparam = "estadisticasv1"
        QTVarios.WDialogo.__init__(self, wowner, titulo, icono, extparam)
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint
                            | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowMinimizeButtonHint)

        self.alm = alm
        self.procesador = manager.procesador
        self.manager = manager
        self.configuration = manager.configuration
        self.show_analysis = show_analysis
        self.colorWhite = QTUtil.qtColorRGB(231, 244, 254)

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

        self.dicLiJG = {
            "A": self.alm.lijg,
            "W": self.alm.lijgW,
            "B": self.alm.lijgB
        }
        gridAll = Grid.Grid(self, xcol(), siSelecFilas=True, xid="A")
        anchoGrid = gridAll.fixMinWidth()
        self.register_grid(gridAll)
        gridW = Grid.Grid(self, xcol(), siSelecFilas=True, xid="W")
        anchoGrid = max(gridW.fixMinWidth(), anchoGrid)
        self.register_grid(gridW)
        gridB = Grid.Grid(self, xcol(), siSelecFilas=True, xid="B")
        anchoGrid = max(gridB.fixMinWidth(), anchoGrid)
        self.register_grid(gridB)

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

        self.tabGrid = tabGrid = Controles.Tab()
        tabGrid.nuevaTab(gridAll, _("All moves"))
        tabGrid.nuevaTab(gridW, _("White"))
        tabGrid.nuevaTab(gridB, _("Black"))
        tabGrid.nuevaTab(wIdx, _("Indexes"))
        tabGrid.dispatchChange(self.tabChanged)
        self.tabActive = 0

        config_board = Code.configuration.config_board("ANALISISGRAPH", 48)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.ponerPiezasAbajo(alm.is_white_bottom)
        self.board.dispatchSize(self.boardSizeChanged)

        # self.capturas = WCapturas.CapturaLista(self, self.board)
        ly_tc = Colocacion.H().control(self.board)
        # .control(self.capturas)

        self.rbShowValues = Controles.RB(self,
                                         _("Values"),
                                         rutina=self.cambiadoShow).activa(True)
        self.rbShowElo = Controles.RB(self,
                                      _("Elo performance"),
                                      rutina=self.cambiadoShow)
        self.chbShowLostPoints = Controles.CHB(
            self, _("Show lost points"),
            self.getShowLostPoints()).capture_changes(
                self, self.showLostPointsChanged)
        ly_rb = (Colocacion.H().espacio(40).control(
            self.rbShowValues).espacio(20).control(
                self.rbShowElo).espacio(30).control(
                    self.chbShowLostPoints).relleno(1))

        layout = Colocacion.G()
        layout.controlc(tabGrid, 0, 0)
        layout.otroc(ly_rb, 1, 0)
        layout.otroc(ly_tc, 0, 1, numFilas=2)

        Controles.Tab().set_position("W")
        ancho = self.board.width() + anchoGrid
        self.htotal = [
            Histogram.Histogram(self, alm.hgame, gridAll, ancho, True),
            Histogram.Histogram(self, alm.hwhite, gridW, ancho, True),
            Histogram.Histogram(self, alm.hblack, gridB, ancho, True),
            Histogram.Histogram(self, alm.hgame, gridAll, ancho, False,
                                alm.eloT),
            Histogram.Histogram(self, alm.hwhite, gridW, ancho, False,
                                alm.eloW),
            Histogram.Histogram(self, alm.hblack, gridB, ancho, False,
                                alm.eloB),
        ]
        lh = Colocacion.V()
        for x in range(6):
            lh.control(self.htotal[x])
            if x:
                self.htotal[x].hide()

        layout.otroc(lh, 2, 0, 1, 3)
        self.setLayout(layout)

        self.restore_video()

        gridAll.gotop()
        gridB.gotop()
        gridW.gotop()
        self.grid_left_button(gridAll, 0, None)
        th = self.board.height()
        self.tabGrid.setFixedHeight(th)
        self.adjustSize()
        self.emIndexes.setFixedHeight(th - 72)
Exemple #11
0
    def __init__(self, wparent, cpu):
        self.cpu = cpu
        self.posicion = cpu.partida.iniPosicion
        configuracion = cpu.configuracion

        self.wparent = wparent

        QtGui.QWidget.__init__(self, wparent)

        liAcciones = (
            (_("Save"), Iconos.GrabarComo(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("Start position"), Iconos.Inicio(), self.inicial),
            None,
            (_("Clear board"), Iconos.Borrar(), self.limpiaTablero),
            (_("Paste FEN position"), Iconos.Pegar16(), self.pegar),
            (_("Copy FEN position"), Iconos.Copiar(), self.copiar),
            (_("Active voice"), Iconos.S_Microfono(),
             self.wparent.voice_active),
            (_("Deactive voice"), Iconos.X_Microfono(),
             self.wparent.voice_deactive),
        )

        self.tb = Controles.TBrutina(self,
                                     liAcciones,
                                     siTexto=False,
                                     tamIcon=20)

        confTablero = configuracion.confTablero("VOYAGERPOS", 24)
        self.tablero = Tablero.PosTablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueve)
        self.tablero.mensBorrar = self.borraCasilla
        self.tablero.mensCrear = self.creaCasilla
        self.tablero.mensRepetir = self.repitePieza
        self.tablero.ponDispatchDrop(self.dispatchDrop)
        self.tablero.baseCasillasSC.setAcceptDrops(True)

        self.rbWhite = Controles.RB(self, _("White"))
        self.rbBlack = Controles.RB(self, _("Black"))

        self.cbWoo = Controles.CHB(self, _("White") + " O-O", True)
        self.cbWooo = Controles.CHB(self, _("White") + " O-O-O", True)
        self.cbBoo = Controles.CHB(self, _("Black") + " O-O", True)
        self.cbBooo = Controles.CHB(self, _("Black") + " O-O-O", True)

        lbEnPassant = Controles.LB(self, _("En passant") + ":")
        self.edEnPassant = Controles.ED(self).controlrx(
            "(-|[a-h][36])").anchoFijo(30)

        self.edMovesPawn, lbMovesPawn = QTUtil2.spinBoxLB(
            self, 0, 0, 999, etiqueta=_("Halfmove clock"), maxTam=50)

        self.edFullMoves, lbFullMoves = QTUtil2.spinBoxLB(
            self, 1, 1, 999, etiqueta=_("Fullmove number"), maxTam=50)

        # COLOCACION -------------------------------------------------------------------------------------------
        hbox = Colocacion.H().relleno().control(
            self.rbWhite).espacio(15).control(self.rbBlack).relleno()
        gbColor = Controles.GB(self, _("Next move"), hbox)

        ly = Colocacion.G().control(self.cbWoo, 0, 0).control(self.cbBoo, 0, 1)
        ly.control(self.cbWooo, 1, 0).control(self.cbBooo, 1, 1)
        gbEnroques = Controles.GB(self, _("Castling moves possible"), ly)

        ly = Colocacion.G()
        ly.controld(lbMovesPawn, 0, 0, 1, 3).control(self.edMovesPawn, 0, 3)
        ly.controld(lbEnPassant, 1, 0).control(self.edEnPassant, 1, 1)
        ly.controld(lbFullMoves, 1, 2).control(self.edFullMoves, 1, 3)
        gbOtros = Controles.GB(self, "", ly)

        ly = Colocacion.V().control(self.tb).control(self.tablero)
        ly.control(gbColor).control(gbEnroques).control(gbOtros)
        ly.margen(1)
        self.setLayout(ly)

        self.ultimaPieza = "P"
        self.piezas = self.tablero.piezas
        self.resetPosicion()
        self.ponCursor()

        self.queueVoice = []
        self.bufferVoice = ""
Exemple #12
0
    def __init__(self, wParent, configuracion, fen):

        QtGui.QDialog.__init__(self, wParent)

        self.wParent = wParent

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

        self.configuracion = configuracion

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

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

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

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

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

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

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

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

        self.resetPosicion()

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

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

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

        # Layout

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

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

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

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

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

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

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

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

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

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

        self.ponCursor()

        self.voyager = None
        self.bufferVoice = ""
        self.queueVoice = []
        self.isVoiceActive = False
        if not configuracion.voice:
            self.btVoiceX.setVisible(False)
            self.btVoice.setVisible(False)
        else:
            if Voice.runVoice.isActive():
                self.voiceActive()
            else:
                self.voiceDeactive()