Exemplo n.º 1
0
    def __init__(self, owner, resistance):

        self.resistance = resistance

        # Dialogo ---------------------------------------------------------------
        icono = Iconos.Resistencia()
        titulo = _("Resistance Test")
        tipo = resistance.tipo
        if tipo:
            titulo += "-" + _("Blindfold chess")
            if tipo == "p1":
                titulo += "-" + _("Hide only our pieces")
            elif tipo == "p2":
                titulo += "-" + _("Hide only opponent pieces")
        extparam = "boxing"
        super().__init__(parent=owner,
                         titulo=titulo,
                         icono=icono,
                         extparam=extparam)
        # self.setStyleSheet("QWidget { background: #AFC3D7 }")

        # Tool bar ---------------------------------------------------------------
        liAcciones = [
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Remove data"), Iconos.Borrar(), self.borrar),
            None,
            (_("Config"), Iconos.Configurar(), self.configurar),
        ]
        tb = Controles.TBrutina(self, liAcciones, background="#AFC3D7")

        # Texto explicativo ----------------------------------------------------
        self.lb = Controles.LB(self)
        self.ponTextoAyuda()
        self.lb.ponFondoN("#F5F0CF")

        # Lista
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("ENGINE", _("Engine"), 198)
        oColumnas.nueva("BLANCAS", _("White"), 200, siCentrado=True)
        oColumnas.nueva("NEGRAS", _("Black"), 200, siCentrado=True)

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

        # Layout
        lyB = Colocacion.V().controlc(self.lb).control(self.grid).margen(3)
        layout = Colocacion.V().control(tb).otro(lyB).margen(0)
        self.setLayout(layout)

        self.recuperarVideo(siTam=True, anchoDefecto=677, altoDefecto=562)

        self.grid.gotop()

        self.grid.setFocus()
        self.resultado = None
Exemplo n.º 2
0
    def init_ended(self, route, lyTitle, lySVG):
        def ly(rt, va):
            lbrt = Controles.LB(rt).ponTipoLetra(puntos=11).align_center()
            lbva = Controles.LB(va).ponTipoLetra(puntos=11).align_center()
            self.set_style("Black", "#B2AE9A", lbrt)
            self.set_border(lbva)
            return Colocacion.H().control(lbrt).control(lbva)

        lyDB = ly(_("Starting date"), route.date_begin)
        lyDE = ly(_("Ending date"), route.date_end)

        tb = QTVarios.LCTB(self, with_text=True, icon_size=32)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Close"), Iconos.MainMenu(), self.mainMenu)

        lyTT = ly(_("Total time"), route.time())
        lyTP = ly(_("Playing"), route.time(Routes.PLAYING))
        lyTC = ly(_("Tactics"), route.time(Routes.BETWEEN))
        lyTE = ly(_("Endings"), route.time(Routes.ENDING))

        lyT = Colocacion.V().otro(lyTT).otro(lyTP).otro(lyTC).otro(lyTE)

        lyD = Colocacion.V().otro(lyDB).otro(lyDE).control(tb)

        lyT_D = Colocacion.H().otro(lyT).otro(lyD)

        ly = Colocacion.V().otro(lyTitle).otro(lySVG).otro(lyT_D).relleno(1)
        self.setLayout(ly)
Exemplo n.º 3
0
 def train(self):
     if self.train_test():
         menu = QTVarios.LCMenu(self)
         menu.opcion("tr_sequential", _("Sequential"),
                     Iconos.TrainSequential())
         menu.separador()
         menu.opcion("tr_static", _("Static"), Iconos.TrainStatic())
         menu.separador()
         menu.opcion("tr_positions", _("Positions"),
                     Iconos.TrainPositions())
         menu.separador()
         submenu = menu.submenu(_("Configuration"), Iconos.Configurar())
         submenu.opcion("update", _("Update current trainings"),
                        Iconos.Reindexar())
         submenu.separador()
         submenu.opcion("new", _("Re-create all trainings"),
                        Iconos.Modificar())
         resp = menu.lanza()
         if resp is None:
             return
         if resp.startswith("tr_"):
             self.resultado = resp
             self.accept()
         elif resp == "new":
             self.trainNew()
         elif resp == "update":
             self.trainUpdate()
Exemplo n.º 4
0
def menu_tools_savemenu(procesador, dic_data=None):
    savemenu = SaveMenu(dic_data, procesador.menuTools_run)

    savemenu.opcion("juega_solo", _("Create your own game"), Iconos.JuegaSolo())
    savemenu.separador()

    menu_database = savemenu.submenu(_("Databases"), Iconos.Database())
    QTVarios.menuDB(menu_database, procesador.configuration, True, indicador_previo="dbase_R_")
    menu_database.separador()
    submenu_database = menu_database.submenu(_("Maintenance"), Iconos.DatabaseMaintenance())
    submenu_database.opcion("dbase_N", _("Create new database"), Iconos.DatabaseMas())
    submenu_database.separador()
    submenu_database.opcion("dbase_D", _("Delete a database"), Iconos.DatabaseDelete())
    if Code.is_windows:
        submenu_database.separador()
        submenu_database.opcion("dbase_M", _("Direct maintenance"), Iconos.Configurar())
    savemenu.separador()

    menu1 = savemenu.submenu(_("PGN"), Iconos.PGN())
    menu1.opcion("pgn", _("Read PGN file"), Iconos.Fichero())
    menu1.separador()
    menu1.opcion("pgn_paste", _("Paste PGN"), Iconos.Pegar())
    menu1.separador()
    menu1.opcion("manual_save", _("Save positions to FNS/PGN"), Iconos.ManualSave())
    menu1.separador()
    menu1.opcion("miniatura", _("Miniature of the day"), Iconos.Miniatura())
    menu1.separador()
    savemenu.separador()

    menu1 = savemenu.submenu(_("Openings"), Iconos.Openings())
    menu1.opcion("openings", _("Opening lines"), Iconos.OpeningLines())
    menu1.separador()
    menu1.opcion("aperturaspers", _("Custom openings"), Iconos.Opening())
    menu1.separador()
    menu1.opcion("polyglot", _("Polyglot book factory"), Iconos.FactoryPolyglot())
    menu1.separador()
    menu1.opcion("polyglot_install", _("Install/remove polyglot books"), Iconos.Libros())
    savemenu.separador()

    menu1 = savemenu.submenu(_("Engines"), Iconos.Motores())
    menu1.opcion("torneos", _("Tournaments between engines"), Iconos.Torneos())
    menu1.separador()
    menu1.opcion("sts", _("STS: Strategic Test Suite"), Iconos.STS())
    menu1.separador()
    menu1.opcion("motores", _("External engines"), Iconos.Motores())
    menu1.separador()
    menu1.opcion("kibitzers", _("Kibitzers"), Iconos.Kibitzer())

    savemenu.separador()

    if Code.is_windows and Code.configuration.x_show_version11:
        menu1 = savemenu.submenu(_("Conversion from version 11"), Iconos.Bridge())
        menu1.opcion("version11_databases", _("Databases"), Iconos.Database())
        menu1.separador()
        menu1.opcion("version11_openinglines", _("Opening lines"), Iconos.OpeningLines())
        menu1.separador()
        menu1.opcion("version11_transsiberian", _("Transsiberian Railway"), Iconos.Train())
        menu1.separador()

    return savemenu
Exemplo n.º 5
0
    def MoverTiempo(self):
        if self.siReloj:
            self.siReloj = False
        else:

            menu = QTVarios.LCMenu(self)
            menu.opcion("previo", "%s: %0.02f" % (_("Duration of interval (secs)"), self.intervalo / 1000.0),
                        Iconos.MoverTiempo())
            menu.opcion("otro", _("Change interval"), Iconos.Configurar())
            resp = menu.lanza()
            if not resp:
                return

            if resp == "otro":
                liGen = [(None, None)]
                config = FormLayout.Editbox(_("Duration of interval (secs)"), 40, tipo=float)
                liGen.append((config, self.intervalo / 1000.0))
                resultado = FormLayout.fedit(liGen, title=_("Interval"), parent=self, icon=Iconos.MoverTiempo())
                if resultado is None:
                    return
                accion, liResp = resultado
                tiempo = liResp[0]
                if tiempo > 0.01:
                    self.intervalo = int(tiempo * 1000)
                else:
                    return

            self.siReloj = True
            self.MoverInicio()
            self.lanzaReloj()
Exemplo n.º 6
0
    def train(self):
        menu = QTVarios.LCMenu(self)
        trSSP, trEng = self.train_test()
        if trSSP:
            menu.opcion("tr_sequential", _("Sequential"), Iconos.TrainSequential())
            menu.separador()
            menu.opcion("tr_static", _("Static"), Iconos.TrainStatic())
            menu.separador()
            menu.opcion("tr_positions", _("Positions"), Iconos.TrainPositions())
            menu.separador()
        if trEng:
            menu.opcion("tr_engines", _("With engines"), Iconos.TrainEngines())
            menu.separador()
        submenu = menu.submenu(_("Configuration"), Iconos.Configurar())
        if trEng or trSSP:
            submenu.opcion("update", _("Update current trainings"), Iconos.Reindexar())
            submenu.separador()
        submenu1 = submenu.submenu(_("Create trainings"), Iconos.Modificar())
        submenu1.opcion(
            "new_ssp", "%s - %s - %s" % (_("Sequential"), _("Static"), _("Positions")), Iconos.TrainSequential()
        )
        submenu1.opcion("new_eng", "With engines", Iconos.TrainEngines())

        resp = menu.lanza()
        if resp is None:
            return
        if resp.startswith("tr_"):
            self.resultado = resp
            self.accept()
        elif resp == "new_ssp":
            self.trainNewSSP()
        elif resp == "new_eng":
            self.trainNewEngines()
        elif resp == "update":
            self.trainUpdateAll()
Exemplo n.º 7
0
    def __init__(self, wParent, sts, procesador):
        titulo = sts.name
        icono = Iconos.STS()
        extparam = "unsts"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        # Datos
        self.sts = sts
        self.procesador = procesador

        # Toolbar
        liAcciones = [
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Run"), Iconos.Run(), self.wkRun),
            None,
            (_("New"), Iconos.NuevoMas(), self.wkNew),
            None,
            (_("Edit"), Iconos.Modificar(), self.wkEdit),
            None,
            (_("Copy"), Iconos.Copiar(), self.wkCopy),
            None,
            (_("Remove"), Iconos.Borrar(), self.wkRemove),
            None,
            (_("Up"), Iconos.Arriba(), self.up),
            (_("Down"), Iconos.Abajo(), self.down),
            None,
            (_("Export"), Iconos.Grabar(), self.export),
            None,
            (_("Config"), Iconos.Configurar(), self.configurar),
            None,
        ]
        tb = Controles.TBrutina(self, liAcciones, tamIcon=24)

        # # Grid works
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("POS", _("N."), 30, siCentrado=True)
        oColumnas.nueva("REF", _("Reference"), 100)
        oColumnas.nueva("TIME", _("Time"), 50, siCentrado=True)
        oColumnas.nueva("DEPTH", _("Depth"), 50, siCentrado=True)
        oColumnas.nueva("SAMPLE", _("Sample"), 50, siCentrado=True)
        oColumnas.nueva("RESULT", _("Result"), 150, siCentrado=True)
        oColumnas.nueva("ELO", _("Elo"), 80, siCentrado=True)
        oColumnas.nueva("WORKTIME", _("Work time"), 80, siCentrado=True)
        for x in range(len(sts.groups)):
            group = sts.groups.group(x)
            oColumnas.nueva("T%d" % x, group.name, 140, siCentrado=True)
        self.grid = Grid.Grid(self,
                              oColumnas,
                              siSelecFilas=True,
                              siSeleccionMultiple=True)
        self.registrarGrid(self.grid)

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

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

        self.grid.gotop()
    def configurar(self):
        segundos, puntos, maxerror = self.resistance.actual()

        separador = FormLayout.separador

        liGen = [separador]

        config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80)
        liGen.append((config, segundos))

        liGen.append(separador)

        config = FormLayout.Spinbox(_("Max lost points in total"), 10, 99999,
                                    80)
        liGen.append((config, puntos))

        liGen.append(separador)

        config = FormLayout.Spinbox(
            _("Max lost points in a single move") + ":\n" +
            _("0 = not consider this limit"), 0, 1000, 80)
        liGen.append((config, maxerror))

        resultado = FormLayout.fedit(liGen,
                                     title=_("Config"),
                                     parent=self,
                                     icon=Iconos.Configurar())
        if resultado:
            accion, liResp = resultado
            segundos, puntos, maxerror = liResp
            self.resistance.cambiaconfiguration(segundos, puntos, maxerror)
            self.set_textAyuda()
            self.grid.refresh()
            return liResp[0]
Exemplo n.º 9
0
    def changeFolder(self):
        nof = _("New opening folder")
        base = self.configuration.folder_base_openings
        li = [x for x in os.listdir(base) if os.path.isdir(os.path.join(base, x))]
        menu = QTVarios.LCMenu(self)
        rondo = QTVarios.rondoPuntos()
        menu.opcion("", _("Home folder"), Iconos.Home())
        menu.separador()
        for x in li:
            menu.opcion(x, x, rondo.otro())
        menu.separador()
        menu.opcion(":n", nof, Iconos.Nuevo())
        if Code.is_windows:
            menu.separador()
            menu.opcion(":m", _("Direct maintenance"), Iconos.Configurar())

        resp = menu.lanza()
        if resp is not None:
            if resp == ":m":
                os.startfile(base)
                return

            elif resp == ":n":
                name = ""
                error = ""
                while True:
                    li_gen = [FormLayout.separador]
                    li_gen.append((nof + ":", name))
                    if error:
                        li_gen.append(FormLayout.separador)
                        li_gen.append((None, error))

                    resultado = FormLayout.fedit(li_gen, title=nof, parent=self, icon=Iconos.OpeningLines(), anchoMinimo=460)
                    if resultado:
                        accion, liResp = resultado
                        name = liResp[0].strip()
                        if name:
                            path = os.path.join(base, name)
                            try:
                                os.mkdir(path)
                            except:
                                error = _("Unable to create this folder")
                                continue
                            if not os.path.isdir(path):
                                continue
                            break
                    else:
                        return
            else:
                path = os.path.join(base, resp)

            path = Util.relative_path(path)
            self.configuration.set_folder_openings(path)
            self.configuration.graba()
            self.listaOpenings = OpeningLines.ListaOpenings(self.configuration)
            self.glista.refresh()
            self.glista.gotop()
            if len(self.listaOpenings) == 0:
                self.wtrain.setVisible(False)
            self.setWindowTitle(self.getTitulo())
Exemplo n.º 10
0
    def __init__(self, owner, name, title, icono, folder, li_tam_blocks):

        self.tol = TurnOnLights.read_tol(name, title, folder, li_tam_blocks)
        self.reinit = False

        titulo = _("Turn on the lights") + ": " + title
        extparam = "tol%s-%d" % (name, self.tol.work_level)
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.colorTheme = QTUtil.qtColor("#F0F0F0")

        # Toolbar
        tb = Controles.TBrutina(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        anterior, siguiente = self.tol.prev_next()
        if anterior:
            tb.new(_("Previous"), Iconos.Anterior(), self.goto_previous)
        if siguiente:
            tb.new(_("Next"), Iconos.Siguiente(), self.goto_next)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Information"), Iconos.Informacion(), self.colors)

        # Lista
        oColumnas = Columnas.ListaColumnas()
        work_level = self.tol.work_level + 1
        oColumnas.nueva("THEME",
                        _("Level %d/%d") % (work_level, self.tol.num_levels),
                        175)
        for x in range(self.tol.num_blocks):
            oColumnas.nueva("BLOCK%d" % x,
                            "%d" % (x + 1, ),
                            42,
                            siCentrado=True,
                            edicion=Delegados.PmIconosColor())

        self.grid = grid = Grid.Grid(self,
                                     oColumnas,
                                     altoFila=42,
                                     background="white")
        self.grid.setAlternatingRowColors(False)
        self.grid.tipoLetra(puntos=10, peso=500)
        nAnchoPgn = self.grid.anchoColumnas() + 20
        self.grid.setMinimumWidth(nAnchoPgn)
        self.registrarGrid(grid)

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.V().control(tb).control(self.grid)

        self.setLayout(ly)

        alto = self.tol.num_themes * 42 + 116
        self.recuperarVideo(siTam=True,
                            altoDefecto=alto,
                            anchoDefecto=nAnchoPgn)
Exemplo n.º 11
0
    def __init__(self, grid_owner, configuracion, work):
        QtWidgets.QDialog.__init__(self, grid_owner)
        self.setWindowTitle(_("Edit columns"))
        self.setWindowIcon(Iconos.EditColumns())

        self.grid_owner = grid_owner
        self.o_columnas_base = grid_owner.columnas()
        self.o_columnas = self.o_columnas_base.clone()

        self.configuracion = configuracion
        self.work = work

        li_options = [
            (_("Save"), Iconos.GrabarFichero(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.reject),
            None,
            (_("Up"), Iconos.Arriba(), self.tw_up),
            (_("Down"), Iconos.Abajo(), self.tw_down),
            None,
            (_("Configurations"), Iconos.Configurar(), self.configurations),
            None,
        ]
        tb = QTVarios.LCTB(self, li_options)

        # Grid
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("SIMOSTRAR", "", 20, siChecked=True)
        o_columns.nueva("CLAVE", _("Key"), 80, centered=True)
        o_columns.nueva("CABECERA",
                        _("Title"),
                        150,
                        edicion=Delegados.LineaTexto())
        o_columns.nueva("ANCHO",
                        _("Width"),
                        60,
                        edicion=Delegados.LineaTexto(siEntero=True),
                        siDerecha=True)

        self.liAlin = [_("Left"), _("Center"), _("Right")]
        o_columns.nueva("ALINEACION",
                        _("Alignment"),
                        100,
                        centered=True,
                        edicion=Delegados.ComboBox(self.liAlin))
        o_columns.nueva("CTEXTO", _("Foreground"), 80, centered=True)
        o_columns.nueva("CFONDO", _("Background"), 80, centered=True)
        self.grid = Grid.Grid(self, o_columns, siEditable=True)

        layout = Colocacion.V().control(tb).control(self.grid).margen(3)
        self.setLayout(layout)

        self.resize(self.grid.anchoColumnas() + 48, 360)
        self.grid.goto(0, 1)
Exemplo n.º 12
0
    def configurar(self):
        segundos, puntos = self.boxing.actual()

        liGen = [(None, None)]

        config = FormLayout.Spinbox(_("Time in seconds"), 1, 99999, 80)
        liGen.append((config, segundos))

        config = FormLayout.Spinbox(_("Points"), 10, 99999, 80)
        liGen.append((config, puntos))

        resultado = FormLayout.fedit(liGen,
                                     title=_("Config"),
                                     parent=self,
                                     icon=Iconos.Configurar())
        if resultado:
            accion, liResp = resultado
            segundos = liResp[0]
            puntos = liResp[1]
            self.boxing.cambiaConfiguracion(segundos, puntos)
            self.ponTextoAyuda()
            self.grid.refresh()
            return liResp[0]
Exemplo n.º 13
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()
Exemplo n.º 14
0
    def preparaTB(self):
        self.dicTB = {}

        dic_opciones = {
            TB_PLAY: (_("Play"), Iconos.Libre()),
            TB_COMPETE: (_("Compete"), Iconos.NuevaPartida()),
            TB_TRAIN: (_("Train"), Iconos.Entrenamiento()),
            TB_OPTIONS: (_("Options"), Iconos.Opciones()),
            TB_INFORMATION: (_("Information"), Iconos.Informacion()),
            TB_FILE: (_("File"), Iconos.File()),
            TB_SAVE: (_("Save"), Iconos.Grabar()),
            TB_SAVE_AS: (_("Save as"), Iconos.GrabarComo()),
            TB_OPEN: (_("Open"), Iconos.Recuperar()),
            TB_RESIGN: (_("Resign"), Iconos.Abandonar()),
            TB_REINIT: (_("Reinit"), Iconos.Reiniciar()),
            TB_TAKEBACK: (_("Takeback"), Iconos.Atras()),
            TB_ADJOURN: (_("Adjourn"), Iconos.Aplazar()),
            TB_ADJOURNS: (_("Adjourns"), Iconos.Aplazamientos()),
            TB_END_GAME: (_("End game"), Iconos.FinPartida()),
            TB_CLOSE: (_("Close"), Iconos.MainMenu()),
            TB_PREVIOUS: (_("Previous"), Iconos.Anterior()),
            TB_NEXT: (_("Next"), Iconos.Siguiente()),
            TB_QUIT: (_("Quit"), Iconos.FinPartida()),
            TB_PASTE_PGN: (_("Paste PGN"), Iconos.Pegar()),
            TB_READ_PGN: (_("Read PGN"), Iconos.Fichero()),
            TB_PGN_LABELS: (_("PGN Labels"), Iconos.InformacionPGN()),
            TB_OTHER_GAME: (_("Other game"), Iconos.FicheroRepite()),
            TB_MY_GAMES: (_("My games"), Iconos.NuestroFichero()),
            TB_DRAW: (_("Draw"), Iconos.Tablas()),
            TB_BOXROOMS_PGN: (_("Boxrooms PGN"), Iconos.BoxRooms()),
            TB_END: (_("End"), Iconos.MainMenu()),
            TB_SLOW: (_("Slow"), Iconos.Pelicula_Lento()),
            TB_PAUSE: (_("Pause"), Iconos.Pelicula_Pausa()),
            TB_CONTINUE: (_("Continue"), Iconos.Pelicula_Seguir()),
            TB_FAST: (_("Fast"), Iconos.Pelicula_Rapido()),
            TB_REPEAT: (_("Repeat"), Iconos.Pelicula_Repetir()),
            TB_PGN: (_("PGN"), Iconos.Pelicula_PGN()),
            TB_HELP: (_("Help"), Iconos.AyudaGR()),
            TB_LEVEL: (_("Level"), Iconos.Jugar()),
            TB_ACCEPT: (_("Accept"), Iconos.Aceptar()),
            TB_CANCEL: (_("Cancel"), Iconos.Cancelar()),
            # TB_GAME_OF_THE_DAY: (_("Game of the day"), Iconos.LM()),
            TB_CONFIG: (_("Config"), Iconos.Configurar()),
            TB_UTILITIES: (_("Utilities"), Iconos.Utilidades()),
            TB_VARIATIONS: (_("Variations"), Iconos.VariantesG()),
            TB_TOOLS: (_("Tools"), Iconos.Tools()),
            TB_CHANGE: (_("Change"), Iconos.Cambiar()),
            TB_SHOW_TEXT: (_("Show text"), Iconos.Modificar()),
            TB_HELP_TO_MOVE: (_("Help to move"), Iconos.BotonAyuda()),
            TB_SEND: (_("Send"), Iconos.Enviar()),
            TB_STOP: (_("Play now"), Iconos.Stop()),
        }

        cf = self.gestor.configuracion
        peso = 75 if cf.x_tb_bold else 50
        puntos = cf.x_tb_fontpoints
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for clave, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.clave = clave
            self.dicTB[clave] = accion
Exemplo n.º 15
0
    def create_toolbar(self):
        self.tb = QtWidgets.QToolBar("BASIC", self)
        iconsTB = self.configuration.tipoIconos()
        self.tb.setToolButtonStyle(iconsTB)
        sz = 32 if iconsTB == QtCore.Qt.ToolButtonTextUnderIcon else 16
        self.tb.setIconSize(QtCore.QSize(sz, sz))
        style = "QToolBar {border-bottom: 1px solid gray; border-top: 1px solid gray;}"
        self.tb.setStyleSheet(style)
        # sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtGui, QtWidgets.QSizePolicy.Expanding)
        # self.tb.setSizePolicy(sp)
        self.tb.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.tb.customContextMenuRequested.connect(self.lanzaAtajos)

        self.dic_toolbar = {}

        dic_opciones = {
            TB_PLAY: (_("Play"), Iconos.Libre()),
            TB_COMPETE: (_("Compete"), Iconos.NuevaPartida()),
            TB_TRAIN: (_("Train"), Iconos.Entrenamiento()),
            TB_OPTIONS: (_("Options"), Iconos.Opciones()),
            TB_INFORMATION: (_("Information"), Iconos.Informacion()),
            TB_FILE: (_("File"), Iconos.File()),
            TB_SAVE: (_("Save"), Iconos.Grabar()),
            TB_SAVE_AS: (_("Save as"), Iconos.GrabarComo()),
            TB_OPEN: (_("Open"), Iconos.Recuperar()),
            TB_RESIGN: (_("Resign"), Iconos.Abandonar()),
            TB_REINIT: (_("Reinit"), Iconos.Reiniciar()),
            TB_TAKEBACK: (_("Takeback"), Iconos.Atras()),
            TB_ADJOURN: (_("Adjourn"), Iconos.Aplazar()),
            TB_Adjournments: (_("Adjournments"), Iconos.Aplazamientos()),
            TB_END_GAME: (_("End game"), Iconos.FinPartida()),
            TB_CLOSE: (_("Close"), Iconos.MainMenu()),
            TB_PREVIOUS: (_("Previous"), Iconos.Anterior()),
            TB_NEXT: (_("Next"), Iconos.Siguiente()),
            TB_QUIT: (_("Quit"), Iconos.FinPartida()),
            TB_PASTE_PGN: (_("Paste PGN"), Iconos.Pegar()),
            TB_READ_PGN: (_("Read PGN"), Iconos.Fichero()),
            TB_PGN_LABELS: (_("PGN Labels"), Iconos.InformacionPGN()),
            TB_OTHER_GAME: (_("Other game"), Iconos.FicheroRepite()),
            TB_MY_GAMES: (_("My games"), Iconos.NuestroFichero()),
            TB_DRAW: (_("Draw"), Iconos.Tablas()),
            TB_BOXROOMS_PGN: (_("Boxrooms PGN"), Iconos.BoxRooms()),
            TB_END: (_("End"), Iconos.MainMenu()),
            TB_SLOW: (_("Slow"), Iconos.Pelicula_Lento()),
            TB_PAUSE: (_("Pause"), Iconos.Pelicula_Pausa()),
            TB_CONTINUE: (_("Continue"), Iconos.Pelicula_Seguir()),
            TB_FAST: (_("Fast"), Iconos.Pelicula_Rapido()),
            TB_REPEAT: (_("Repeat"), Iconos.Pelicula_Repetir()),
            TB_PGN: (_("PGN"), Iconos.Pelicula_PGN()),
            TB_HELP: (_("Help"), Iconos.AyudaGR()),
            TB_LEVEL: (_("Level"), Iconos.Jugar()),
            TB_ACCEPT: (_("Accept"), Iconos.Aceptar()),
            TB_CANCEL: (_("Cancel"), Iconos.Cancelar()),
            TB_CONFIG: (_("Config"), Iconos.Configurar()),
            TB_UTILITIES: (_("Utilities"), Iconos.Utilidades()),
            TB_VARIATIONS: (_("Variations"), Iconos.VariationsG()),
            TB_TOOLS: (_("Tools"), Iconos.Tools()),
            TB_CHANGE: (_("Change"), Iconos.Cambiar()),
            TB_SHOW_TEXT: (_("Show text"), Iconos.Modificar()),
            TB_HELP_TO_MOVE: (_("Help to move"), Iconos.BotonAyuda()),
            TB_SEND: (_("Send"), Iconos.Enviar()),
            TB_STOP: (_("Play now"), Iconos.Stop()),
        }

        cf = self.manager.configuration
        peso = 75 if cf.x_tb_bold else 50
        puntos = cf.x_tb_fontpoints
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for key, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.key = key
            self.dic_toolbar[key] = accion
Exemplo n.º 16
0
    def __init__(self, procesador, winBookGuide, dbGames, wsummary, siMoves=True):
        QtGui.QWidget.__init__(self)

        self.winBookGuide = winBookGuide
        self.dbGames = dbGames  # <--setdbGames
        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.siMoves = siMoves

        self.wsummary = wsummary
        self.infoMove = None  # <-- setInfoMove
        self.summaryActivo = None  # movimiento activo en summary
        self.numJugada = 0  # Se usa para indicarla al mostrar el pgn en infoMove

        self.terminado = False # singleShot

        self.ap = AperturasStd.ap

        self.liFiltro = []
        self.where = None

        self.last_opening = None

        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("numero", _("N."), 70, siCentrado=True)
        liBasic = dbGames.liCamposBase
        ancho = 70
        for clave in liBasic:
            rotulo = TrListas.pgnLabel(clave)
            oColumnas.nueva(clave, rotulo, ancho, siCentrado=True)
        oColumnas.nueva("rowid", _("Row ID"), 70, siCentrado=True)
        oColumnas.nueva("opening", _("Opening"), 140)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, siSeleccionMultiple=True, xid="wgames")

        # Status bar
        self.status = QtGui.QStatusBar(self)
        self.status.setFixedHeight(22)

        # ToolBar
        liAccionesWork = [
            (_("Close"), Iconos.MainMenu(), self.tw_terminar), None,
            (_("File"), Iconos.File(), self.tg_file), None,
            (_("New"), Iconos.Nuevo(), self.tw_nuevo, _("Add a new game")), None,
            (_("Edit"), Iconos.Modificar(), self.tw_editar), None,
            (_("First"), Iconos.Inicio(), self.tw_gotop), None,
            (_("Last"), Iconos.Final(), self.tw_gobottom), None,
            (_("Filter"), Iconos.Filtrar(), self.tw_filtrar), None,
            (_("Remove"), Iconos.Borrar(), self.tw_borrar),None,
            (_("Move up"), Iconos.Arriba(), self.tw_up), None,
            (_("Move down"), Iconos.Abajo(), self.tw_down), None,
            (_("Config"), Iconos.Configurar(), self.tw_configure), None,
            (_("Utilities"), Iconos.Utilidades(), self.tw_utilities), None,
        ]

        self.tbWork = Controles.TBrutina(self, liAccionesWork, tamIcon=24, puntos=12)

        self.lbName = Controles.LB(self, "").ponWrap().alinCentrado().ponColorFondoN("white", "#4E5A65").ponTipoLetra(puntos=16)
        lyNT = Colocacion.H().control(self.lbName)
        if not siMoves:
            self.lbName.hide()

        lyTB = Colocacion.H().control(self.tbWork)

        layout = Colocacion.V().otro(lyNT).otro(lyTB).control(self.grid).control(self.status).margen(1)

        self.setLayout(layout)

        self.setNameToolBar()

        self.recuperaOrden()
Exemplo n.º 17
0
    def __init__(self, procesador, titulo):

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

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

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

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

        # Toolbar

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

        # Tab

        tab = Controles.Tab()

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

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

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

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

        # TAB General

        lyG = nuevoG()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # TAB Tiempo

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

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

        # TAB Initial moves

        lyG = nuevoG()

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

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

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

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

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

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

        self.setLayout(layout)

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

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

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

        self.recuperarVideo()
Exemplo n.º 18
0
    def __init__(self, procesador, wb_database, dbGames, wsummary, si_select):
        QtWidgets.QWidget.__init__(self)

        self.wb_database = wb_database
        self.dbGames = dbGames  # <--setdbGames
        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.wsummary = wsummary
        self.infoMove = None  # <-- setInfoMove
        self.summaryActivo = None  # movimiento activo en summary
        self.numJugada = 0  # Se usa para indicarla al mostrar el pgn en infoMove

        self.si_select = si_select

        self.terminado = False  # singleShot

        self.ap = AperturasStd.ap

        self.liFiltro = []
        self.where = None

        self.last_opening = None

        # Grid
        o_columns = self.lista_columnas()
        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True, xid="wgames")

        # Status bar
        self.status = QtWidgets.QStatusBar(self)
        self.status.setFixedHeight(22)

        # ToolBar
        if si_select:
            liAccionesWork = [
                (_("Accept"), Iconos.Aceptar(), wb_database.tw_aceptar),
                None,
                (_("Cancel"), Iconos.Cancelar(), wb_database.tw_cancelar),
                None,
                (_("First"), Iconos.Inicio(), self.tw_gotop),
                None,
                (_("Last"), Iconos.Final(), self.tw_gobottom),
                None,
                (_("Filter"), Iconos.Filtrar(), self.tw_filtrar),
                None,
            ]
        else:
            liAccionesWork = [
                (_("Close"), Iconos.MainMenu(), wb_database.tw_terminar),
                None,
                (_("Edit"), Iconos.Modificar(), self.tw_editar),
                None,
                (_("New"), Iconos.Nuevo(), self.tw_nuevo, _("Add a new game")),
                None,
                (_("Filter"), Iconos.Filtrar(), self.tw_filtrar),
                None,
                (_("First"), Iconos.Inicio(), self.tw_gotop),
                None,
                (_("Last"), Iconos.Final(), self.tw_gobottom),
                None,
                (_("Up"), Iconos.Arriba(), self.tw_up),
                None,
                (_("Down"), Iconos.Abajo(), self.tw_down),
                None,
                (_("Remove"), Iconos.Borrar(), self.tw_borrar),
                None,
                (_("Config"), Iconos.Configurar(), self.tw_configure),
                None,
                (_("Utilities"), Iconos.Utilidades(), self.tw_utilities),
                None,
                (_("Import"), Iconos.Import8(), self.tw_import),
                None,
                (_("Export"), Iconos.Export8(), self.tw_export),
                None,
                (_("Train"), Iconos.TrainStatic(), self.tw_train),
                None,

            ]

        self.tbWork = QTVarios.LCTB(self, liAccionesWork)

        lyTB = Colocacion.H().control(self.tbWork)

        layout = Colocacion.V().otro(lyTB).control(self.grid).control(self.status).margen(1)

        self.setLayout(layout)
Exemplo n.º 19
0
    def __init__(self, procesador, name, title, icono, folder, li_tam_blocks,
                 one_line):
        self.one_line = one_line
        if one_line:
            self.tol = TurnOnLights.read_oneline_tol()
        else:
            self.tol = TurnOnLights.read_tol(name, title, folder,
                                             li_tam_blocks)
        self.reinit = False

        titulo = _("Turn on the lights") + ": " + title
        if self.tol.is_calculation_mode():
            tipo = _("Calculation mode")
            background = "#88AA3A"
        else:
            tipo = _("Memory mode")
            background = "#BDDBE8"

        self.procesador = procesador
        extparam = "tol%s-%d" % (name, self.tol.work_level)

        QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, icono,
                                   extparam)

        self.colorTheme = QTUtil.qtColor("#F0F0F0")

        lb = Controles.LB(self, tipo)
        lb.ponFondoN(background).alinCentrado().ponTipoLetra(puntos=14)

        # Toolbar
        tb = Controles.TBrutina(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        anterior, siguiente, terminado = self.tol.prev_next()
        if terminado:
            tb.new(_("Rebuild"), Iconos.Reindexar(), self.rebuild)
        if anterior:
            tb.new(_("Previous"), Iconos.Anterior(), self.goto_previous)
        if siguiente:
            tb.new(_("Next"), Iconos.Siguiente(), self.goto_next)
        if one_line:
            tb.new(_("Change"), Iconos.TOLchange(), self.cambiar_one_line)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Information"), Iconos.Informacion(), self.colors)

        # Lista
        oColumnas = Columnas.ListaColumnas()
        work_level = self.tol.work_level + 1
        oColumnas.nueva("THEME",
                        _("Level %d/%d") % (work_level, self.tol.num_levels),
                        175)

        edicionIconos = Delegados.PmIconosColor()
        self.dicIconos = {}
        for k, pm in edicionIconos.dicpmIconos.iteritems():
            self.dicIconos[k] = QtGui.QIcon(pm)

        for x in range(self.tol.num_blocks):
            oColumnas.nueva("BLOCK%d" % x,
                            "%d" % (x + 1, ),
                            42,
                            siCentrado=True,
                            edicion=edicionIconos)

        self.grid = grid = Grid.Grid(self,
                                     oColumnas,
                                     altoFila=42,
                                     background="white")
        self.grid.setAlternatingRowColors(False)
        self.grid.tipoLetra(puntos=10, peso=500)
        nAnchoPgn = self.grid.anchoColumnas() + 20
        self.grid.setMinimumWidth(nAnchoPgn)
        self.registrarGrid(grid)

        # Colocamos ---------------------------------------------------------------
        ly = Colocacion.V().control(lb).control(tb).control(self.grid)

        self.setLayout(ly)

        alto = self.tol.num_themes * 42 + 146
        self.recuperarVideo(siTam=True,
                            altoDefecto=alto,
                            anchoDefecto=max(nAnchoPgn, 480))
Exemplo n.º 20
0
    def __init__(self, procesador):
        self.procesador = procesador
        self.configuracion = procesador.configuracion
        self.db = EndingsGTB.DBendings(self.configuracion)
        self.t4 = LibChess.T4(self.configuracion)

        QTVarios.WDialogo.__init__(
            self, procesador.main_window, _("Endings with Gaviota Tablebases"), Iconos.Finales(), "endings_gtb"
        )

        self.game = Game.Game()
        self.act_recno = -1

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Config"), Iconos.Configurar(), self.configurar),
            None,
            (_("Utilities"), Iconos.Utilidades(), self.utilidades),
            None,
        )
        tb = QTVarios.LCTB(self, li_acciones)

        ly_bt, self.bt_movs = QTVarios.lyBotonesMovimiento(
            self, "", siTiempo=True, siLibre=False, rutina=self.run_botones, tamIcon=24
        )

        self.chb_help = Controles.CHB(self, _("Help mode"), False)
        ly_bt.espacio(20).control(self.chb_help)

        self.wpzs = QtWidgets.QWidget(self)
        self.wpzs.li_labels = []
        ly_wpzs = Colocacion.H()
        for x in range(6):
            lbl = Controles.LB(self.wpzs)
            self.wpzs.li_labels.append(lbl)
            ly_wpzs.control(lbl)
        self.wpzs.setLayout(ly_wpzs)
        self.wpzs.mousePressEvent = self.change

        self.color_done = QTUtil.qtColorRGB(213, 233, 250)

        li_acciones = (
            None,
            (" " + _("Play"), Iconos.Play1(), self.play),
            None,
            (" " + _("New"), Iconos.New1(), self.nuevo),
            None,
            (" " + _("Remove"), Iconos.Remove1(), self.remove),
            None,
        )
        self.tb_run = Controles.TBrutina(self, li_acciones, tamIcon=32, puntos=self.configuracion.x_tb_fontpoints)

        ly_top = Colocacion.H().control(tb).relleno().control(self.wpzs).relleno().control(self.tb_run)
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUM", _("N."), 50, centered=True)
        o_columns.nueva("XFEN", _("Position"), 140, centered=True)
        o_columns.nueva("MATE", _("Mate"), 60, centered=True)
        o_columns.nueva("TRIES", _("Tries"), 50, centered=True)
        o_columns.nueva("MOVES", _("Minimum moves"), 120, centered=True)
        o_columns.nueva("TIMEMS", _("Minimum time"), 120, centered=True)
        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True)
        self.grid.tipoLetra(puntos=self.configuracion.x_pgn_fontpoints)
        self.grid.ponAltoFila(self.configuracion.x_pgn_rowheight)
        self.grid.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding))

        ly_pos = Colocacion.V().control(self.grid)

        config_board = self.configuracion.config_board("ENDINGSGTB", 64)
        self.tablero = TableroEndings(self, config_board)
        self.tablero.set_startup_control(self.startup_control)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)
        self.tablero.set_dispatcher(self.mueve_humano)

        self.pzs = self.tablero.piezas
        self.playing = False

        ly_left_bottom = Colocacion.V().control(self.tablero).otro(ly_bt).relleno().margen(0)
        w = QtWidgets.QWidget(self)
        w.setLayout(ly_left_bottom)
        w.setFixedWidth(self.tablero.ancho + 16)

        ly_bottom = Colocacion.H().control(w).otro(ly_pos)

        layout = Colocacion.V().otro(ly_top).otro(ly_bottom).margen(6)
        self.setLayout(layout)

        self.restore_video()

        dic = self.configuracion.leeVariables("endingsGTB")

        self.key = key = dic.get("KEY")
        if (not key) or len(key) > self.configuracion.piezas_gaviota():
            key = "KPk"
        self.db.set_examples_auto(dic.get("EXAMPLES_AUTO", True))
        self.set_key(key)

        self.play_next_type = dic.get("PLAY_NEXT", PLAY_STOP)

        self.grid.gotop()
        self.play()
    def __init__(self, procesador, winBookGuide, dbGamesFEN):
        QtGui.QWidget.__init__(self)

        self.winBookGuide = winBookGuide
        self.dbGamesFEN = dbGamesFEN
        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.infoMove = None  # <-- setInfoMove
        self.numJugada = 0  # Se usa para indicarla al mostrar el pgn en infoMove

        self.terminado = False # singleShot

        self.liFiltro = []
        self.where = None

        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("numero", _("N."), 70, siCentrado=True)
        liBasic = dbGamesFEN.liCamposBase
        for clave in liBasic:
            rotulo = TrListas.pgnLabel(clave)
            siCentrado = clave != "EVENT"

            ancho = 140 if clave == "FEN" else 70  # para que sirva con WBG_GamesFEN
            oColumnas.nueva(clave, rotulo, ancho, siCentrado=siCentrado)
        oColumnas.nueva("rowid", _("Row ID"), 70, siCentrado=True)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, siSeleccionMultiple=True, xid="wgamesfen")

        # Status bar
        self.status = QtGui.QStatusBar(self)
        self.status.setFixedHeight(22)

        # ToolBar
        liAccionesWork = [
            (_("Close"), Iconos.MainMenu(), self.tw_terminar), None,
            (_("File"), Iconos.File(), self.tg_file), None,
            (_("New"), Iconos.Nuevo(), self.tw_nuevo, _("Add a new game")), None,
            (_("Edit"), Iconos.Modificar(), self.tw_editar), None,
            (_("First"), Iconos.Inicio(), self.tw_gotop), None,
            (_("Last"), Iconos.Final(), self.tw_gobottom), None,
            (_("Filter"), Iconos.Filtrar(), self.tw_filtrar), None,
            (_("Remove"), Iconos.Borrar(), self.tw_borrar),None,
            (_("Up"), Iconos.Arriba(), self.tw_up), None,
            (_("Down"), Iconos.Abajo(), self.tw_down), None,
            (_("Config"), Iconos.Configurar(), self.tw_configure), None,
            (_("Utilities"), Iconos.Utilidades(), self.tw_utilities), None,
        ]

        self.tbWork = QTVarios.LCTB(self, liAccionesWork, tamIcon=24, puntos=procesador.configuracion.puntosTB)

        self.lbName = Controles.LB(self, "").ponWrap().alinCentrado().ponColorFondoN("white", "#4E5A65").ponTipoLetra(puntos=16)
        lyNT = Colocacion.H().control(self.lbName)

        lyTB = Colocacion.H().control(self.tbWork)

        layout = Colocacion.V().otro(lyNT).otro(lyTB).control(self.grid).control(self.status).margen(1)

        self.setLayout(layout)

        self.setNameToolBar()
Exemplo n.º 22
0
    def __init__(self, procesador, winBookGuide, dbGames, siMoves=True):
        QtGui.QWidget.__init__(self)

        self.winBookGuide = winBookGuide

        self.dbGames = dbGames  # <--setdbGames
        self.bookGuide = winBookGuide.bookGuide
        self.infoMove = None  # <-- setInfoMove
        self.wmoves = None  # <-- setwmoves
        self.fenM2 = None
        self.liMoves = []
        self.analisisMRM = None
        self.siMoves = siMoves
        self.procesador = procesador
        self.configuracion = procesador.configuracion

        self.leeConfig()

        self.aperturasStd = AperturasStd.ListaAperturasStd(
            self.configuracion, False, False)

        self.siFigurinesPGN = self.configuracion.figurinesPGN

        self.pvBase = ""

        self.orden = ["games", False]

        self.lbName = Controles.LB(
            self, "").ponWrap().alinCentrado().ponColorFondoN(
                "white", "#4E5A65").ponTipoLetra(puntos=10 if siMoves else 16)
        if not siMoves:
            self.lbName.hide()

        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("numero", _("N."), 35, siCentrado=True)
        self.delegadoMove = Delegados.EtiquetaPGN(
            True if self.siFigurinesPGN else None)
        oColumnas.nueva("move", _("Move"), 60, edicion=self.delegadoMove)
        dicTipos = {
            "t": Iconos.pmTransposition(),
        }
        oColumnas.nueva("trans",
                        "",
                        24,
                        edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        oColumnas.nueva("analisis", _("Analysis"), 60, siDerecha=True)
        oColumnas.nueva("games", _("Games"), 70, siDerecha=True)
        oColumnas.nueva("pgames",
                        "% " + _("Games"),
                        70,
                        siDerecha=True,
                        siCentrado=True)
        oColumnas.nueva("win", _("Win"), 70, siDerecha=True)
        oColumnas.nueva("draw", _("Draw"), 70, siDerecha=True)
        oColumnas.nueva("lost", _("Lost"), 70, siDerecha=True)
        oColumnas.nueva("pwin", "% " + _("Win"), 60, siDerecha=True)
        oColumnas.nueva("pdraw", "% " + _("Draw"), 60, siDerecha=True)
        oColumnas.nueva("plost", "% " + _("Lost"), 60, siDerecha=True)
        oColumnas.nueva("pdrawwin", "%% %s" % _("W+D"), 60, siDerecha=True)
        oColumnas.nueva("pdrawlost", "%% %s" % _("L+D"), 60, siDerecha=True)

        self.grid = Grid.Grid(self,
                              oColumnas,
                              xid="summary",
                              siSelecFilas=True)
        self.grid.tipoLetra(puntos=self.configuracion.puntosPGN)
        self.grid.ponAltoFila(self.configuracion.altoFilaPGN)

        # ToolBar
        liAcciones = [
            (_("Close"), Iconos.MainMenu(), winBookGuide.terminar),
            None,
            (_("Start position"), Iconos.Inicio(), self.inicio),
            None,
            (_("Previous"), Iconos.AnteriorF(), self.anterior),
            (_("Next"), Iconos.SiguienteF(), self.siguiente),
            None,
            (_("Analyze"), Iconos.Analizar(), self.analizar),
            None,
            (_("Rebuild"), Iconos.Reindexar(), self.reindexar),
            None,
            (_("Config"), Iconos.Configurar(), self.config),
            None,
        ]
        if siMoves:
            liAcciones.append(
                (_("Create a new guide based in these games") if siMoves else
                 _("Create"), Iconos.BookGuide(), self.createGuide))
            liAcciones.append(None)

        self.tb = Controles.TBrutina(self,
                                     liAcciones,
                                     tamIcon=20,
                                     siTexto=not self.siMoves)
        if self.siMoves:
            self.tb.vertical()

        layout = Colocacion.V().control(self.lbName)
        if not self.siMoves:
            layout.control(self.tb)
        layout.control(self.grid)
        if self.siMoves:
            layout = Colocacion.H().control(self.tb).otro(layout)

        layout.margen(1)

        self.setLayout(layout)

        self.qtColor = (QTUtil.qtColorRGB(221, 255, 221),
                        QTUtil.qtColorRGB(247, 247, 247),
                        QTUtil.qtColorRGB(255, 217, 217))
        self.qtColorTotales = QTUtil.qtColorRGB(170, 170, 170)
Exemplo n.º 23
0
    def __init__(self, wParent, sts, work, procesador):
        titulo = "%s - %s" % (sts.name, work.ref)
        icono = Iconos.STS()
        extparam = "runsts"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        self.work = work
        self.sts = sts
        self.xengine = procesador.creaGestorMotor(work.configEngine(),
                                                  work.seconds * 1000,
                                                  work.depth)
        self.playing = False
        self.configuracion = procesador.configuracion
        dic = self.configuracion.leeVariables("STSRUN")
        self.hideBoard = dic["HIDEBOARD"] if dic else False

        # Toolbar
        liAcciones = [
            (_("Close"), Iconos.MainMenu(), self.cerrar),
            None,
            (_("Run"), Iconos.Run(), self.run),
            (_("Pause"), Iconos.Pelicula_Pausa(), self.pause),
            None,
            (_("Config"), Iconos.Configurar(), self.config),
            None,
        ]
        self.tb = tb = Controles.TBrutina(self, liAcciones, tamIcon=24)

        # Board
        confTablero = self.configuracion.confTablero("STS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()

        # Area resultados
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("GROUP", _("Group"), 180)
        oColumnas.nueva("DONE", _("Done"), 100, siCentrado=True)
        oColumnas.nueva("RESULT", _("Result"), 150, siCentrado=True)
        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True)

        # self.splitter = splitter = QtGui.QSplitter(self)
        # splitter.addWidget(self.tablero)
        # splitter.addWidget(self.grid)
        # self.registrarSplitter(splitter,"base")

        layout = Colocacion.H()
        layout.control(self.tablero)
        layout.control(self.grid)
        layout.margen(3)

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

        self.setLayout(ly)

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

        resp = self.sts.siguientePosicion(self.work)
        if resp:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, True)
        else:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, False)

        self.setViewBoard()
Exemplo n.º 24
0
    def preparaTB(self):

        self.dicTB = {}

        liOpciones = (
            (_("Quit"), Iconos.Terminar(), k_terminar),
            (_("Play"), Iconos.Libre(), k_play),
            (_("Compete"), Iconos.NuevaPartida(), k_competir),
            (_("Train"), Iconos.Entrenamiento(), k_entrenamiento),
            (_("Options"), Iconos.Opciones(), k_opciones),
            (_("Information"), Iconos.Informacion(), k_informacion),
            (_("Save"), Iconos.Grabar(), k_grabar),
            (_("Save as"), Iconos.GrabarComo(), k_grabarComo),
            (_("Open"), Iconos.Recuperar(), k_recuperar),
            (_("Resign"), Iconos.Abandonar(), k_abandonar),
            (_("Reinit"), Iconos.Reiniciar(), k_reiniciar),
            (_("Takeback"), Iconos.Atras(), k_atras),
            (_("Adjourn"), Iconos.Aplazar(), k_aplazar),
            (_("End game"), Iconos.FinPartida(), k_finpartida),
            (_("Close"), Iconos.MainMenu(), k_mainmenu),
            (_("Reinit"), Iconos.Reiniciar(), k_ent_empezar),
            (_("Previous"), Iconos.Anterior(), k_anterior),
            (_("Next"), Iconos.Siguiente(), k_siguiente),
            (_("Quit"), Iconos.FinPartida(), k_pgnFin),
            (_("Paste PGN"), Iconos.Pegar(), k_pgnPaste),
            (_("Read PGN"), Iconos.Fichero(), k_pgnFichero),
            (_("PGN Labels"), Iconos.InformacionPGN(), k_pgnInformacion),
            (_("Other game"), Iconos.FicheroRepite(), k_pgnFicheroRepite),
            (_("My games"), Iconos.NuestroFichero(), k_pgnNuestroFichero),
            (_("Resign"), Iconos.Rendirse(), k_rendirse),
            (_("Draw"), Iconos.Tablas(), k_tablas),
            (_("Boxrooms PGN"), Iconos.Trasteros(), k_trasteros),
            (_("End"), Iconos.MainMenu(), k_peliculaTerminar),
            (_("Slow"), Iconos.Pelicula_Lento(), k_peliculaLento),
            (_("Pause"), Iconos.Pelicula_Pausa(), k_peliculaPausa),
            (_("Continue"), Iconos.Pelicula_Seguir(), k_peliculaSeguir),
            (_("Fast"), Iconos.Pelicula_Rapido(), k_peliculaRapido),
            (_("Repeat"), Iconos.Pelicula_Repetir(), k_peliculaRepetir),
            (_("PGN"), Iconos.Pelicula_PGN(), k_peliculaPGN),
            (_("Play"), Iconos.Jugar(), k_jugar),
            (_("Help"), Iconos.AyudaGR(), k_ayuda),
            (_("Level"), Iconos.Jugar(), k_mateNivel),
            (_("Accept"), Iconos.Aceptar(), k_aceptar),
            (_("Cancel"), Iconos.Cancelar(), k_cancelar),
            (_("Game of the day"), Iconos.LM(), k_jugadadia),
            (_("Config"), Iconos.Configurar(), k_configurar),
            (_("Utilities"), Iconos.Utilidades(), k_utilidades),
            (_("Variants"), Iconos.VariantesG(), k_variantes),
            (_("Tools"), Iconos.Tools(), k_tools),
            (_("Change"), Iconos.Cambiar(), k_cambiar),
            (_("Show text"), Iconos.Modificar(), k_showtext),
            (_("Help to move"), Iconos.BotonAyuda(), k_ayudaMover),
            (_("Send"), Iconos.Enviar(), k_enviar),
            # ( "Debug", Iconos.Camara(), 999),# Martin debug
        )

        cf = self.gestor.configuracion
        peso = 75 if cf.boldTB else 50
        puntos = cf.puntosTB
        font = Controles.TipoLetra(puntos=puntos, peso=peso)

        for titulo, icono, clave in liOpciones:
            accion = QtGui.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            self.connect(accion, QtCore.SIGNAL("triggered()"),
                         self.procesarAccion)
            accion.clave = clave
            self.dicTB[clave] = accion
Exemplo n.º 25
0
    def init_working(self, route, lyTitle, lySVG):

        # Line
        line = route.get_line()
        tt = route.tool_tip_line()
        lbTip = (Controles.LB(
            _("Stage") + " %d/%d" %
            (line.stage, route.num_stages)).ponTipoLetra(
                puntos=11).anchoFijo(120).align_center())
        lbTip.setToolTip(tt)
        lbTit = self.LINE(line.st_from.name, line.st_to.name, 11)
        lbTit.setToolTip(tt)
        lbKM = self.KM(line.km, 11)
        self.set_style("Black", "Cornsilk", lbTip, lbTit, lbKM)
        lbKM.setToolTip(tt)
        lbKMdone = self.KM(line.km_done(route.km), 11)
        self.set_border(lbKMdone)
        lyLine = Colocacion.H().control(lbTip).control(lbTit).control(
            lbKM).control(lbKMdone)

        # Track
        st_from, st_to = route.get_track()
        tt = route.tool_tip_track()
        lbTip = (Controles.LB(
            _("Track") + " %d/%d" %
            (route.num_track, line.num_stations)).ponTipoLetra(
                puntos=11).anchoFijo(120).align_center())
        lbTip.setToolTip(tt)
        lbTit = self.LINE(st_from.name, st_to.name, 11)
        lbTit.setToolTip(tt)
        lbKM = self.KM(st_to.km - st_from.km, 11)
        lbKM.setToolTip(tt)
        self.set_style("Black", "#E6DFC6", lbTip, lbTit, lbKM)
        lbKMdone = self.KM(route.km - st_from.km, 11)
        self.set_border(lbKMdone)
        lyTrack = Colocacion.H().control(lbTip).control(lbTit).control(
            lbKM).control(lbKMdone)

        # State
        lbTip = Controles.LB(_("State")).ponTipoLetra(
            puntos=11, peso=200).anchoFijo(120).align_center()
        lbTit = Controles.LB(route.mens_state()).ponTipoLetra(
            puntos=11, peso=200).align_center()
        self.set_style("White", "#B2AE9A", lbTip, lbTit)
        lyState = Colocacion.H().control(lbTip).control(lbTit)

        # Next task
        texto, color = route.next_task()
        lbTip = Controles.LB(_("Next task")).ponTipoLetra(
            puntos=11, peso=500).anchoFijo(120).align_center()
        lbTit = Controles.LB(texto).ponTipoLetra(puntos=11,
                                                 peso=500).align_center()
        self.set_style("White", color, lbTip, lbTit)
        lyTask = Colocacion.H().control(lbTip).control(lbTit)

        tb = QTVarios.LCTB(self, with_text=True, icon_size=32)
        tb.new(_("Play"), Iconos.Empezar(), self.play)
        tb.new(_("Config"), Iconos.Configurar(), self.config)
        tb.new(_("Close"), Iconos.MainMenu(), self.mainMenu)
        tb.setFixedWidth(206)
        lbTim = (Controles.LB(
            "%s: %s" % (_("Time"), route.time())).ponTipoLetra(
                puntos=11, peso=500).align_center().anchoFijo(206))
        lbTim.setToolTip("%s %s\n%s %s\n%s %s\n%s %s" % (
            route.time(),
            _("Total"),
            route.time(Routes.PLAYING),
            _("Playing"),
            route.time(Routes.BETWEEN),
            _("Tactics"),
            route.time(Routes.ENDING),
            _("Endings"),
        ))

        self.set_style("White", color, lbTit)
        self.set_style("White", "#B2AE9A", lbTim)
        lyStTa = Colocacion.V().otro(lyState).otro(lyTask)
        lyTB = Colocacion.V().control(lbTim).control(tb)
        lyAll = Colocacion.H().otro(lyStTa).otro(lyTB)

        ly = Colocacion.V().otro(lyTitle).otro(lySVG).otro(lyLine).otro(
            lyTrack).otro(lyAll).relleno(1)
        self.setLayout(ly)
Exemplo n.º 26
0
    def __init__(self, wParent, sts, work, procesador):
        titulo = "%s - %s - %s" % (sts.name, work.ref, work.pathToExe())
        icono = Iconos.STS()
        extparam = "runsts"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        self.work = work
        self.sts = sts
        self.ngroup = -1
        self.xengine = procesador.creaGestorMotor(work.configEngine(), work.seconds * 1000, work.depth)
        self.xengine.set_direct( )
        self.playing = False
        self.configuracion = procesador.configuracion
        dic = self.configuracion.leeVariables("STSRUN")
        self.hideBoard = dic["HIDEBOARD"] if dic else False

        # Toolbar
        liAcciones = [(_("Close"), Iconos.MainMenu(), self.cerrar), None,
                      (_("Run"), Iconos.Run(), self.run),
                      (_("Pause"), Iconos.Pelicula_Pausa(), self.pause), None,
                      (_("Config"), Iconos.Configurar(), self.config), None,
                      ]
        self.tb = tb = Controles.TBrutina(self, liAcciones, tamIcon=24)

        # Board
        confTablero = self.configuracion.confTablero("STS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()

        # Area resultados
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("GROUP", _("Group"), 180)
        oColumnas.nueva("DONE", _("Done"), 100, siCentrado=True)
        oColumnas.nueva("WORK", _("Result"), 120, siCentrado=True)

        self.dworks = self.read_works()
        self.calc_max()
        for x in range(len(self.sts.works)-1, -1, -1):
            work = self.sts.works.getWork(x)
            if work != self.work:
                key = "OTHER%d" % x
                reg = self.dworks[key]
                oColumnas.nueva(key, reg.title, 120, siCentrado=True)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True)

        self.colorMax = QTUtil.qtColor("#840C24")
        self.colorOth = QTUtil.qtColor("#4668A6")

        layout = Colocacion.H()
        layout.control(self.tablero)
        layout.control(self.grid)
        layout.margen(3)

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

        self.setLayout(ly)

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

        resp = self.sts.siguientePosicion(self.work)
        if resp:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, True)
        else:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, False)

        self.setViewBoard()
Exemplo n.º 27
0
    def __init__(self, procesador, wb_database, dbGames, siMoves=True):
        QtWidgets.QWidget.__init__(self)

        self.wb_database = wb_database

        self.dbGames = dbGames  # <--setdbGames
        self.infoMove = None  # <-- setInfoMove
        self.wmoves = None  # <-- setwmoves
        self.liMoves = []
        self.siMoves = siMoves
        self.procesador = procesador
        self.configuration = procesador.configuration

        self.wdb_analysis = WDB_Analysis.WDBAnalisis(self)

        self.leeConfig()

        self.aperturasStd = OpeningsStd.ap

        self.si_figurines_pgn = self.configuration.x_pgn_withfigurines

        self.pvBase = ""

        self.orden = ["games", False]

        self.lbName = (
            Controles.LB(self, "")
            .set_wrap()
            .align_center()
            .set_foreground_backgound("white", "#4E5A65")
            .ponTipoLetra(puntos=10 if siMoves else 16)
        )
        if not siMoves:
            self.lbName.hide()

        # Grid
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("number", _("N."), 35, centered=True)
        self.delegadoMove = Delegados.EtiquetaPGN(True if self.si_figurines_pgn else None)
        o_columns.nueva("move", _("Move"), 60, edicion=self.delegadoMove)
        o_columns.nueva("analysis", _("Analysis"), 60, siDerecha=True)
        o_columns.nueva("games", _("Games"), 70, siDerecha=True)
        o_columns.nueva("pgames", "% " + _("Games"), 70, siDerecha=True)
        o_columns.nueva("win", _("Win"), 70, siDerecha=True)
        o_columns.nueva("draw", _("Draw"), 70, siDerecha=True)
        o_columns.nueva("lost", _("Lost"), 70, siDerecha=True)
        o_columns.nueva("pwin", "% " + _("Win"), 60, siDerecha=True)
        o_columns.nueva("pdraw", "% " + _("Draw"), 60, siDerecha=True)
        o_columns.nueva("plost", "% " + _("Lost"), 60, siDerecha=True)
        o_columns.nueva("pdrawwin", "%% %s" % _("W+D"), 60, siDerecha=True)
        o_columns.nueva("pdrawlost", "%% %s" % _("L+D"), 60, siDerecha=True)

        self.grid = Grid.Grid(self, o_columns, xid="summary", siSelecFilas=True)
        self.grid.tipoLetra(puntos=self.configuration.x_pgn_fontpoints)
        self.grid.ponAltoFila(self.configuration.x_pgn_rowheight)

        # ToolBar
        li_acciones = [
            (_("Start position"), Iconos.Inicio(), self.start),
            None,
            (_("Previous"), Iconos.AnteriorF(), self.anterior),
            (_("Next"), Iconos.SiguienteF(), self.siguiente),
            None,
            (_("Analyze"), Iconos.Analizar(), self.analizar),
            None,
            (_("Rebuild"), Iconos.Reindexar(), self.reindexar),
            None,
            (_("Config"), Iconos.Configurar(), self.config),
            None,
        ]

        self.tb = QTVarios.LCTB(self, li_acciones, icon_size=20, with_text=not self.siMoves)
        if self.siMoves:
            self.tb.vertical()

        layout = Colocacion.V().control(self.lbName)
        if not self.siMoves:
            layout.control(self.tb)
        layout.control(self.grid)
        if self.siMoves:
            layout = Colocacion.H().control(self.tb).otro(layout)

        layout.margen(1)

        self.setLayout(layout)

        self.qtColor = (QTUtil.qtColorRGB(221, 255, 221), QTUtil.qtColorRGB(247, 247, 247), QTUtil.qtColorRGB(255, 217, 217))
        self.qtColorTotales = QTUtil.qtColorRGB(170, 170, 170)