示例#1
0
    def elo(self):
        menu = QTVarios.LCMenu(self.pantalla)

        menu.opcion("lucaselo", "%s (%d)" % (_("Lucas-Elo"), self.configuracion.elo), Iconos.Elo())
        menu.separador()
        if VarGen.isWindows or VarGen.isWine:
            menu.opcion("micelo", "%s (%d)" % (_("Tourney-Elo"), self.configuracion.michelo), Iconos.EloTimed())
            menu.separador()
        fics = self.configuracion.fics
        menuf = menu.submenu("%s (%d)" % (_("Fics-Elo"), fics), Iconos.Fics())
        rp = QTVarios.rondoPuntos()
        for elo in range(900, 2800, 100):
            if (elo == 900) or (0 <= (elo + 99 - fics) <= 400 or 0 <= (fics - elo) <= 400):
                menuf.opcion("fics%d" % (elo / 100,), "%d-%d" % (elo, elo + 99), rp.otro())
        fide = self.configuracion.fide
        menu.separador()
        menuf = menu.submenu("%s (%d)" % (_("Fide-Elo"), fide), Iconos.Fide())
        rp = QTVarios.rondoPuntos()
        for elo in range(1500, 2700, 100):
            if (elo == 1500) or (0 <= (elo + 99 - fide) <= 400 or 0 <= (fide - elo) <= 400):
                menuf.opcion("fide%d" % (elo / 100,), "%d-%d" % (elo, elo + 99), rp.otro())
        resp = menu.lanza()

        if resp:
            if resp == "lucaselo":
                self.lucaselo(True)
            elif resp == "micelo":
                self.micelo(True)
            elif resp.startswith("fics"):
                self.ficselo(True, int(resp[4:]))
            elif resp.startswith("fide"):
                self.fideelo(True, int(resp[4:]))
示例#2
0
 def reset(self):
     for pzB in "kqrbnp":
         lbPZw, cbPZw, lbPZ, lbPZb, cbPZb, tipoW, tipoB = self.dicWidgets[pzB]
         tipoNv = cbPZw.valor()
         if tipoW != tipoNv:
             pzW = pzB.upper()
             self.config.dicPiezas[pzW] = tipoNv
             self.dicWidgets[pzB][5] = tipoNv  # tiene que ser pzB que esta en misnusculas
             fich = self.config.ficheroBase(pzB, True)
             if fich in self.dicImgs:
                 pm = self.dicImgs[fich]
             else:
                 pm = QTVarios.fsvg2pm(fich, 32)
                 self.dicImgs[fich] = pm
             lbPZw.ponImagen(pm)
         tipoNv = cbPZb.valor()
         if tipoB != tipoNv:
             self.config.dicPiezas[pzB] = tipoNv
             self.dicWidgets[pzB][6] = tipoNv
             fich = self.config.ficheroBase(pzB, False)
             if fich in self.dicImgs:
                 pm = self.dicImgs[fich]
             else:
                 pm = QTVarios.fsvg2pm(fich, 32)
                 self.dicImgs[fich] = pm
             lbPZb.ponImagen(pm)
示例#3
0
 def ponTema(self, tema):
     self.setVisible(tema is not None)
     self.tema = tema
     if not tema:
         return
     self.setToolTip(tema["NOMBRE"])
     self.setIcon(QTVarios.iconoTema(tema, 64))
示例#4
0
 def creaTablero(nombre, si=True, siLibre=True, siPunto=False):
     if not si:
         return None, None, None
     tablero = Tablero.Tablero(self, confTablero)
     tablero.crea()
     tablero.ponerPiezasAbajo(siBlancas)
     lytb, tb = QTVarios.lyBotonesMovimiento(self, nombre, siLibre)
     return tablero, lytb, tb
示例#5
0
 def micelo(self, siCompetitivo):
     self.gestor = GestorMicElo.GestorMicElo(self)
     resp = PantallaMotores.eligeMotorMicElo(self.gestor, self.configuracion.miceloActivo(siCompetitivo))
     if resp:
         respT = QTVarios.tiempo(self.pantalla, minMinutos=10 if siCompetitivo else 3, minSegundos=0, maxMinutos=999,
                                 maxSegundos=999)
         if respT:
             minutos, segundos = respT
             self.gestor.inicio(resp, minutos, segundos, siCompetitivo)
示例#6
0
    def __init__(self, gestor, xmotor, nombreOP, posicion, mrm, rmOP, rmUsu, analisis):
        self.siCompetitivo = gestor.siCompetitivo
        self.nombreOP = nombreOP
        self.posicion = posicion
        self.rmOP = rmOP
        self.rmUsu = rmUsu
        self.mrm = mrm
        self.analisis = analisis
        self.xmotor = xmotor
        self.gestor = gestor

        self.listaRM, self.posOP = self.hazListaRM()
        self.posicion = posicion

        titulo = _("Analysis")
        icono = Iconos.Analizar()
        extparam = "jzgm"
        QTVarios.WDialogo.__init__(self, gestor.pantalla, titulo, icono, extparam)

        self.colorNegativo = QTUtil.qtColorRGB(255, 0, 0)
        self.colorImpares = QTUtil.qtColorRGB(231, 244, 254)

        self.lbComentario = Controles.LB(self, "").ponTipoLetra(puntos=10).alinCentrado()

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

        self.lbMotor = Controles.LB(self).alinCentrado()
        self.lbTiempo = Controles.LB(self).alinCentrado()

        liMas = ( (_("Close"), "close", Iconos.Delete() ), )
        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=True, tamIcon=24, siMas=True, liMasAcciones=liMas)

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("POSREAL", "#", 40, siCentrado=True)
        oColumnas.nueva("JUGADAS", "%d %s" % (len(self.listaRM), _("Moves")), 120, siCentrado=True)
        oColumnas.nueva("PLAYER", _("Player"), 120)

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

        lyT = Colocacion.V().control(self.tablero).otro(lyBM).control(self.lbComentario)

        # Layout
        layout = Colocacion.H().otro(lyT).control(self.grid)

        self.setLayout(layout)

        self.grid.setFocus()

        self.grid.goto(self.posOP, 0)
        self.siMoviendoTiempo = False

        self.ponPuntos()
示例#7
0
    def menu(self, parent):
        menu = Controles.Menu(parent)

        rp = QTVarios.rondoPuntos()

        submenu = menu.submenu(_("Internal engines"), self.dicIconos[INTERNO])
        for cm in self.liMotoresInternos:
            clave = INTERNO, cm
            texto = cm.nombre
            icono = rp.otro()
            elo = cm.elo
            submenu.opcion(clave, "%s (%d)" % (texto, elo), icono)
        menu.separador()
        submenu = menu.submenu(_("External engines"), self.dicIconos[EXTERNO])
        for cm in self.liMotoresExternos:
            clave = EXTERNO, cm
            texto = cm.clave
            icono = rp.otro()
            submenu.opcion(clave, texto, icono)
        submenu.separador()
        clave = EXTERNO, None
        texto = _("Edition")
        icono = Iconos.Mas()
        submenu.opcion(clave, texto, icono)

        menu.separador()
        submenu = menu.submenu(_("GM engines"), self.dicIconos[MICGM])
        for gm, li in self.dicMotoresGM.iteritems():
            icono = rp.otro()
            submenuGM = submenu.submenu(gm, icono)
            for cm in li:
                clave = MICGM, cm
                texto = cm.alias.split(" ")[2]
                submenuGM.opcion(clave, texto, icono)
            submenuGM.separador()

        menu.separador()
        menu.opcion((MICPER, None), _("Tourney engines"), self.dicIconos[MICPER])

        menu.separador()
        submenu = menu.submenu(_("Engines with fixed elo"), self.dicIconos[FIXED])
        li = self.dicMotoresFixedElo.keys()
        li.sort()
        for elo in li:
            icono = rp.otro()
            submenuElo = submenu.submenu(str(elo), icono)
            lien = self.dicMotoresFixedElo[elo]
            lien.sort(key=lambda x: x.nombre)
            for cm in lien:
                clave = FIXED, cm
                texto = cm.nombre
                submenuElo.opcion(clave, texto, icono)
            submenuElo.separador()

        return menu.lanza()
示例#8
0
    def selectOther(self):
        li = self.bookGuide.getOtras()
        if not li:
            return None
        menu = QTVarios.LCMenu(self)
        nico = QTVarios.rondoColores()

        for k in li:
            menu.opcion(k, k, nico.otro())
            menu.separador()
        return menu.lanza()
示例#9
0
    def __init__(self, oBase, ventana, segundosPensando, siBlancas, cPuntos, maxRecursion):
        super(WAnalisisVariantes, self).__init__(ventana)

        self.oBase = oBase

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

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

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

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

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

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

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

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

        # Creamos los layouts

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

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

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

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

        self.setLayout(layout)

        self.move(ventana.x() + 20, ventana.y() + 20)
示例#10
0
def ponMenuTemas(menuBase, liTemas, baseResp):
    baseResp += "%d"

    dFolders = Util.SymbolDict()
    liRoot = []
    for n, uno in enumerate(liTemas):
        if uno:
            if "SECCION" in uno:
                folder = uno["SECCION"]
                if folder not in dFolders:
                    dFolders[folder] = []
                dFolders[folder].append((uno, n))
            else:
                liRoot.append((uno, n))
    icoFolder = Iconos.DivisionF()
    for k in dFolders:
        mf = menuBase.submenu(k, icoFolder)
        for uno, n in dFolders[k]:
            mf.opcion(baseResp % n, uno["NOMBRE"], QTVarios.iconoTema(uno, 16))
    menuBase.separador()
    for uno, n in liRoot:
        menuBase.opcion(baseResp % n, uno["NOMBRE"], QTVarios.iconoTema(uno, 16))
    menuBase.separador()
示例#11
0
    def ayuda(self):
        menu = QTVarios.LCMenu(self)

        nico = QTVarios.rondoColores()

        for opcion, txt in (
            (self.borraJUMPS, _("Without repetitions of each puzzle")),
            (self.borraREPEAT, _("Without repetitions of block")),
            (self.borraPENALIZATION, _("Without penalties")),
        ):
            menu.opcion(opcion, txt, nico.otro())
            menu.separador()

        resp = menu.lanza()
        if resp:
            resp()
示例#12
0
    def enImportar(self):
        menu = QTVarios.LCMenu(self)
        lista = VarGen.configuracion.comboMotoresCompleto()
        nico = QTVarios.rondoPuntos()
        for nombre, clave in lista:
            menu.opcion(clave, nombre, nico.otro())

        resp = menu.lanza()
        if not resp:
            return

        me = Torneo.Engine()
        me.ponHuella(self.torneo.liEngines())
        me.leerConfigEngine(resp)
        self.torneo.appendEngine(me)
        self.gridEnginesAlias.refresh()
        self.gridEnginesAlias.gobottom(0)

        self.borraResult()
示例#13
0
        def miraDir(submenu, base, dr):
            if base:
                pathCarpeta = base + dr + "/"
                smenu = submenu.submenu(dr, Iconos.Carpeta())
            else:
                pathCarpeta = dr + "/"
                smenu = submenu
            li = []
            for fich in os.listdir(pathCarpeta):
                pathFich = pathCarpeta + fich
                if os.path.isdir(pathFich):
                    miraDir(smenu, pathCarpeta, fich)
                elif pathFich.lower().endswith(".svg"):
                    li.append((pathFich, fich))

            for pathFich, fich in li:
                ico = QTVarios.fsvg2ico(pathFich, 32)
                if ico:
                    smenu.opcion(pathFich, fich[:-4], ico)
示例#14
0
    def tacticas(self, tipo, nombre, carpeta, ini):
        um = self.procesador.unMomento()
        tacticas = Tacticas.Tacticas(tipo, nombre, carpeta, ini)
        liMenus = tacticas.listaMenus()
        if len(liMenus) == 0:
            um.final()
            return

        nico = QTVarios.rondoPuntos()
        if len(liMenus) > 1:
            menu = QTVarios.LCMenu(self.parent)
            menu.opcion(None, _SP(nombre), Iconos.Tacticas())
            menu.separador()

            dmenu = {}

            for valor, lista in liMenus:
                actmenu = menu
                if len(lista) > 1:
                    t = ""
                    for x in range(len(lista) - 1):
                        t += "|%s" % lista[x]
                        if t not in dmenu:
                            dmenu[t] = actmenu.submenu(_SP(lista[x]), nico.otro())
                            actmenu.separador()
                        actmenu = dmenu[t]
                actmenu.opcion(valor, _SP(lista[-1]), nico.otro())
                actmenu.separador()
            um.final()
            resp = menu.lanza()

        else:
            resp = liMenus[0][0]

        if not resp:
            um.final()
            return

        tactica = tacticas.eligeTactica(resp)

        um.final()
        if tactica:
            self.entrenaTactica(tactica)
示例#15
0
    def __init__(self, owner, configuracion, bloqueApertura):
        icono = Iconos.Apertura()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        super().__init__(parent=owner, titulo=titulo, icono=icono, extparam=extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = AperturasStd.apTrain
        self.configuracion = configuracion
        self.partida = Partida.Partida()
        self.bloqueApertura = bloqueApertura
        self.liActivas = []

        # Tablero
        confTablero = configuracion.confTablero("APERTURAS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueveHumano)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").ponWrap().ponTipoLetra(puntos=10, peso=75)

        # Movimiento
        self.siMoviendoTiempo = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new(_("Accept"), Iconos.Aceptar(), self.aceptar)
        tb.new(_("Cancel"), Iconos.Cancelar(), self.cancelar)
        tb.new(_("Reinit"), Iconos.Reiniciar(), self.resetPartida)
        tb.new(_("Takeback"), Iconos.Atras(), self.atras)
        tb.new(_("Remove"), Iconos.Borrar(), self.borrar)

        # Lista Aperturas
        oColumnas = Columnas.ListaColumnas()
        dicTipos = {"b": Iconos.pmSun(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja()}
        oColumnas.nueva("TIPO", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        oColumnas.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, altoFila=32)
        self.registrarGrid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.tablero).otro(lyBM).control(self.lbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtWidgets.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.registrarSplitter(splitter, "splitter")

        # Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()

        dic = {'_SIZE_': '916,444', 'SP_splitter': [356, 548]}
        self.recuperarVideo(dicDef=dic)
示例#16
0
    def config(self):
        menu = QTVarios.LCMenu(self)
        smenu = menu.submenu(_("Change the unit of measurement"),
                             Iconos.Measure())
        is_miles = self.route.is_miles
        dico = {True: Iconos.Aceptar(), False: Iconos.PuntoVerde()}
        dkey = {True: None, False: "k"}
        smenu.opcion(dkey[not is_miles],
                     _("Kilometres"),
                     dico[not is_miles],
                     siDeshabilitado=not is_miles)
        smenu.opcion(dkey[is_miles],
                     _("Miles (internally works in km)"),
                     dico[is_miles],
                     siDeshabilitado=is_miles)

        menu.separador()
        smenu = menu.submenu(_("Tactics"), Iconos.Tacticas())
        dkey = {True: None, False: "g"}
        go_fast = self.route.go_fast
        smenu.opcion(dkey[not go_fast],
                     _("Stop after solve"),
                     dico[not go_fast],
                     siDeshabilitado=not go_fast)
        smenu.opcion(dkey[go_fast],
                     _("Jump to the next after solve"),
                     dico[go_fast],
                     siDeshabilitado=go_fast)

        if self.route.km:
            menu.separador()
            menu.opcion("rst", _("Return to the starting point"),
                        Iconos.Delete())

        menu.separador()
        smenu = menu.submenu(_("Change level"), Iconos.Modificar())
        rondo = QTVarios.rondoPuntos()
        level = self.route.level
        for lv in range(1, 6):
            if lv != level:
                smenu.opcion("l%d" % lv, "%s %d" % (_("Level"), lv),
                             rondo.otro())

        resp = menu.lanza()
        if resp:
            if resp == "rst":
                if QTUtil2.pregunta(self, _("Are you sure?")):
                    self.route.reset()
                else:
                    return
            elif resp == "k":
                self.route.change_measure()
            elif resp == "g":
                self.route.change_go_fast()
                return
            elif resp.startswith("l"):
                if QTUtil2.pregunta(
                        self,
                        _("Change level") + "\n" + _("Are you sure?")):
                    self.route.write_with_level()
                    n = int(resp[1])
                    self.route.set_level(n)
            self.reject()
            train_train(self.procesador)
示例#17
0
def nag2ico(nag, tam):
    with open(Code.path_resource("IntFiles", "NAGs", "Color", "nag_%d.svg" % nag), "rb") as f:
        dato = f.read()
        color = getattr(Code.configuration, "x_color_nag%d" % nag)
        dato = dato.replace(b"#3139ae", color.encode())
    return QTVarios.svg2ico(dato, tam)
    def __init__(self, owner, db_coordinates, coordinates):

        QTVarios.WDialogo.__init__(self, owner, _("Coordinates by blocks"),
                                   Iconos.Blocks(), "runcoordinatesblocks")

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

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

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

        font = Controles.TipoLetra(
            puntos=self.configuration.x_sizefont_infolabels)

        lb_block_k = Controles.LB(self, _("Block") + ":").ponFuente(font)
        self.lb_block = Controles.LB(self).ponFuente(font)

        lb_try_k = Controles.LB(self,
                                _("Tries in this block") + ":").ponFuente(font)
        self.lb_try = Controles.LB(self).ponFuente(font)

        lb_minimum_score_k = Controles.LB(self,
                                          _("Minimum score") +
                                          ":").ponFuente(font)
        self.lb_minimum_score = Controles.LB(self).ponFuente(font)

        lb_current_score_block_k = Controles.LB(self,
                                                _("Max score in block") +
                                                ":").ponFuente(font)
        self.lb_current_score_block = Controles.LB(self).ponFuente(font)
        self.lb_current_score_enough = Controles.LB(self).ponImagen(
            Iconos.pmCorrecto())
        self.lb_current_score_enough.hide()

        self.lb_active_score_k = Controles.LB(self,
                                              _("Active score") +
                                              ":").ponFuente(font)
        self.lb_active_score = Controles.LB(self).ponFuente(font)

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

        separacion = 20
        ly_info = Colocacion.G()
        ly_info.controld(lb_block_k, 0, 0).controld(self.lb_block, 0, 1)
        ly_info.filaVacia(1, separacion)
        ly_info.controld(lb_try_k, 2, 0).controld(self.lb_try, 2, 1)
        ly_info.filaVacia(3, separacion)
        ly_info.controld(lb_minimum_score_k, 4,
                         0).controld(self.lb_minimum_score, 4, 1)
        ly_info.filaVacia(5, separacion)
        ly_info.controld(lb_current_score_block_k, 6,
                         0).controld(self.lb_current_score_block, 6, 1)
        ly_info.filaVacia(7, separacion)
        ly_info.controld(self.lb_active_score_k, 8,
                         0).controld(self.lb_active_score, 8, 1)

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

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

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

        self.setLayout(ly_center)

        self.restore_video()
        self.show_data()
        self.adjustSize()
示例#19
0
    def __init__(self, owner, dicdatos):

        self.dicdatos = dicdatos

        site = dicdatos["SITE"]
        self.level = dicdatos["LEVEL"]
        self.intervalo = dicdatos["INTERVAL"]
        self.intervaloPorPieza = dicdatos["INTERVALPIECE"]
        self.esatacada = dicdatos["ISATTACKED"]
        self.esatacante = dicdatos["ISATTACKING"]
        self.position = dicdatos["POSITION"]
        self.color = dicdatos["COLOR"]
        self.errors = dicdatos["ERRORS"]
        self.time = dicdatos["TIME"]
        self.liFENs = dicdatos["FENS"]

        mas = "x" if self.intervaloPorPieza else ""
        titulo = '%s (%s%d")' % (site, mas, self.intervalo)

        super(WPlay, self).__init__(owner, titulo, Iconos.Gafas(), "visualplay")

        self.procesador = owner.procesador
        self.configuration = self.procesador.configuration

        # Tiempo en board
        intervaloMax = self.intervalo
        if self.intervaloPorPieza:
            intervaloMax *= 32

        # Board
        config_board = self.configuration.config_board("VISUALPLAY", 48)
        self.board = Board.Board(self, config_board)
        self.board.crea()

        lyT = Colocacion.V().control(self.board)

        self.gbBoard = Controles.GB(self, "", lyT)

        # entradas
        ly = Colocacion.G()

        self.posPosicion = None
        self.posColor = None
        self.posIsAttacked = None
        self.posIsAttacking = None

        lista = [_("Piece")]
        if self.position:
            lista.append(_("Position"))
        if self.color:
            lista.append(_("Square color"))
        if self.esatacada:
            lista.append(_("Is attacked?"))
        if self.esatacante:
            lista.append(_("Is attacking?"))
        self.liLB2 = []
        for col, eti in enumerate(lista):
            ly.control(Controles.LB(self, eti), 0, col + 1)
            lb2 = Controles.LB(self, eti)
            ly.control(lb2, 0, col + len(lista) + 2)
            self.liLB2.append(lb2)
        elementos = len(lista) + 1

        liComboPieces = []
        for c in "PNBRQKpnbrqk":
            liComboPieces.append(("", c, self.board.piezas.icono(c)))

        self.pmBien = Iconos.pmAceptarPeque()
        self.pmMal = Iconos.pmCancelarPeque()
        self.pmNada = Iconos.pmPuntoAmarillo()

        self.liBloques = []
        for x in range(32):
            row = x % 16 + 1
            colPos = elementos if x > 15 else 0

            unBloque = []
            self.liBloques.append(unBloque)

            # # Solucion
            lb = Controles.LB(self, "").ponImagen(self.pmNada)
            ly.control(lb, row, colPos)
            unBloque.append(lb)

            # # Piezas
            colPos += 1
            cb = Controles.CB(self, liComboPieces, "P")
            # cb.setStyleSheet("* { min-height:32px }")
            cb.setIconSize(QtCore.QSize(20, 20))

            ly.control(cb, row, colPos)
            unBloque.append(cb)

            if self.position:
                ec = Controles.ED(self, "").caracteres(2).controlrx("(|[a-h][1-8])").anchoFijo(24).align_center()
                colPos += 1
                ly.controlc(ec, row, colPos)
                unBloque.append(ec)

            if self.color:
                cl = QTVarios.TwoImages(Iconos.pmBlancas(), Iconos.pmNegras())
                colPos += 1
                ly.controlc(cl, row, colPos)
                unBloque.append(cl)

            if self.esatacada:
                isat = QTVarios.TwoImages(Iconos.pmAtacada().scaledToWidth(24), Iconos.pmPuntoNegro())
                colPos += 1
                ly.controlc(isat, row, colPos)
                unBloque.append(isat)

            if self.esatacante:
                at = QTVarios.TwoImages(Iconos.pmAtacante().scaledToWidth(24), Iconos.pmPuntoNegro())
                colPos += 1
                ly.controlc(at, row, colPos)
                unBloque.append(at)

        ly1 = Colocacion.H().otro(ly).relleno()
        ly2 = Colocacion.V().otro(ly1).relleno()
        self.gbSolucion = Controles.GB(self, "", ly2)

        f = Controles.TipoLetra("", 11, 80, False, False, False, None)

        bt = Controles.PB(self, _("Close"), self.terminar, plano=False).ponIcono(Iconos.MainMenu()).ponFuente(f)
        self.btBoard = Controles.PB(self, _("Go to board"), self.activaBoard, plano=False).ponIcono(Iconos.Board()).ponFuente(f)
        self.btComprueba = (
            Controles.PB(self, _("Test the solution"), self.compruebaSolucion, plano=False).ponIcono(Iconos.Check()).ponFuente(f)
        )
        self.btGotoNextLevel = (
            Controles.PB(self, _("Go to next level"), self.gotoNextLevel, plano=False).ponIcono(Iconos.GoToNext()).ponFuente(f)
        )
        ly0 = Colocacion.H().control(bt).relleno().control(self.btBoard).control(self.btComprueba).control(self.btGotoNextLevel)

        lyBase = Colocacion.H().control(self.gbBoard).control(self.gbSolucion)

        layout = Colocacion.V().otro(ly0).otro(lyBase)

        self.setLayout(layout)

        self.restore_video()

        self.gotoNextLevel()
    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).alinCentrado()
        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).alinCentrado()
        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).alinCentrado()
        lbTit = Controles.LB(route.mens_state()).ponTipoLetra(puntos=11, peso=200).alinCentrado()
        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).alinCentrado()
        lbTit = Controles.LB(texto).ponTipoLetra(puntos=11, peso=500).alinCentrado()
        self.set_style("White", color, lbTip, lbTit)
        lyTask = Colocacion.H().control(lbTip).control(lbTit)

        tb = QTVarios.LCTB(self, siTexto=True, tamIcon=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).alinCentrado().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)
示例#21
0
    def __init__(self, wParent):
        QtGui.QWidget.__init__(self, wParent)

        self.wParent = wParent

        self.jg = None
        self.partida = None

        puntos = VarGen.configuracion.puntosPGN

        f = Controles.TipoLetra(puntos=puntos, peso=75)
        # ftxt = Controles.TipoLetra( nombre="Courier New", puntos=puntos )
        f9 = Controles.TipoLetra(puntos=puntos)
        ftxt = f9

        # Apertura
        self.lbApertura = Controles.LB(self, "").ponFuente(f).alinCentrado().ponColorFondoN("#eeeeee", "#474d59").ponWrap()
        self.lbApertura.hide()

        # Valoracion
        liOpciones = [("-", "-")]
        dicNAGs = TrListas.dicNAGs()

        carpNAGs = "./IntFiles/NAGs"

        for x in dicNAGs:
            if x:
                fsvg = "%s/$%d.svg" % (carpNAGs, x)
                if os.path.isfile(fsvg):
                    liOpciones.append(("$%d : %s" % ( x, dicNAGs[x]), str(x), QTVarios.fsvg2ico(fsvg, 16)))
                else:
                    liOpciones.append(("$%d : %s" % ( x, dicNAGs[x]), str(x)))
        self.maxNAGs = 10
        self.liNAGs = []
        for x in range(self.maxNAGs):
            cb = Controles.CB(self, liOpciones, "").ponAnchoMinimo().capturaCambiado(self.valoracionCambiada).ponFuente(
                f9)
            if x:
                cb.hide()
            self.liNAGs.append(cb)

        liOpciones = [(x, x) for x in ("-", "!", "!!", "?", "??", "!?", "?!" )]
        self.valoracionDirecta = Controles.CB(self, liOpciones, "-").ponAnchoFijo(42).capturaCambiado(self.valoracionDirectaCambiada)

        lyH = Colocacion.H().control(self.valoracionDirecta).control(self.liNAGs[0])
        ly = Colocacion.V().otro(lyH)
        for x in range(1, self.maxNAGs):
            ly.control(self.liNAGs[x])

        self.gbValoracion = Controles.GB(self, _("Rating"), ly).ponFuente(f)

        # Comentarios
        self.comentario = Controles.EM(self, siHTML=False).capturaCambios(self.comentarioCambiado).ponFuente(
            ftxt).anchoMinimo(200)

        ly = Colocacion.H().control(self.comentario)
        self.gbComentario = Controles.GB(self, _("Comments"), ly).ponFuente(f)

        # Variantes
        liAcciones = (
            ( _("Append"), Iconos.Mas(), "tbMasVariante" ), None,
            ( "%s+%s" % (_("Append"), _("Engine")), Iconos.MasR(), "tbMasVarianteR" ), None,
            ( _("Edit"), Iconos.ComentarioEditar(), "tbEditarVariante" ), None,
            ( _("Remove"), Iconos.Borrar(), "tbBorrarVariante" ), None,
        )
        tbVariantes = Controles.TB(self, liAcciones, siTexto=False, tamIcon=16)

        self.variantes = Controles.EM(self, siHTML=False).capturaCambios(self.variantesCambiado).ponFuente(ftxt)
        self.variantes.capturaDobleClick(self.variantesDobleClick)

        ly = Colocacion.V().control(tbVariantes).control(self.variantes)
        self.gbVariantes = Controles.GB(self, _("Variants"), ly).ponFuente(f)

        layout = Colocacion.V()
        layout.control(self.lbApertura)
        layout.control(self.gbValoracion)
        layout.control(self.gbComentario)
        layout.control(self.gbVariantes)
        layout.margen(5)

        self.setLayout(layout)
    def __init__(self, procesador, txtcategoria, nivel, segundos, listaFen,
                 record):

        titulo = _("Check your memory on a chessboard")
        icono = Iconos.Memoria()
        extparam = "memoria"
        QTVarios.WDialogo.__init__(self, procesador.main_window, titulo, icono,
                                   extparam)

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

        self.configuration = procesador.configuration
        self.nivel = nivel
        self.segundos = segundos
        self.record = record

        # Board
        config_board = self.configuration.config_board("MEMORIA", 48)

        self.listaFen = listaFen

        self.position = Position.Position()

        self.board = Board.PosBoard(self, config_board)
        self.board.crea()
        self.board.ponDispatchDrop(self.dispatchDrop)
        self.board.baseCasillasSC.setAcceptDrops(True)
        self.ultimaPieza = "P"
        self.piezas = self.board.piezas

        tamPiezas = max(16,
                        int(32 * self.board.config_board.anchoPieza() / 48))
        self.listaPiezasW = QTVarios.ListaPiezas(self,
                                                 "P,N,B,R,Q,K",
                                                 self.board,
                                                 tamPiezas,
                                                 margen=0)
        self.listaPiezasB = QTVarios.ListaPiezas(self,
                                                 "p,n,b,r,q,k",
                                                 self.board,
                                                 tamPiezas,
                                                 margen=0)

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

        # Rotulos informacion
        lbCategoria = Controles.LB(self, txtcategoria).ponFuente(f)
        lbNivel = Controles.LB(self, _X(_("Level %1/%2"), str(nivel + 1),
                                        "25")).ponFuente(f)
        if record:
            lbRecord = Controles.LB(self,
                                    _X(_("Record %1 seconds"),
                                       str(record))).ponFuente(f)

        # Rotulo de vtime
        self.rotuloDispone = (Controles.LB(
            self,
            _X(
                _("You have %1 seconds to remember the position of %2 pieces"),
                str(self.segundos),
                str(self.nivel + 3),
            ),
        ).set_wrap().ponFuente(f).align_center())
        self.rotuloDispone1 = (Controles.LB(
            self, _("when you know you can press the Continue button")).
                               set_wrap().ponFuente(f).align_center())
        ly = Colocacion.V().control(self.rotuloDispone).control(
            self.rotuloDispone1)
        self.gbTiempo = Controles.GB(self, "", ly)

        self.rotuloDispone1.hide()

        # Tool bar
        li_acciones = (
            (_("Start"), Iconos.Empezar(), "empezar"),
            (_("Continue"), Iconos.Pelicula_Seguir(), "seguir"),
            (_("Check"), Iconos.Check(), "comprobar"),
            (_("Target"), Iconos.Verde32(), "objetivo"),
            (_("Wrong"), Iconos.Rojo32(), "nuestro"),
            (_("Repeat"), Iconos.Pelicula_Repetir(), "repetir"),
            (_("Resign"), Iconos.Abandonar(), "abandonar"),
        )
        self.tb = tb = Controles.TB(self, li_acciones)
        self.pon_toolbar(["empezar"])

        # Colocamos
        lyP = Colocacion.H().relleno().control(self.listaPiezasW).control(
            self.listaPiezasB).relleno().margen(0)
        lyT = Colocacion.V().control(self.board).otro(lyP).margen(0)

        lyI = Colocacion.V()
        lyI.control(tb)
        lyI.relleno()
        lyI.controlc(lbCategoria)
        lyI.controlc(lbNivel)
        if record:
            lyI.controlc(lbRecord)
        lyI.controlc(self.gbTiempo)
        lyI.relleno()
        lyI.control(self.gbAyuda)
        lyI.margen(3)

        ly = Colocacion.H().otro(lyT).otro(lyI).relleno()
        ly.margen(3)

        self.setLayout(ly)

        self.timer = None

        self.encenderExtras(False)
示例#23
0
 def lanza(self, procesador):
     menu = QTVarios.LCMenu(procesador.main_window)
     self.xmenu(menu)
     return menu.lanza()
示例#24
0
 def gmGuardar(self):
     pgn = self.pgnActual()
     if pgn:
         QTVarios.savePGN(self, pgn)
示例#25
0
    def __init__(self, procesador):

        icono = Iconos.ManualSave()
        extparam = "manualsave"
        titulo = _("Save positions to FNS/PGN")
        QTVarios.WDialogo.__init__(self, procesador.pantalla, titulo, icono, extparam)

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

        self.posicion = ControlPosicion.ControlPosicion()
        self.posicion.posInicial()

        self.gestor_motor = None
        self.pgn = None
        self.fns = None

        self.li_labels = [
            ["Site", ""],
            ["Event", ""],
            ["Date", ""],
            ["White", ""],
            ["Black", ""],
            ["WhiteElo", ""],
            ["BlackElo", ""],
            ["Result", ""],
        ]
        self.li_labels.extend([["", ""] for x in range(10)])

        self.li_analysis = []
        self.analyzing = False

        self.partida = None

        # Toolbar
        liAcciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar), None,
            (_("External engines"), Iconos.Motores(), self.ext_engines), None,
        )
        tb = Controles.TBrutina(self, liAcciones)

        # Board + botones + solucion + boton salvado
        ##
        bt_change_position = Controles.PB(self, "   " + _("Change position"), self.change_position, plano=False)
        bt_change_position.ponIcono(Iconos.Datos(), 24)
        ##
        conf_tablero = self.configuracion.confTablero("MANUALSAVE", 32)
        self.tablero = Tablero.Tablero(self, conf_tablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)
        ##
        lybt, bt = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24, siTiempo=False)
        ##
        self.em_solucion = Controles.EM(self, siHTML=False).altoMinimo(40).capturaCambios(self.reset_partida)
        ##
        self.bt_solucion = Controles.PB(self, "   " + _("Save solution"), self.savesolucion, plano=False).ponIcono(Iconos.Grabar(), 24)
        self.bt_editar = Controles.PB(self, "   " + _("Edit"), self.editar_solucion, plano=False).ponIcono(Iconos.PlayGame())
        ly = Colocacion.V().control(self.em_solucion).control(self.bt_editar)
        gb = Controles.GB(self, _("Solution"), ly)
        ###
        lybtp = Colocacion.H().control(bt_change_position).espacio(20).control(self.bt_solucion)
        lyT = Colocacion.V().otro(lybtp).control(self.tablero).otro(lybt).control(gb)
        gb_left = Controles.GB(self, "", lyT)

        # Ficheros PGN + FNS
        lb_pgn = Controles.LB(self, _("PGN") + ": ")
        self.bt_pgn = Controles.PB(self, "", self.pgn_select, plano=False).anchoMinimo(300)
        bt_no_pgn = Controles.PB(self, "", self.pgn_unselect).ponIcono(Iconos.Delete()).anchoFijo(16)
        lb_fns = Controles.LB(self, _("FNS") + ": ")
        self.bt_fns = Controles.PB(self, "", self.fns_select, plano=False).anchoMinimo(300)
        bt_no_fns = Controles.PB(self, "", self.fns_unselect).ponIcono(Iconos.Delete()).anchoFijo(16)
        ## Codec
        lb_codec = Controles.LB(self, _("Encoding") + ": ")
        liCodecs = [k for k in set(v for k, v in encodings.aliases.aliases.iteritems())]
        liCodecs.sort()
        liCodecs = [(k, k) for k in liCodecs]
        liCodecs.insert(0, ("%s: %s" % (_("By default"), _("UTF-8")), "default"))
        self.codec = "default"
        self.cb_codecs = Controles.CB(self, liCodecs, self.codec)
        ###
        ly0 = Colocacion.G().control(lb_pgn, 0, 0).control(self.bt_pgn, 0, 1).control(bt_no_pgn, 0, 2)
        ly0.control(lb_fns, 1, 0).control(self.bt_fns, 1, 1).control(bt_no_fns, 1, 2)
        ly1 = Colocacion.H().control(lb_codec).control(self.cb_codecs).relleno(1)
        ly = Colocacion.V().otro(ly0).otro(ly1)
        gb_files = Controles.GB(self, _("File to save"), ly)

        # Labels + correlativo
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("LABEL", _("Label"), 80, edicion=Delegados.LineaTextoUTF8(), siCentrado=True)
        oColumnas.nueva("VALUE", _("Value"), 280, edicion=Delegados.LineaTextoUTF8())
        self.grid_labels = Grid.Grid(self, oColumnas, siEditable=True, xid=1)
        n = self.grid_labels.anchoColumnas()
        self.grid_labels.setFixedWidth(n + 20)
        self.registrarGrid(self.grid_labels)

        ##
        lb_number = Controles.LB(self, _("Correlative number")+": ")
        self.sb_number = Controles.SB(self, 0, 0, 99999999).tamMaximo(50)
        lb_number_help = Controles.LB(self, _("Replace symbol # in Value column (#=3, ###=003)"))
        lb_number_help.setWordWrap(True)

        ly_number = Colocacion.H().control(lb_number).control(self.sb_number).control(lb_number_help, 4)

        ly = Colocacion.V().control(self.grid_labels).otro(ly_number)
        gb_labels = Controles.GB(self, _("PGN labels"), ly)

        # Analysis + grid + start/stop + multiPV
        self.bt_start = Controles.PB(self, "", self.start).ponIcono(Iconos.Pelicula_Seguir(), 32)
        self.bt_stop = Controles.PB(self, "", self.stop).ponIcono(Iconos.Pelicula_Pausa(), 32)
        self.bt_stop.hide()

        lb_engine = Controles.LB(self, _("Engine") + ":")
        liMotores = self.configuracion.comboMotoresCompleto()
        self.cb_engine = Controles.CB(self, liMotores, self.configuracion.tutor.clave).capturaCambiado(self.reset_motor)

        lb_multipv = Controles.LB(self, _("Multi PV")+": ")
        self.sb_multipv = Controles.SB(self, 1, 1, 500).tamMaximo(50)
        ##
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("PDT", _("Evaluation"), 100, siCentrado=True)
        oColumnas.nueva("PGN", _("Solution"), 360)
        self.grid_analysis = Grid.Grid(self, oColumnas, siSelecFilas=True)
        self.registrarGrid(self.grid_analysis)
        ##
        lb_analysis_help = Controles.LB(self, _("Double click to send analysis line to solution"))
        ###
        ly_lin1 = Colocacion.H().control(self.bt_start).control(self.bt_stop).control(lb_engine).control(self.cb_engine)
        ly_lin1.relleno(1).control(lb_multipv).control(self.sb_multipv)
        ly = Colocacion.V().otro(ly_lin1).control(self.grid_analysis).control(lb_analysis_help)
        gb_analysis = Controles.GB(self, _("Analysis"), ly)

        # ZONA
        splitter_right = QtGui.QSplitter(self)
        splitter_right.setOrientation(QtCore.Qt.Vertical)
        splitter_right.addWidget(gb_files)
        splitter_right.addWidget(gb_labels)
        splitter_right.addWidget(gb_analysis)

        self.registrarSplitter(splitter_right, "RIGHT")
        ##
        splitter = QtGui.QSplitter(self)
        splitter.addWidget(gb_left)
        splitter.addWidget(splitter_right)

        self.registrarSplitter(splitter, "ALL")

        layout = Colocacion.V().control(tb).control(splitter).margen(5)

        self.setLayout(layout)

        self.inicializa()
示例#26
0
    def __init__(self, procesador):

        self.procesador = procesador
        self.configuration = procesador.configuration

        self.siPlay = False
        self.wreload = False

        self.dbwashing = Washing.DBWashing(procesador.configuration)
        self.washing = self.dbwashing.washing
        eng = self.washing.last_engine(procesador.configuration)
        finished = eng is None

        owner = procesador.main_window
        titulo = _("The Washing Machine")
        extparam = "washing"
        icono = Iconos.WashingMachine()
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Toolbar
        tb = QTVarios.LCTB(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        tb.new(_("File"), Iconos.Recuperar(), self.file)
        if not finished:
            tb.new(_("Play"), Iconos.Play(), self.play)

        # Tab current
        ia = self.washing.index_average()

        c_create = "#f9e7e7"
        c_tactics = "#df8f87"
        c_reinit = "#8aa678"
        c_des = "#e4e4e4"
        c_hab = "#9dde67"
        c_act = "#dd2a2b"
        c_ia = "#cccdea"

        li_ia = ("#ffed00", "#ff8e00", "#29b41b", "#1174ff", "#bc01d9",
                 "#eb0000")
        d_ia = li_ia[int(eng.index() / (100.0 / 6.0)) % 6]
        state = eng.state
        wsvg = QtSvg.QSvgWidget()
        with open(Code.path_resource("IntFiles/Svg",
                                     "washing-machine.svg")) as f:
            svg = f.read()
            d_create = c_des
            d_tactics = c_des
            d_reinit = c_des
            ctac = ""
            if state == Washing.CREATING:
                d_create = c_act
            elif state == Washing.REPLAY:
                d_create = c_hab
                d_tactics = c_hab
                d_reinit = c_act
            elif state == Washing.TACTICS:
                d_create = c_hab
                d_tactics = c_act
                ctac = str(eng.numTactics())
            svg = svg.replace(c_create, d_create)
            svg = svg.replace(c_tactics, d_tactics)
            svg = svg.replace(c_reinit, d_reinit)
            svg = svg.replace("TAC", ctac)
            svg = svg.replace(c_ia, d_ia)
            wsvg.load(QtCore.QByteArray(svg.encode("utf-8")))
        p = 1.0
        wsvg.setFixedSize(287.79 * p, 398.83 * p)

        if finished:
            plant = '<tr><td align="right">%s:</td><td><b>%s</b></td></tr>'
            hints, times, games = self.washing.totals()
            nEngines = self.washing.num_engines()
            html = '<h2><center>%s: %d %s</center></h2><br><table cellpadding="4">' % (
                _("Finished"),
                nEngines,
                _("engines"),
            )
            for x in range(3):
                html += plant
            html += "</table>"

            html = html % (
                _("Hints"),
                "%d (%0.02f)" % (hints, hints * 1.0 / nEngines),
                _("Games"),
                "%d (%0.02f)" % (games, games * 1.0 / nEngines),
                _("Time"),
                "%s (%s)" %
                (Util.secs2str(times), Util.secs2str(int(times / nEngines))),
            )

        else:
            plant = '<tr><td align="right">%s:</td><td><b>%s</b></td></tr>'
            plantverde = '<tr><td align="right">%s:</td><td style="color:green;"><b>%s</b></td></tr>'
            html = '<h2><center>%s %d/%d</center></h2><br><table cellpadding="4">'
            for x in range(8):
                html += plantverde if x == 2 else plant
            html += "</table>"
            html = html % (
                _("Washing"),
                self.washing.num_engines(),
                self.washing.total_engines(procesador.configuration),
                _("Engine"),
                eng.name,
                _("Elo"),
                eng.elo,
                "<b>%s</b>" % _("Task"),
                eng.lbState(),
                _("Color"),
                _("White") if eng.color else _("Black"),
                _("Hints"),
                "%d/%d" % (eng.hints_current, eng.hints),
                _("Games"),
                eng.games,
                _("Time"),
                eng.lbTime(),
                _("Index"),
                eng.cindex(),
            )

        lbTxt = Controles.LB(self, html).ponTipoLetra(puntos=12)
        lbIdx = Controles.LB(self, "%0.2f%%" % ia).align_center().ponTipoLetra(
            puntos=36, peso=700)

        ly0 = Colocacion.V().control(wsvg).relleno(1)
        ly1 = Colocacion.V().espacio(20).control(lbTxt).espacio(20).control(
            lbIdx).relleno(1)
        ly2 = Colocacion.H().otro(ly0).otro(ly1)
        gbCurrent = Controles.GB(self, "", ly2)

        # Lista
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("STEP", _("Washing"), 50, centered=True)
        o_columns.nueva("ENGINE", _("Engine"), 170, centered=True)
        o_columns.nueva("ELO", _("Elo"), 50, centered=True)
        o_columns.nueva("COLOR", _("Color"), 70, centered=True)
        o_columns.nueva("STATE", _("State"), 90, centered=True)
        o_columns.nueva("HINTS", _("Hints"), 60, centered=True)
        o_columns.nueva("GAMES", _("Games"), 60, centered=True)
        o_columns.nueva("TIME", _("Time"), 60, centered=True)
        o_columns.nueva("DATE", _("Date"), 120, centered=True)
        o_columns.nueva("INDEX", _("Index"), 60, centered=True)

        self.grid = grid = Grid.Grid(self, o_columns, siSelecFilas=True)
        nAnchoPgn = self.grid.anchoColumnas() + 20
        self.grid.setMinimumWidth(nAnchoPgn)
        self.register_grid(grid)

        ly0 = Colocacion.V().control(self.grid)
        gbDatos = Controles.GB(self, "", ly0)

        self.tab = Controles.Tab()
        self.tab.nuevaTab(gbCurrent, _("Current"))
        self.tab.nuevaTab(gbDatos, _("Data"))

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

        self.restore_video(siTam=True, anchoDefecto=nAnchoPgn)
示例#27
0
    def file(self):
        menu = QTVarios.LCMenu(self)
        menu.opcion("saveas", _("Save a copy"), Iconos.GrabarComo())
        menu.separador()
        menu.opcion("restorefrom", _("Restore from"), Iconos.Recuperar())
        menu.separador()
        submenu = menu.submenu(_("Create new"), Iconos.Nuevo())
        submenu.opcion("new_UNED", _("UNED chess school"), Iconos.Uned())
        submenu.separador()
        submenu.opcion("new_UWE", _("Uwe Auerswald"), Iconos.Uwe())
        submenu.separador()
        submenu.opcion("new_SM", _("Singular moves"), Iconos.Singular())
        menu.separador()
        submenu = menu.submenu(_("Export to"), Iconos.DatabaseMas())
        submenu.opcion("save_pgn", _("A PGN file"), Iconos.FichPGN())
        submenu.separador()
        submenu.opcion("save_db", _("Database"), Iconos.Database())

        resp = menu.lanza()
        if resp is None:
            return
        if resp == "saveas":
            liGen = [(None, None)]
            config = FormLayout.Editbox(_("Name"), ancho=160)
            liGen.append((config, ""))

            resultado = FormLayout.fedit(liGen,
                                         title=_("Name"),
                                         parent=self,
                                         icon=Iconos.GrabarComo())
            if resultado:
                accion, liResp = resultado
                fich = name = liResp[0]
                if name.lower()[-4:] != ".wsm":
                    fich += ".wsm"
                path = os.path.join(self.configuration.carpeta_results, fich)
                ok = True
                if Util.exist_file(path):
                    ok = QTUtil2.pregunta(
                        self,
                        _X(
                            _("The file %1 already exists, what do you want to do?"
                              ), fich),
                        label_yes=_("Overwrite"),
                        label_no=_("Cancel"),
                    )
                if ok:
                    shutil.copy(self.dbwashing.file, path)
        elif resp == "restorefrom":
            li = []
            for fich in os.listdir(self.configuration.carpeta_results):
                if fich.endswith(".wsm") and fich != self.dbwashing.filename:
                    li.append(fich[:-4])
            if not li:
                QTUtil2.message_bold(self, _("There is no file"))
                return
            menu = QTVarios.LCMenu(self)
            for fich in li:
                menu.opcion(fich, fich, Iconos.PuntoRojo())
            resp = menu.lanza()
            if resp:
                if QTUtil2.pregunta(
                        self, "%s\n%s" %
                    (_("Current data will be removed and overwritten."),
                     _("Are you sure?"))):
                    shutil.copy(
                        os.path.join(self.configuration.carpeta_results,
                                     resp + ".wsm"), self.dbwashing.file)
                    self.wreload = True
                    self.save_video()
                    self.accept()
        elif resp.startswith("new_"):
            tactic = resp[4:]
            if QTUtil2.pregunta(
                    self, "%s\n%s" %
                (_("Current data will be removed and overwritten."),
                 _("Are you sure?"))):
                self.dbwashing.new(tactic)
                self.wreload = True
                self.save_video()
                self.accept()

        elif resp.startswith("save_"):

            def other_pc():
                for engine in self.washing.liEngines:
                    if engine.state == Washing.ENDED:
                        game = self.dbwashing.restoreGame(engine)
                        pc = Game.Game()
                        pc.assign_other_game(game)
                        dt = engine.date if engine.date else Util.today()
                        if engine.color:
                            white = self.configuration.x_player
                            black = engine.name
                            result = "1-0"
                            whiteelo = str(self.configuration.x_elo)
                            blackelo = engine.elo
                        else:
                            black = self.configuration.x_player
                            white = engine.name
                            result = "0-1"
                            blackelo = str(self.configuration.x_elo)
                            whiteelo = engine.elo
                        tags = [
                            ["Site", "Lucas Chess"],
                            ["Event", _("The Washing Machine")],
                            ["Date",
                             "%d-%d-%d" % (dt.year, dt.month, dt.day)],
                            ["White", white],
                            ["Black", black],
                            ["WhiteElo", whiteelo],
                            ["BlackElo", blackelo],
                            ["Result", result],
                        ]
                        ap = game.opening
                        if ap:
                            tags.append(["ECO", ap.eco])
                            tags.append(["Opening", ap.trNombre])
                        pc.set_tags(tags)
                        yield pc

            if resp == "save_db":
                ext = "lcg"
                path = QTUtil2.salvaFichero(
                    self,
                    _("Database of complete games"),
                    self.configuration.ficheroDBgames,
                    _("File") + " %s (*.%s)" % (ext, ext),
                    False,
                )
                if path:
                    if not path.lower().endswith(".lcdb"):
                        path += ".lcdb"
                    me = QTUtil2.mensEspera.start(self, _("Saving..."))
                    dbn = DBgames.DBgames(path)
                    for pc in other_pc():
                        dbn.insert(pc)
                    me.final()
                    QTUtil2.message_bold(self, _X(_("Saved to %1"), path))
            else:
                w = WindowSavePGN.WSaveVarios(self, self.configuration)
                if w.exec_():
                    ws = WindowSavePGN.FileSavePGN(self, w.dic_result)
                    if ws.open():
                        ws.um()
                        for n, pc in enumerate(other_pc()):
                            if n or not ws.is_new:
                                ws.write("\n\n")
                        ws.write(pc.pgn())
                    ws.close()
                    ws.um_final()
示例#28
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()
示例#29
0
def lanzaGUI(procesador):
    """
    Lanzador del interfaz grafico de la aplicacion.
    """

    # Comprobamos el lenguaje
    app = QtGui.QApplication([])

    liUsuarios = Usuarios.listaUsuarios()
    if liUsuarios:
        usuario = pideUsuario(liUsuarios)
        if usuario is None:
            return
        user = str(usuario.numero) if usuario.numero else ""
    else:
        user = ""

    activeFolder = Configuracion.activeFolder()
    siPedirLenguaje = not os.path.isdir(activeFolder) or not os.listdir(
        activeFolder)
    procesador.iniciaConUsuario(user)
    configuracion = procesador.configuracion

    # Comprobamos el lenguaje
    if siPedirLenguaje and not configuracion.traductor:
        if user:
            confMain = Configuracion.Configuracion("")
            ori = confMain.ficheroMExternos
            confMain.lee()
            confMain.limpia(usuario.nombre)
            confMain.ponCarpetas(user)
            confMain.graba()
            procesador.configuracion = confMain

            Util.copiaFichero(ori, confMain.carpeta)

        else:
            li = configuracion.listaTraducciones()
            menu = QTVarios.LCMenu(None)

            nico = QTVarios.rondoPuntos()
            for k, nombre, porc in li:
                rotulo = nombre
                if porc != "100":
                    rotulo += " (%s%%)" % porc
                menu.opcion(k, nombre, nico.otro())
            resp = menu.lanza()
            if resp:
                configuracion.traductor = resp
                configuracion.graba()

    # Estilo
    global stylename
    styleName = configuracion.estilo
    app.setStyle(QtGui.QStyleFactory.create(styleName))
    app.setPalette(QtGui.QApplication.style().standardPalette())
    app.setEffectEnabled(QtCore.Qt.UI_AnimateMenu)

    if configuracion.familia:
        font = Controles.TipoLetra(configuracion.familia)
        app.setFont(font)

    VarGen.gc = QTUtil.GarbageCollector()

    # Lanzamos la pantalla
    procesador.iniciarGUI()

    resp = app.exec_()
    Voice.runVoice.close()

    return resp
示例#30
0
    def __init__(self, owner, configuracion, bloqueApertura):
        icono = Iconos.Apertura()
        titulo = _("Select an opening")
        extparam = "selectOpening"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        # Variables--------------------------------------------------------------------------
        self.apStd = AperturasStd.ListaAperturasStd(configuracion, True, True)
        self.configuracion = configuracion
        self.partida = Partida.Partida()
        self.bloqueApertura = bloqueApertura
        self.liActivas = []

        # Tablero
        confTablero = configuracion.confTablero("APERTURAS", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponMensajero(self.mueveHumano)

        # Current pgn
        self.lbPGN = Controles.LB(self, "").ponWrap().ponTipoLetra(puntos=10, peso=75)
        ly = Colocacion.H().control(self.lbPGN)
        gbPGN = Controles.GB(self, _("Current opening"), ly)

        # Movimiento
        self.siMoviendoTiempo = False

        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self, "", siLibre=False, tamIcon=24)
        self.tbBM = tbBM

        # Tool bar
        tb = Controles.TBrutina(self)
        tb.new( _("Accept"), Iconos.Aceptar(), self.aceptar )
        tb.new( _("Cancel"), Iconos.Cancelar(), self.cancelar )
        tb.new( _("Reinit"), Iconos.Reiniciar(), self.resetPartida )
        tb.new( _("Takeback"), Iconos.Atras(), self.atras )
        tb.new( _("Remove"), Iconos.Borrar(), self.borrar )

        # Lista Aperturas
        oColumnas = Columnas.ListaColumnas()
        dicTipos = {"b": Iconos.pmEstrella(), "n": Iconos.pmPuntoAzul(), "l": Iconos.pmNaranja()}
        oColumnas.nueva("TIPO", "", 24, edicion=Delegados.PmIconosBMT(dicIconos=dicTipos))
        oColumnas.nueva("OPENING", _("Possible continuation"), 480)

        self.grid = Grid.Grid(self, oColumnas, siSelecFilas=True, altoFila=32)
        self.registrarGrid(self.grid)

        # # Derecha
        lyD = Colocacion.V().control(tb).control(self.grid)
        gbDerecha = Controles.GB(self, "", lyD)

        # # Izquierda
        lyI = Colocacion.V().control(self.tablero).otro(lyBM).control(gbPGN)
        gbIzquierda = Controles.GB(self, "", lyI)

        splitter = QtGui.QSplitter(self)
        splitter.addWidget(gbIzquierda)
        splitter.addWidget(gbDerecha)
        self.registrarSplitter(splitter, "splitter")

        ## Completo
        ly = Colocacion.H().control(splitter).margen(3)
        self.setLayout(ly)

        self.recuperarVideo(siTam=True)

        self.ponActivas()
        self.resetPartida()
        self.actualizaPosicion()
示例#31
0
    def __init__(self, winBookGuide, siMoves=True):
        QtGui.QWidget.__init__(self)

        self.siMoves = siMoves
        self.winBookGuide = winBookGuide
        if self.siMoves:
            self.tree = winBookGuide.wmoves.tree
        else:
            self.tree = None
        self.movActual = None

        confTablero = VarGen.configuracion.confTablero("INFOMOVEBOOKGUIDE", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)
        self.tablero.ponMensajero(self.mueveHumano)
        self.cpActual = ControlPosicion.ControlPosicion()
        self.historia = None
        self.posHistoria = None

        self.intervalo = 1400

        lybt, bt = QTVarios.lyBotonesMovimiento(self,
                                                "",
                                                siTiempo=True,
                                                siLibre=False,
                                                tamIcon=24)

        self.lbPGN = LBPGN("").anchoFijo(self.tablero.ancho).ponWrap()
        self.lbPGN.colocate = self.colocatePartida
        self.lbPGN.setStyleSheet(
            "QWidget { border-style: groove; border-width: 2px; border-color: LightSlateGray; padding: 8px;}"
        )
        self.lbPGN.ponTipoLetra(puntos=10)

        if siMoves:
            tree = winBookGuide.wmoves.tree
            # Valoracion
            liOpciones = [(tit[0], k, tit[1])
                          for k, tit in tree.dicValoracion.iteritems()]
            self.lbValoracion = Controles.LB(self, _("Rating") + ":")
            self.cbValoracion = Controles.CB(
                self, liOpciones, 0).capturaCambiado(self.cambiadoValoracion)

            # Ventaja
            liOpciones = [(tit, k, icon)
                          for k, (tit, icon) in tree.dicVentaja.iteritems()]
            self.lbVentaja = Controles.LB(self, _("Advantage") + ":")
            self.cbVentaja = Controles.CB(self, liOpciones, 0).capturaCambiado(
                self.cambiadoVentaja)

            # Comentario
            self.emComentario = Controles.EM(
                self, siHTML=False).capturaCambios(self.cambiadoComentario)

            lyVal = Colocacion.H().control(self.lbValoracion).control(
                self.cbValoracion).relleno()
            lyVen = Colocacion.H().control(self.lbVentaja).control(
                self.cbVentaja).relleno()
            lyEd = Colocacion.V().otro(lyVal).otro(lyVen).control(
                self.emComentario)
        else:
            self.lbOpening = Controles.LB(self).alinCentrado().ponWrap()
            self.lbOpening.ponTipoLetra(puntos=10, peso=200)
            lyO = Colocacion.H().relleno().control(self.lbOpening).relleno()

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

        lya = Colocacion.H().relleno().control(self.lbPGN).relleno()

        layout = Colocacion.V()
        layout.otro(lyt)
        layout.otro(lybt)
        if not siMoves:
            layout.otro(lyO)
        layout.otro(lya)
        if siMoves:
            layout.otro(lyEd)
        layout.relleno()
        self.setLayout(layout)

        self.usoNormal = True

        self.siReloj = False
示例#32
0
    def creaMenu(self):
        dicMenu = {}
        menu = QTVarios.LCMenu(self.parent)

        def xopcion(menu, clave, texto, icono, siDeshabilitado=False):
            menu.opcion(clave, texto, icono, siDeshabilitado)
            dicMenu[clave] = (clave, texto, icono, siDeshabilitado)

        # Posiciones de entrenamiento --------------------------------------------------------------------------
        self.menuFNS(menu, _("Training positions"), xopcion)
        menu.separador()

        # GM ---------------------------------------------------------------------------------------------------
        xopcion(menu, "gm", _("Play like a grandmaster"), Iconos.GranMaestro())
        menu.separador()

        # Mate --------------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Training mates"), Iconos.Mate())
        for mate in range(1, 5):
            xopcion(menu1, "mate%d" % mate, _X(_("Mate in %1"), str(mate)),
                    Iconos.PuntoAzul())
            menu1.separador()
        menu.separador()

        # BMT -------------------------------------------------------------------------------------------
        xopcion(menu, "bmt", _("Find best move"), Iconos.BMT())
        menu.separador()

        # Resistencia ------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Resistance Test"), Iconos.Resistencia())
        nico = Util.Rondo(Iconos.Verde(), Iconos.Azul(), Iconos.Amarillo(),
                          Iconos.Naranja())
        xopcion(menu1, "resistance", _("Normal"), nico.otro())
        xopcion(menu1, "resistancec", _("Blindfold chess"), nico.otro())
        xopcion(menu1, "resistancep1", _("Hide only our pieces"), nico.otro())
        xopcion(menu1, "resistancep2", _("Hide only opponent pieces"),
                nico.otro())
        menu.separador()

        # DailyTest ------------------------------------------------------------------------------------------------
        xopcion(menu, "dailytest", _("Your daily test"), Iconos.DailyTest())
        menu.separador()

        # Tacticas ---------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Learn tactics by repetition"),
                             Iconos.Tacticas())
        nico = Util.Rondo(Iconos.Amarillo(), Iconos.Naranja(), Iconos.Verde(),
                          Iconos.Azul(), Iconos.Magenta())
        dicTraining = TrListas.dicTraining()

        def trTraining(txt):
            return dicTraining.get(txt, txt)

        def menuTacticas(tipo, carpetaBase):
            lista = []
            if os.path.isdir(carpetaBase):
                li = Util.listdir(carpetaBase)
                for nombre in li:
                    carpeta = os.path.join(carpetaBase, nombre)
                    ini = os.path.join(carpeta, "Config.ini")
                    if os.path.isdir(carpeta) and os.path.isfile(ini):
                        xopcion(
                            menu1, "tactica|%s|%s|%s|%s" %
                            (tipo, nombre, carpeta, ini), trTraining(nombre),
                            nico.otro())
                        menu1.separador()
                        lista.append((carpeta, nombre))
            return lista

        menuTacticas("B", "Tactics")
        carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining,
                                        "Tactics")
        lista = menuTacticas("P", carpetaTacticasP)
        if lista:
            ico = Iconos.Delete()
            menub = menu1.submenu(_("Remove"), ico)
            for carpeta, nombre in lista:
                xopcion(menub, "remtactica|%s|%s" % (carpeta, nombre),
                        trTraining(nombre), ico)

        menu.separador()

        # Openings ------------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Openings"), Iconos.Aperturas())
        # # Aperturas --------------------------------------------------------------------------------------------
        xopcion(menu1, "aperturas", _("Learn openings by repetition"),
                Iconos.Apertura())
        menu1.separador()
        # Books ------------------------------------------------------------------------------------------------
        xopcion(menu1, "polyglot", _("Training with a book"), Iconos.Libros())

        # Ratings
        menu.separador()
        menu1 = menu.submenu(_("Training ratings"), Iconos.Elo())
        xopcion(menu1, "lucaselo",
                "%s (%d)" % (_("Lucas-Elo"), self.configuracion.eloNC),
                Iconos.Elo())
        menu1.separador()
        xopcion(menu1, "micelo",
                "%s (%d)" % (_("Tourney-Elo"), self.configuracion.micheloNC),
                Iconos.EloTimed())
        menu1.separador()
        fics = self.configuracion.ficsNC
        menuf = menu1.submenu("%s (%d)" % (_("Fics-Elo"), fics), Iconos.Fics())
        rp = QTVarios.rondoPuntos()
        for elo in range(900, 2800, 100):
            if (elo == 900) or (0 <= (elo + 99 - fics) <= 400 or 0 <=
                                (fics - elo) <= 400):
                xopcion(menuf, "fics%d" % (elo / 100, ),
                        "%d-%d" % (elo, elo + 99), rp.otro())
        menu1.separador()
        fide = self.configuracion.fideNC
        menuf = menu1.submenu("%s (%d)" % (_("Fide-Elo"), fide), Iconos.Fide())
        rp = QTVarios.rondoPuntos()
        for elo in range(1500, 2700, 100):
            if (elo == 1500) or (0 <= (elo + 99 - fide) <= 400 or 0 <=
                                 (fide - elo) <= 400):
                xopcion(menuf, "fide%d" % (elo / 100, ),
                        "%d-%d" % (elo, elo + 99), rp.otro())

        menu.separador()

        # Longs ----------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Long-term trainings"), Iconos.Longhaul())
        # Maps
        menu2 = menu1.submenu(_("Training on a map"), Iconos.Maps())
        xopcion(menu2, "map_Africa", _("Africa map"), Iconos.Africa())
        menu2.separador()
        xopcion(menu2, "map_WorldMap", _("World map"), Iconos.WorldMap())
        # Rail
        menu1.separador()
        xopcion(menu1, "transsiberian", _("Transsiberian Railway"),
                Iconos.Train())
        # Everest
        menu1.separador()
        xopcion(menu1, "everest", _("Expeditions to the Everest"),
                Iconos.Trekking())
        # TOL
        menu1.separador()
        menu2 = menu1.submenu(_("Turn on the lights"), Iconos.TOL())
        xopcion(menu2, "tol_uned", _("UNED chess school"), Iconos.Uned())
        menu2.separador()
        xopcion(menu2, "tol_uwe", _("Uwe Auerswald"), Iconos.Uwe())
        # Washing
        menu1.separador()
        xopcion(menu1, "washing_machine", _("The Washing Machine"),
                Iconos.WashingMachine())

        # Cebras ---------------------------------------------------------------------------------------------------
        menu.separador()
        menu1 = menu.submenu(_("Resources for zebras"), Iconos.Cebra())
        menu2 = menu1.submenu(_("Check your memory on a chessboard"),
                              Iconos.Memoria())
        rival = self.configuracion.rival

        mem = Memoria.Memoria(self.procesador)

        for x in range(6):
            cat = rival.categorias.numero(x)
            txt = cat.nombre()

            nm = mem.nivel(x)
            if nm > -1:
                txt += " %s %d" % (_("Level"), nm + 1)

            xopcion(menu2,
                    -100 - x,
                    txt,
                    cat.icono(),
                    siDeshabilitado=not mem.siActiva(x))

        menu1.separador()

        menu2 = menu1.submenu(_("Find all moves"), Iconos.J60())
        xopcion(menu2, "j60_rival", _("Opponent"), Iconos.PuntoNaranja())
        xopcion(menu2, "j60_jugador", _("Player"), Iconos.PuntoAzul())

        menu1.separador()
        self.horsesDef = hd = {
            1: ("N", "Alpha", _("Basic test")),
            2: ("p", "Fantasy", _("Four pawns test")),
            3: ("Q", "Pirat", _("Jonathan Levitt test")),
            4: ("n", "Spatial", _("Basic test") + ": a1"),
            5: ("N", "Cburnett", _("Basic test") + ": e4")
        }
        menu2 = menu1.submenu(_("Becoming a knight tamer"),
                              self.procesador.tablero.piezas.icono("N"))
        vicon = VarGen.todasPiezas.icono
        icl, icn, tit = hd[1]
        menu3 = menu2.submenu(tit, vicon(icl, icn))
        xopcion(menu3, "horses_1", tit, vicon(icl, icn))
        menu3.separador()
        icl, icn, tit = hd[4]
        xopcion(menu3, "horses_4", tit, vicon(icl, icn))
        menu3.separador()
        icl, icn, tit = hd[5]
        xopcion(menu3, "horses_5", tit, vicon(icl, icn))
        menu2.separador()
        icl, icn, tit = hd[2]
        xopcion(menu2, "horses_2", tit, vicon(icl, icn))
        menu2.separador()
        icl, icn, tit = hd[3]
        xopcion(menu2, "horses_3", tit, vicon(icl, icn))

        menu1.separador()
        menu2 = menu1.submenu(_("Moves between two positions"),
                              Iconos.Puente())
        rp = QTVarios.rondoPuntos()
        for x in range(1, 11):
            xopcion(menu2, "puente_%d" % x, "%s %d" % (_("Level"), x),
                    rp.otro())

        menu1.separador()
        xopcion(menu1, "potencia", _("Determine your calculating power"),
                Iconos.Potencia())

        menu1.separador()
        menu2 = menu1.submenu(_("Learn a game"), Iconos.School())
        xopcion(menu2, "learnPGN", _("Memorizing their moves"),
                Iconos.LearnGame())
        menu2.separador()
        xopcion(menu2, "playPGN", _("Playing against"), Iconos.Law())

        menu1.separador()
        xopcion(menu1, "visualiza", _("The board at a glance"), Iconos.Gafas())

        # menu2 = menu1.submenu(_("Endings with 3/4 pieces"), Iconos.Puente())
        # xopcion(menu2, "end_t4-1", "%s %d"%(_("Level"), 1), Iconos.PuntoAzul())
        # xopcion(menu2, "end_t4-2", "%s %d"%(_("Level"), 2), Iconos.PuntoMagenta())

        return menu, dicMenu
示例#33
0
def nag2ico(nag, tam):
    with open("./IntFiles/NAGs/Color/nag_%d.svg" % nag) as f:
        dato = f.read()
        color = getattr(VarGen.configuracion, "color_nag%d" % nag)
        dato = dato.replace("#3139ae", color)
    return QTVarios.svg2ico(dato, tam)
    def menu(self):
        pantalla = self.procesador.pantalla
        pantalla.cursorFueraTablero()
        menu = QTVarios.LCMenu(pantalla)
        f = Controles.TipoLetra(nombre="Courier New", puntos=10)
        fbold = Controles.TipoLetra(nombre="Courier New", puntos=10, peso=700)
        fbolds = Controles.TipoLetra(nombre="Courier New",
                                     puntos=10,
                                     peso=500,
                                     siSubrayado=True)
        menu.ponFuente(f)

        li_results = self.lee_results()
        icono = Iconos.PuntoAzul()

        menu.separador()
        titulo = ("** %s **" % _("Challenge 101")).center(30)
        if self.pendientes == 0:
            menu.opcion("close", titulo, Iconos.Terminar())
        else:
            menu.opcion("continuar", titulo, Iconos.Pelicula_Seguir())
        menu.separador()
        ok_en_lista = False
        for n, (fecha, pts) in enumerate(li_results, 1):
            if fecha == self.key:
                ok_en_lista = True
                ico = Iconos.PuntoEstrella()
                tipoLetra = fbolds
            else:
                ico = icono
                tipoLetra = None
            txt = str(fecha)[:16]
            menu.opcion(None,
                        "%2d. %-20s %6d" % (n, txt, pts),
                        ico,
                        tipoLetra=tipoLetra)

        menu.separador()
        menu.opcion(None, "")
        menu.separador()
        if self.puntos_ultimo:
            menu.opcion(None, ("+%d" % (self.puntos_ultimo)).center(30),
                        tipoLetra=fbold)
        if self.pendientes == 0:
            if not ok_en_lista:
                menu.opcion(None,
                            ("%s: %d" %
                             (_("Score"), self.puntos_totales)).center(30),
                            tipoLetra=fbold)
            menu.separador()
            menu.opcion("close", _("GAME OVER").center(30), Iconos.Terminar())
        else:
            menu.opcion(None, ("%s: %d" %
                               (_("Score"), self.puntos_totales)).center(30),
                        tipoLetra=fbold)
            menu.separador()
            menu.opcion(None,
                        ("%s: %d" %
                         (_("Positions left"), self.pendientes)).center(30),
                        tipoLetra=fbold)
            menu.separador()
            menu.opcion(None, "")
            menu.separador()
            menu.opcion("continuar", _("Continue"), Iconos.Pelicula_Seguir())
            menu.separador()
            menu.opcion("close", _("Close"), Iconos.MainMenu())

        resp = menu.lanza()

        return not (resp == "close" or self.pendientes == 0)
示例#35
0
    def __init__(self,
                 gestor,
                 xmotor,
                 nombreOP,
                 posicion,
                 mrm,
                 rmOP,
                 rmUsu,
                 analisis,
                 siCompetitivo=None):
        self.siCompetitivo = gestor.siCompetitivo if siCompetitivo is None else siCompetitivo
        self.nombreOP = nombreOP
        self.posicion = posicion
        self.rmOP = rmOP
        self.rmUsu = rmUsu
        self.mrm = mrm
        self.analisis = analisis
        self.siAnalisisCambiado = False
        self.xmotor = xmotor
        self.gestor = gestor

        self.listaRM, self.posOP = self.hazListaRM()
        self.posicion = posicion

        titulo = _("Analysis")
        icono = Iconos.Analizar()
        extparam = "jzgm"
        super().__init__(parent=gestor.pantalla,
                         titulo=titulo,
                         icono=icono,
                         extparam=extparam)

        self.colorNegativo = QTUtil.qtColorRGB(255, 0, 0)
        self.colorImpares = QTUtil.qtColorRGB(231, 244, 254)

        self.lbComentario = Controles.LB(
            self, "").ponTipoLetra(puntos=10).alinCentrado()

        confTablero = gestor.configuracion.confTablero("JUICIO", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(posicion.siBlancas)

        self.lbMotor = Controles.LB(self).alinCentrado()
        self.lbTiempo = Controles.LB(self).alinCentrado()

        liMas = ((_("Close"), "close", Iconos.AceptarPeque()), )
        lyBM, tbBM = QTVarios.lyBotonesMovimiento(self,
                                                  "",
                                                  siLibre=False,
                                                  tamIcon=24,
                                                  siMas=gestor.continueTt,
                                                  liMasAcciones=liMas)

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("POSREAL", "#", 40, siCentrado=True)
        oColumnas.nueva("JUGADAS",
                        "%d %s" % (len(self.listaRM), _("Moves")),
                        120,
                        siCentrado=True)
        oColumnas.nueva("PLAYER", _("Player"), 120)

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

        lyT = Colocacion.V().control(self.tablero).otro(lyBM).control(
            self.lbComentario)

        # Layout
        layout = Colocacion.H().otro(lyT).control(self.grid)

        self.setLayout(layout)

        self.grid.setFocus()

        self.grid.goto(self.posOP, 0)
        self.siMoviendoTiempo = False

        self.ponPuntos()
示例#36
0
def run_gui(procesador):
    app = QtWidgets.QApplication([])

    # Usuarios
    list_users = Usuarios.Usuarios().list_users
    if len(list_users) > 1:
        main_config = Configuration.Configuration("")
        main_config.releeTRA()

        user = pide_usuario(list_users)
        if user == list_users[0]:
            user = None
    else:
        user = None

    procesador.start_with_user(user)
    configuration = procesador.configuration
    if user:
        if not configuration.x_player:
            configuration.x_player = user.name
            configuration.graba()
        elif configuration.x_player != user.name:
            for usu in list_users:
                if usu.number == user.number:
                    usu.name = configuration.x_player
                    Usuarios.Usuarios().save_list(list_users)

    # Comprobamos el lenguaje
    if not configuration.x_translator:
        if user:
            conf_main = Configuration.Configuration("")
            configuration.x_translator = conf_main.x_translator
            configuration.start()
            configuration.limpia(user.name)
            configuration.set_folders()
            configuration.graba()

        else:
            li = configuration.list_translations()

            li_info = locale.getdefaultlocale()
            lng_default = "en"
            name_default = "English"
            if len(li_info) == 2:
                lng = li_info[0][:2]
                for k, name, porc, author in li:
                    if k == lng:
                        name_default = name
                        lng_default = lng

            menu = QTVarios.LCMenuRondo(None)
            menu.opcion(None, "Select your language", icono=Iconos.Book())
            menu.separador()
            menu.opcion(lng_default,
                        "By default: %s" % name_default,
                        icono=Iconos.AceptarPeque())
            menu.separador()

            font_metrics = QtGui.QFontMetrics(menu.font())
            space_width = font_metrics.width(" ")

            mx = 0
            d_with = {}
            for k, name, porc, author in li:
                if porc < 95:
                    name += " (%d%%)" % porc
                name_with = font_metrics.width(name)
                d_with[k] = name, name_with
                if name_with > mx:
                    mx = name_with
            mx += space_width * 2

            for k, name, porc, author in li:
                name, name_with = d_with[k]
                resto = mx - name_with
                name += " " * (resto // space_width) + "by %s" % author
                if k == lng_default:
                    menu.opcion(k, name, icono=Iconos.AceptarPeque())
                else:
                    menu.opcion(k, name)
            menu.separador()
            resp = menu.lanza()
            if resp:
                lng = resp
            else:
                lng = lng_default
            configuration.set_translator(lng)
            configuration.graba()
            configuration.releeTRA()

    # Estilo
    # https://github.com/gmarull/qtmodern/blob/master/qtmodern/styles.py
    # https://stackoverflow.com/questions/15035767/is-the-qt-5-dark-fusion-theme-available-for-windows
    # darkPalette.setColor(QPalette.Window, QColor(53, 53, 53))
    # darkPalette.setColor(QPalette.WindowText, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.Base, QColor(42, 42, 42))
    # darkPalette.setColor(QPalette.Text, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
    # darkPalette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53))
    # darkPalette.setColor(QPalette.ToolTipText, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.Button, QColor(53, 53, 53))
    # darkPalette.setColor(QPalette.ButtonText, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.BrightText, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.Link, QColor(56, 252, 196))
    #
    # darkPalette.setColor(QPalette.Light, QColor(180, 180, 180))
    # darkPalette.setColor(QPalette.Midlight, QColor(90, 90, 90))
    # darkPalette.setColor(QPalette.Dark, QColor(35, 35, 35))
    # darkPalette.setColor(QPalette.Shadow, QColor(20, 20, 20))
    # darkPalette.setColor(QPalette.Highlight, QColor(42, 130, 218))
    # darkPalette.setColor(QPalette.HighlightedText, QColor(180, 180, 180))
    #
    # # disabled
    # darkPalette.setColor(QPalette.Disabled, QPalette.WindowText,
    #                      QColor(127, 127, 127))
    # darkPalette.setColor(QPalette.Disabled, QPalette.Text,
    #                      QColor(127, 127, 127))
    # darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText,
    #                      QColor(127, 127, 127))
    # darkPalette.setColor(QPalette.Disabled, QPalette.Highlight,
    #                      QColor(80, 80, 80))
    # darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText,
    #                      QColor(127, 127, 127))
    app.setStyle(QtWidgets.QStyleFactory.create(configuration.x_style))

    if configuration.palette:
        qpalette = QtGui.QPalette()
        palette = configuration.palette
        # palette = palette_dark = {'Window': '#353535', 'WindowText': '#b4b4b4', 'Base': '#2a2a2a', 'Text': '#b4b4b4', 'AlternateBase': '#424242',
        #  'ToolTipBase': '#353535', 'ToolTipText': '#b4b4b4', 'Button': '#353535', 'ButtonText': '#b4b4b4', 'BrightText': '#b4b4b4',
        #  'Link': '#38fcc4'}

        for key, tp in (
            (QtGui.QPalette.Window, "Window"),
            (QtGui.QPalette.WindowText, "WindowText"),
            (QtGui.QPalette.Base, "Base"),
            (QtGui.QPalette.Text, "Text"),
            (QtGui.QPalette.AlternateBase, "AlternateBase"),
            (QtGui.QPalette.ToolTipBase, "ToolTipBase"),
            (QtGui.QPalette.ToolTipText, "ToolTipText"),
            (QtGui.QPalette.Button, "Button"),
            (QtGui.QPalette.ButtonText, "ButtonText"),
            (QtGui.QPalette.BrightText, "BrightText"),
            (QtGui.QPalette.Link, "Link"),
        ):
            qpalette.setColor(key, QtGui.QColor(palette[tp]))
    else:
        qpalette = QtWidgets.QApplication.style().standardPalette()

    app.setPalette(qpalette)

    app.setEffectEnabled(QtCore.Qt.UI_AnimateMenu)

    QtGui.QFontDatabase.addApplicationFont(
        Code.path_resource("IntFiles", "ChessAlpha2.ttf"))

    if configuration.x_font_family:
        font = Controles.TipoLetra(configuration.x_font_family)
        app.setFont(font)

    Code.gc = QTUtil.GarbageCollector()

    procesador.iniciar_gui()

    resp = app.exec_()

    return resp
示例#37
0
    def __init__(self, mAnalisis, ventana, siBlancas, siLibre, siGrabar, muestraInicial):
        titulo = _("Analysis")
        icono = Iconos.Tutor()
        extparam = "analysis"

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

        self.mAnalisis = mAnalisis
        self.muestraActual = None

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.recuperarVideo(siTam=False)
        self.show()
        wm.cambiadoRM(muestraInicial.posElegida)
        self.activaMuestra(muestraInicial)
示例#38
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,
            (_("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=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()
示例#39
0
    def __init__(self, boardOriginal):
        main_window = boardOriginal.parent()
        titulo = _("Colors")
        icono = Iconos.EditarColores()
        extparam = "WColores"
        QTVarios.WDialogo.__init__(self, main_window, titulo, icono, extparam)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        ly_otros = Colocacion.G()
        # _nomPiezas
        li = []
        lbPiezas = crea_lb(_("Pieces"))
        for entry in Util.listdir(Code.path_resource("Pieces")):
            if entry.is_dir():
                li.append((entry.name, entry.name))
        li.sort(key=lambda x: x[0])
        self.cbPiezas = Controles.CB(self, li, self.config_board.nomPiezas()).capture_changes(self.actualizaBoardM)
        self.chbDefPiezas = xDefecto(self.config_board.siDefPiezas())
        l2mas1(ly_otros, 0, lbPiezas, self.cbPiezas, self.chbDefPiezas)

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

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

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

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

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

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

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

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

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

        self.setLayout(ly)

        self.elegido = None

        self.li_themes = self.read_own_themes()
        self.current_theme = {"NOMBRE": "", "SECCION": "", "CHANGE_PIECES": True, "o_tema": self.config_board.grabaTema(), "o_base": self.config_board.grabaBase()}
        self.own_theme_selected = False
        self.cambiadoTema()
        self.defectoTemas()

        self.extendedColor()

        self.siActualizando = False

        self.restore_video(siTam=False)
示例#40
0
def nag2ico( nag, tam ):
    with open("IntFiles/NAGs/Color/nag_%d.svg"%nag) as f:
        dato = f.read()
        color = getattr(VarGen.configuracion,"color_nag%d"%nag)
        dato = dato.replace("#3139ae",color)
    return QTVarios.svg2ico(dato,tam)
示例#41
0
def iconoTema(tema, tam):
    svg = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1"
   width="388pt"
   height="388pt"
   viewBox="0 0 388 388"
   id="svg2">
  <metadata
     id="metadata117">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <defs
     id="defs115" />
  <g
     id="layer3"
     style="display:inline">
    <rect
       width="486.81006"
       height="486.81006"
       x="0"
       y="-0.35689625"
       transform="scale(0.8,0.8)"
       id="rect4020"
       style="fill:FONDO;fill-opacity:1;fill-rule:nonzero;stroke:none" />
  </g>
  <g
     id="layer1"
     style="display:inline">
    <rect
       width="316.67606"
       height="317.12463"
       ry="0"
       x="35.708782"
       y="34.520344"
       id="rect3095"
       style="fill:WHITE;stroke:RECUADRO;stroke-width:4.54554987;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
  </g>
  <g
     id="layer2"
     style="display:inline">
    <rect
       width="38.841644"
       height="39.047188"
       x="154.92021"
       y="36.90279"
       id="rect3104"
       style="fill:BLACK;fill-opacity:1;stroke:BLACK;stroke-width:0.16;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
    <use
       transform="translate(-78.883927,0)"
       id="use3887"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-118.64494,118.02342)"
       id="use3889"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-39.492576,196.10726)"
       id="use3891"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-118.64494,274.01176)"
       id="use3893"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(78.161342,3.0019919e-8)"
       id="use3903"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(156.08573,78.779427)"
       id="use3905"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-118.64494,196.10726)"
       id="use3907"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(38.395272,274.01176)"
       id="use3909"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(156.08573,3.0019984e-8)"
       id="use3919"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(0,78.779427)"
       id="use3921"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-78.883927,156.79797)"
       id="use3923"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-39.492576,274.01176)"
       id="use3925"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-118.64494,39.217809)"
       id="use3935"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(78.161342,78.779427)"
       id="use3937"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(0,156.79797)"
       id="use3939"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(0,235.54546)"
       id="use3941"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-39.492576,39.217809)"
       id="use3951"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-39.492576,118.02342)"
       id="use3953"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(38.395272,196.10726)"
       id="use3955"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(78.161342,235.54546)"
       id="use3957"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(38.395272,39.217809)"
       id="use3967"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(38.395272,118.02342)"
       id="use3969"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(78.161342,156.79797)"
       id="use3971"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(156.08573,235.54546)"
       id="use3973"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(116.52539,39.217809)"
       id="use3983"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(116.52539,118.02342)"
       id="use3985"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(116.52539,196.10726)"
       id="use3987"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(116.52539,274.01176)"
       id="use3989"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-78.883927,78.779427)"
       id="use3999"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(156.08573,156.79797)"
       id="use4001"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
    <use
       transform="translate(-78.883927,235.54546)"
       id="use4003"
       x="0"
       y="0"
       width="388"
       height="388"
       xlink:href="#rect3104" />
  </g>
</svg>
"""

    confTema = ConfBoards.ConfigTabTema()
    confTema.restore_dic(tema["o_tema"])

    thumbail = confTema.x_png64Thumb
    if thumbail:
        pm = QtGui.QPixmap()
        png = base64.b64decode(thumbail)
        pm.loadFromData(png)
        icono = QtGui.QIcon(pm)
        return icono

    def ccolor(ncolor):
        x = QtGui.QColor(ncolor)
        return x.name()

    svg = svg.replace("WHITE", ccolor(confTema.x_colorBlancas))
    svg = svg.replace("BLACK", ccolor(confTema.x_colorNegras))
    svg = svg.replace("FONDO", ccolor(confTema.x_colorExterior))
    svg = svg.replace("RECUADRO", ccolor(confTema.x_colorFrontera))

    return QTVarios.svg2ico(svg.encode("utf-8"), tam)
示例#42
0
    def __init__(self, winBookGuide, siMoves=True):
        QtGui.QWidget.__init__(self)

        self.siMoves = siMoves
        self.winBookGuide = winBookGuide
        if self.siMoves:
            self.tree = winBookGuide.wmoves.tree
        else:
            self.tree = None
        self.movActual = None

        confTablero = VarGen.configuracion.confTablero("INFOMOVEBOOKGUIDE", 32)
        self.tablero = Tablero.Tablero(self, confTablero)
        self.tablero.crea()
        self.tablero.ponerPiezasAbajo(True)
        self.tablero.ponMensajero(self.mueveHumano)
        self.cpActual = ControlPosicion.ControlPosicion()
        self.historia = None
        self.posHistoria = None

        self.intervalo = 1400

        lybt, bt = QTVarios.lyBotonesMovimiento(self, "", siTiempo=True, siLibre=False, tamIcon=24)

        self.lbPGN = LBPGN("").anchoFijo(self.tablero.ancho).ponWrap()
        self.lbPGN.colocate = self.colocatePartida

        if siMoves:
            tree = winBookGuide.wmoves.tree
            # Valoracion
            liOpciones = [( tit[0], k, tit[1] ) for k, tit in tree.dicValoracion.iteritems()]
            self.lbValoracion = Controles.LB(self, _("Rating") + ":")
            self.cbValoracion = Controles.CB(self, liOpciones, 0).capturaCambiado(self.cambiadoValoracion)

            # Ventaja
            liOpciones = [( tit, k, icon ) for k, (tit, icon) in tree.dicVentaja.iteritems()]
            self.lbVentaja = Controles.LB(self, _("Advantage") + ":")
            self.cbVentaja = Controles.CB(self, liOpciones, 0).capturaCambiado(self.cambiadoVentaja)

            # Comentario
            self.emComentario = Controles.EM(self, siHTML=False).capturaCambios(self.cambiadoComentario)

            lyVal = Colocacion.H().control(self.lbValoracion).control(self.cbValoracion).relleno()
            lyVen = Colocacion.H().control(self.lbVentaja).control(self.cbVentaja).relleno()
            lyEd = Colocacion.V().otro(lyVal).otro(lyVen).control(self.emComentario)

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

        lya = Colocacion.H().relleno().control(self.lbPGN).relleno()

        layout = Colocacion.V()
        layout.otro(lyt)
        layout.otro(lybt)
        layout.otro(lya)
        if siMoves:
            layout.otro(lyEd)
        layout.relleno()
        self.setLayout(layout)

        self.usoNormal = True

        self.siReloj = False
示例#43
0
    def tools(self):
        menu = QTVarios.LCMenu(self.pantalla)

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

        menu1 = menu.submenu(_("PGN viewer"), Iconos.PGN())
        menu1.opcion("pgn_paste", _("Paste PGN"), Iconos.Pegar())
        menu1.separador()
        menu1.opcion("pgn_fichero", _("Read PGN"), Iconos.Fichero())
        menu1.separador()
        menu1.opcion("pgn_jugadadia", _("Game of the day"), Iconos.LM())
        menu1.separador()
        if self.configuracion.liTrasteros:
            menu1.opcion("pgn_trasteros", _("Boxrooms PGN"), Iconos.Trasteros())
            menu1.separador()
        if self.configuracion.salvarFichero and Util.existeFichero(self.configuracion.salvarFichero):
            menu1.opcion("pgn_nuestroFichero", _("My games"), Iconos.NuestroFichero())
        menu.separador()

        menu1 = menu.submenu(_("Database"), Iconos.Database())
        menu1.opcion("database", _("Complete games"), Iconos.DatabaseC())
        menu1.separador()
        menu1.opcion("databaseFEN", _("Positions"), Iconos.DatabaseF()) # TODO
        menu.separador()

        menu.opcion("manual_save", _("Save positions to FNS/PGN"), Iconos.ManualSave())
        menu.separador()

        menu1 = menu.submenu(_("Openings"), Iconos.Aperturas())
        menu1.opcion("aperturaspers", _("Custom openings"), Iconos.Apertura())
        menu1.separador()
        menu1.opcion("bookguide", _("Personal Opening Guide"), Iconos.BookGuide())
        menu.separador()
        menu.separador()

        menu1 = menu.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())
        menu.separador()

        resp = menu.lanza()
        if resp:
            if resp.startswith("pgn_"):
                self.visorPGN(resp)

            elif resp == "juega_solo":
                self.jugarSolo()

            elif resp == "torneos":
                self.torneos()
            elif resp == "motores":
                self.motoresExternos()
            elif resp == "sts":
                self.sts()
            elif resp == "kibitzers":
                self.kibitzers()

            elif resp == "manual_save":
                self.manual_save()

            elif resp == "database":
                self.database()

            elif resp == "databaseFEN":
                self.databaseFEN()

            elif resp == "aperturaspers":
                self.aperturaspers()
            elif resp == "bookguide":
                w = WOpeningGuide.WOpeningGuide(self.pantalla, self)
                w.exec_()
示例#44
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.main_window, titulo, icono,
                                   extparam)

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

        lb = Controles.LB(self, tipo)
        lb.set_background(background).align_center().ponTipoLetra(puntos=14)

        # Toolbar
        tb = QTVarios.LCTB(self)
        tb.new(_("Close"), Iconos.MainMenu(), self.terminar)
        anterior, siguiente, terminado = 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)
        if terminado:
            tb.new(_("Rebuild"), Iconos.Reindexar(), self.rebuild)

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

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

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

        self.grid = grid = Grid.Grid(self,
                                     o_columns,
                                     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.register_grid(grid)

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

        self.setLayout(ly)

        alto = self.tol.num_themes * 42 + 146
        self.restore_video(siTam=True,
                           altoDefecto=alto,
                           anchoDefecto=max(nAnchoPgn, 480))
示例#45
0
文件: Gui.py 项目: JERUKA9/lucaschess
def lanzaGUI(procesador):
    """
    Lanzador del interfaz grafico de la aplicacion.
    """

    # Comprobamos el lenguaje
    app = QtGui.QApplication([])

    liUsuarios = Usuarios.listaUsuarios()
    if liUsuarios:
        usuario = pideUsuario(liUsuarios)
        if usuario is None:
            return
        user = str(usuario.numero) if usuario.numero else ""
    else:
        user = ""

    activeFolder = Configuracion.activeFolder()
    siPedirLenguaje = not os.path.isdir(activeFolder) or not os.listdir(activeFolder)
    procesador.iniciaConUsuario(user)
    configuracion = procesador.configuracion

    # Comprobamos el lenguaje
    if siPedirLenguaje and not configuracion.traductor:
        if user:
            confMain = Configuracion.Configuracion("")
            ori = confMain.ficheroMExternos
            confMain.lee()
            confMain.limpia(usuario.nombre)
            confMain.ponCarpetas(user)
            confMain.graba()
            procesador.configuracion = confMain

            Util.copiaFichero(ori, confMain.carpeta)

        else:
            li = configuracion.listaTraducciones()
            menu = QTVarios.LCMenu(None)

            nico = QTVarios.rondoPuntos()
            for k, nombre, porc in li:
                rotulo = nombre
                if porc != "100":
                    rotulo += " (%s%%)"%porc
                menu.opcion(k, nombre, nico.otro())
            resp = menu.lanza()
            if resp:
                configuracion.traductor = resp
                configuracion.graba()

    # Estilo
    global stylename
    styleName = configuracion.estilo
    app.setStyle(QtGui.QStyleFactory.create(styleName))
    app.setPalette(QtGui.QApplication.style().standardPalette())
    app.setEffectEnabled(QtCore.Qt.UI_AnimateMenu)

    if configuracion.familia:
        font = Controles.TipoLetra(configuracion.familia)
        app.setFont(font)

    VarGen.gc = QTUtil.GarbageCollector()

    # Lanzamos la pantalla
    procesador.iniciarGUI()

    resp = app.exec_()
    Voice.runVoice.close()

    return resp
示例#46
0
    def mueveHumano(self, desde, hasta, coronacion=None):
        jg = self.checkMueveHumano(desde, hasta, coronacion)
        if not jg:
            return False

        movimiento = jg.movimiento()

        siAnalisis = False

        siElegido = False

        if self.book and self.bookMandatory:
            fen = self.fenUltimo()
            listaJugadas = self.book.miraListaJugadas(fen)
            if listaJugadas:
                li = []
                for apdesde, aphasta, apcoronacion, nada, nada1 in listaJugadas:
                    mx = apdesde + aphasta + apcoronacion
                    if mx.strip().lower() == movimiento:
                        siElegido = True
                        break
                    li.append((apdesde, aphasta, False))
                if not siElegido:
                    self.tablero.ponFlechasTmp(li)
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaObl:
            fenBase = self.fenUltimo()
            if self.aperturaObl.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                apdesde, aphasta = self.aperturaObl.desdeHastaActual(fenBase)
                if apdesde is None:
                    self.aperturaObl = None
                else:
                    self.tablero.ponFlechasTmp(((apdesde, aphasta, False), ))
                    self.sigueHumano()
                    return False

        if not siElegido and self.aperturaStd:
            fenBase = self.fenUltimo()
            if self.aperturaStd.compruebaHumano(fenBase, desde, hasta):
                siElegido = True
            else:
                if not self.aperturaStd.isActive(fenBase):
                    self.aperturaStd = None

        if self.siTeclaPanico:
            self.sigueHumano()
            return False

        self.analizaFinal()  # tiene que acabar siempre
        if not siElegido and self.siTutorActivado:
            rmUser, n = self.mrmTutor.buscaRM(movimiento)
            if not rmUser:
                rmUser = self.xtutor.valora(self.partida.ultPosicion, desde,
                                            hasta, jg.coronacion)
                if not rmUser:
                    self.sigueHumanoAnalisis()
                    return False
                self.mrmTutor.agregaRM(rmUser)
            siAnalisis = True
            pointsBest, pointsUser = self.mrmTutor.difPointsBest(movimiento)
            self.setSummary("POINTSBEST", pointsBest)
            self.setSummary("POINTSUSER", pointsUser)
            difpts = self.configuracion.tutorDifPts
            difporc = self.configuracion.tutorDifPorc
            if self.mrmTutor.mejorRMQue(rmUser, difpts, difporc):
                if not jg.siJaqueMate:
                    siTutor = True
                    if self.chance:
                        num = self.mrmTutor.numMejorMovQue(movimiento)
                        if num:
                            rmTutor = self.mrmTutor.rmBest()
                            menu = QTVarios.LCMenu(self.pantalla)
                            menu.opcion("None",
                                        _("There are %d best moves") % num,
                                        Iconos.Motor())
                            menu.separador()
                            menu.opcion(
                                "tutor", "&1. %s (%s)" %
                                (_("Show tutor"), rmTutor.abrTextoBase()),
                                Iconos.Tutor())
                            menu.separador()
                            menu.opcion("try", "&2. %s" % _("Try again"),
                                        Iconos.Atras())
                            menu.separador()
                            menu.opcion(
                                "user", "&3. %s (%s)" %
                                (_("Select my move"), rmUser.abrTextoBase()),
                                Iconos.Player())
                            self.pantalla.cursorFueraTablero()
                            resp = menu.lanza()
                            if resp == "try":
                                self.sigueHumanoAnalisis()
                                return False
                            elif resp == "user":
                                siTutor = False
                            elif resp != "tutor":
                                self.sigueHumanoAnalisis()
                                return False

                    if siTutor:
                        tutor = Tutor.Tutor(self, self, jg, desde, hasta,
                                            False)

                        if self.aperturaStd:
                            liApPosibles = self.listaAperturasStd.listaAperturasPosibles(
                                self.partida)
                        else:
                            liApPosibles = None

                        if tutor.elegir(self.ayudas > 0,
                                        liApPosibles=liApPosibles):
                            if self.ayudas > 0:  # doble entrada a tutor.
                                self.reponPieza(desde)
                                self.ayudas -= 1
                                desde = tutor.desde
                                hasta = tutor.hasta
                                coronacion = tutor.coronacion
                                siBien, mens, jgTutor = Jugada.dameJugada(
                                    self.partida.ultPosicion, desde, hasta,
                                    coronacion)
                                if siBien:
                                    jg = jgTutor
                                    self.setSummary("SELECTTUTOR", True)
                        if self.configuracion.guardarVariantesTutor:
                            tutor.ponVariantes(
                                jg, 1 + self.partida.numJugadas() / 2)

                        del tutor

        self.setSummary("TIMEUSER", self.timekeeper.stop())
        self.relojStop(True)

        self.movimientosPiezas(jg.liMovs)

        if siAnalisis:
            rm, nPos = self.mrmTutor.buscaRM(jg.movimiento())
            if rm:
                jg.analisis = self.mrmTutor, nPos

        self.partida.ultPosicion = jg.posicion
        self.masJugada(jg, True)
        self.error = ""
        self.siguienteJugada()
        return True
示例#47
0
 def gmGuardar(self):
     pgn = self.pgnActual()
     if pgn:
         QTVarios.savePGN(self, pgn)
示例#48
0
def dameCategoria(wParent, configuracion, procesador):
    rival = configuracion.rival

    menu = QTVarios.LCMenu(wParent)

    menu.opcion(None, "%s: %d %s" % (_("Total score"), configuracion.puntuacion(), _("pts")), Iconos.NuevaPartida())
    menu.separador()
    menu.opcion(None, "%s: %s" % (_("Opponent"), rival.rotuloPuntos()), Iconos.Motor(), siDeshabilitado=False)
    menu.separador()

    # ---------- CATEGORIAS
    ant = 1
    for x in range(6):
        cat = rival.categorias.numero(x)
        txt = cat.nombre()
        nm = cat.nivelHecho

        nh = cat.hecho

        if nm > 0:
            txt += " %s %d" % (_("Level"), nm)
        if nh:
            if "B" in nh:
                txt += " +%s:%d" % (_("White"), nm + 1)
            if "N" in nh:
                txt += " +%s:%d" % (_("Black"), nm + 1)

                # if "B" not in nh:
                # txt += "  ...  %s:%d"%( _( "White" )[0],nm+1)
                # elif "N" not in nh:
                # txt += "  ...  %s:%d"%( _( "Black" )[0],nm+1)
                # else:
                # txt += "  ...  %s:%d"%( _( "White" )[0],nm+1)

        siDesHabilitado = (ant == 0)
        ant = nm
        menu.opcion(str(x), txt, cat.icono(), siDeshabilitado=siDesHabilitado)

    # ----------- RIVAL
    menu.separador()
    menuRival = menu.submenu(_("Change opponent"))

    puntuacion = configuracion.puntuacion()

    icoNo = Iconos.Motor_No()
    icoSi = Iconos.Motor_Si()
    icoActual = Iconos.Motor_Actual()
    grpNo = Iconos.Grupo_No()
    grpSi = Iconos.Grupo_Si()

    for grupo in configuracion.grupos.liGrupos:
        nombre = _X(_("%1 group"), grupo.nombre)
        if grupo.minPuntos > 0:
            nombre += " (+%d %s)" % (grupo.minPuntos, _("pts"))

        siDes = (grupo.minPuntos > puntuacion)
        if siDes:
            icoG = grpNo
            icoM = icoNo
        else:
            icoG = grpSi
            icoM = icoSi
        submenu = menuRival.submenu(nombre, icoG)

        for rv in grupo.liRivales:
            siActual = rv.clave == rival.clave
            ico = icoActual if siActual else icoM
            submenu.opcion("MT_" + rv.clave, rv.rotuloPuntos(), ico, siDes or siActual)
        menuRival.separador()

    # ----------- RIVAL
    menu.separador()
    menu.opcion("ayuda", _("Help"), Iconos.Ayuda())

    cursor = QtGui.QCursor.pos()
    resp = menu.lanza()
    if resp is None:
        return None
    elif resp == "ayuda":
        titulo = _("Competition")
        ancho, alto = QTUtil.tamEscritorio()
        ancho = min(ancho, 700)
        txt = _("<br><b>The aim is to obtain the highest possible score</b> :<ul><li>The current point score is displayed in the title bar.</li><li>To obtain points it is necessary to win on different levels in different categories.</li><li>To overcome a level it is necessary to win against the engine with white and with black.</li><li>The categories are ranked in the order of the following table:</li><ul><li><b>Beginner</b> : 5</li><li><b>Amateur</b> : 10</li><li><b>Candidate Master</b> : 20</li><li><b>Master</b> : 40</li><li><b>International Master</b> : 80</li><li><b>Grandmaster</b> : 160</li></ul><li>The score for each game is calculated by multiplying the playing level with the score of the category.</li><li>The engines are divided into groups.</li><li>To be able to play with an opponent of a particular group a minimum point score is required. The required score is shown next to the group label.</li></ul>")
        Info.info(wParent, _("Lucas Chess"), titulo, txt, ancho, Iconos.pmAyudaGR())
        return None

    elif resp.startswith("MT_"):
        procesador.cambiaRival(resp[3:])
        QtGui.QCursor.setPos(cursor)
        procesador.competicion()
        return None
    else:
        categoria = rival.categorias.numero(int(resp))
        return categoria
示例#49
0
    def tw_filtrar(self):
        xpv = None
        if self.summaryActivo and "pv" in self.summaryActivo:
            li = self.summaryActivo["pv"].split(" ")
            if len(li) > 1:
                xpv = " ".join(li[:-1])

        def refresh():
            self.grid.refresh()
            self.grid.gotop()
            self.updateStatus()
            self.gridCambiadoRegistro(None, 0, 0)

        def standard():
            w = PantallaPGN.WFiltrar(self, self.grid.oColumnas, self.liFiltro,
                                     self.dbGames.nomFichero)
            if w.exec_():
                self.liFiltro = w.liFiltro

                self.where = w.where()
                self.dbGames.filterPV(xpv, self.where)
                refresh()

        def raw_sql():
            w = PantallaPGN.WFiltrarRaw(self, self.grid.oColumnas, self.where)
            if w.exec_():
                self.where = w.where
                self.dbGames.filterPV(xpv, self.where)
                refresh()

        def opening():
            me = QTUtil2.unMomento(self)
            import Code.QT.PantallaAperturas as PantallaAperturas
            w = PantallaAperturas.WAperturas(self, self.configuracion,
                                             self.last_opening)
            me.final()
            if w.exec_():
                self.last_opening = ap = w.resultado()
                pv = getattr(ap, "a1h8", "")
                self.dbGames.filterPV(pv)
                self.numJugada = pv.count(" ")
                refresh()

        def remove():
            self.dbGames.filterPV("")
            self.where = None
            refresh()

        menu = QTVarios.LCMenu(self)
        menu.opcion(standard, _("Standard"), Iconos.Filtrar())
        menu.separador()
        menu.opcion(raw_sql, _("Advanced"), Iconos.SQL_RAW())
        menu.separador()
        menu.opcion(opening, _("Opening"), Iconos.Apertura())
        if self.dbGames.filter is not None and self.dbGames.filter:
            menu.separador()
            menu.opcion(remove, _("Remove filter"), Iconos.Cancelar())
        # menu.opcion(vopening, _("Various openings"), Iconos.Apertura())
        # menu.separador()
        # menu.opcion(sample, _("Select a sample"), Iconos.Apertura())
        # menu.separador()

        resp = menu.lanza()
        if resp:
            resp()
示例#50
0
    def creaMenu(self):
        dicMenu = {}
        menu = QTVarios.LCMenu(self.parent)

        def xopcion(menu, clave, texto, icono, siDeshabilitado=False):
            menu.opcion(clave, texto, icono, siDeshabilitado)
            dicMenu[clave] = (clave, texto, icono, siDeshabilitado )

        # Posiciones de entrenamiento --------------------------------------------------------------------------
        self.menuFNS(menu, _("Training positions"), xopcion)
        menu.separador()

        # GM ---------------------------------------------------------------------------------------------------
        xopcion(menu, "gm", _("Play like a grandmaster"), Iconos.GranMaestro())
        menu.separador()

        # Mate --------------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Training mates"), Iconos.Mate())
        for mate in range(1, 5):
            xopcion(menu1, "mate%d" % mate, _X(_("Mate in %1"), str(mate)), Iconos.PuntoAzul())
            menu1.separador()
        menu.separador()

        # BMT -------------------------------------------------------------------------------------------
        xopcion(menu, "bmt", _("Find best move"), Iconos.BMT())
        menu.separador()

        # Openings ------------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Openings"), Iconos.Aperturas())
        # # Aperturas --------------------------------------------------------------------------------------------
        xopcion(menu1, "aperturas", _("Learn openings by repetition"), Iconos.Apertura())
        menu1.separador()
        ## Books ------------------------------------------------------------------------------------------------
        xopcion(menu1, "polyglot", _("Training with a book"), Iconos.Libros())

        menu.separador()

        # DailyTest ------------------------------------------------------------------------------------------------
        xopcion(menu, "dailytest", _("Your daily test"), Iconos.DailyTest())
        menu.separador()

        # Resistencia ------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Resistance Test"), Iconos.Resistencia())
        nico = Util.Rondo(Iconos.Verde(), Iconos.Azul(), Iconos.Amarillo(), Iconos.Naranja())
        xopcion(menu1, "boxing", _("Normal"), nico.otro())
        xopcion(menu1, "boxingc", _("Blindfold chess"), nico.otro())
        xopcion(menu1, "boxingp1", _("Hide only our pieces"), nico.otro())
        xopcion(menu1, "boxingp2", _("Hide only opponent pieces"), nico.otro())
        menu.separador()

        # Tacticas ---------------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Learn tactics by repetition"), Iconos.Tacticas())
        nico = Util.Rondo(Iconos.Amarillo(), Iconos.Naranja(), Iconos.Verde(), Iconos.Azul(), Iconos.Magenta())
        dicTraining = TrListas.dicTraining()

        def trTraining(txt):
            return dicTraining.get(txt, txt)

        def menuTacticas(tipo, carpetaBase):
            lista = []
            if os.path.isdir(carpetaBase):
                li = Util.listdir(carpetaBase)
                for nombre in li:
                    carpeta = os.path.join(carpetaBase, nombre)
                    ini = os.path.join(carpeta, "Config.ini")
                    if os.path.isdir(carpeta) and os.path.isfile(ini):
                        xopcion(menu1, "tactica|%s|%s|%s|%s" % (tipo, nombre, carpeta, ini), trTraining(nombre),
                                nico.otro())
                        menu1.separador()
                        lista.append((carpeta, nombre))
            return lista

        menuTacticas("B", "Tactics")
        carpetaTacticasP = os.path.join(self.configuracion.dirPersonalTraining, "Tactics")
        lista = menuTacticas("P", carpetaTacticasP)
        if lista:
            ico = Iconos.Delete()
            menub = menu1.submenu(_("Remove"), ico)
            for carpeta, nombre in lista:
                xopcion(menub, "remtactica|%s|%s" % (carpeta, nombre), trTraining(nombre), ico)

        menu.separador()

        # Maps ----------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Training on a map"), Iconos.Maps())
        xopcion(menu1, "map_Africa", _("Africa map"), Iconos.Africa())
        menu1.separador()
        xopcion(menu1, "map_WorldMap", _("World map"), Iconos.WorldMap())

        # Cebras ---------------------------------------------------------------------------------------------------
        menu.separador()
        menu1 = menu.submenu(_("Resources for zebras"), Iconos.Cebra())
        menu2 = menu1.submenu(_("Check your memory on a chessboard"), Iconos.Memoria())
        rival = self.configuracion.rival

        mem = Memoria.Memoria(self.procesador)

        for x in range(6):
            cat = rival.categorias.numero(x)
            txt = cat.nombre()

            nm = mem.nivel(x)
            if nm > -1:
                txt += " %s %d" % (_("Level"), nm + 1)

            xopcion(menu2, -100 - x, txt, cat.icono(), siDeshabilitado=not mem.siActiva(x))

        menu1.separador()

        menu2 = menu1.submenu(_("Find all moves"), Iconos.J60())
        xopcion(menu2, "j60_rival", _("Opponent"), Iconos.PuntoNaranja())
        xopcion(menu2, "j60_jugador", _("Player"), Iconos.PuntoAzul())

        menu1.separador()
        self.horsesDef = hd = {
            1: ( "N", "Alpha", _("Basic test") ),
            2: ( "p", "Fantasy", _("Four pawns test") ),
            3: ( "Q", "Pirat", _("Jonathan Levitt test") ),
            4: ( "n", "Spatial", _("Basic test") + ": a1" ),
            5: ( "N", "Cburnett", _("Basic test") + ": e4" )
        }
        menu2 = menu1.submenu(_("Becoming a knight tamer"), self.procesador.tablero.piezas.icono("N"))
        vicon = VarGen.todasPiezas.icono
        icl, icn, tit = hd[1]
        menu3 = menu2.submenu(tit, vicon(icl, icn))
        xopcion(menu3, "horses_1", tit, vicon(icl, icn))
        menu3.separador()
        icl, icn, tit = hd[4]
        xopcion(menu3, "horses_4", tit, vicon(icl, icn))
        menu3.separador()
        icl, icn, tit = hd[5]
        xopcion(menu3, "horses_5", tit, vicon(icl, icn))
        menu2.separador()
        icl, icn, tit = hd[2]
        xopcion(menu2, "horses_2", tit, vicon(icl, icn))
        menu2.separador()
        icl, icn, tit = hd[3]
        xopcion(menu2, "horses_3", tit, vicon(icl, icn))

        menu1.separador()
        menu2 = menu1.submenu(_("Moves between two positions"), Iconos.Puente())
        rp = QTVarios.rondoPuntos()
        for x in range(1, 11):
            xopcion(menu2, "puente_%d" % x, "%s %d" % (_("Level"), x), rp.otro())

        menu1.separador()
        xopcion(menu1, "potencia", _("Determine your calculating power"), Iconos.Potencia())

        menu1.separador()
        xopcion(menu1, "learnPGN", _("Learn a game"), Iconos.PGN())

        menu1.separador()
        xopcion(menu1, "visualiza", _("The board at a glance"), Iconos.Gafas())

        # Ratings
        menu.separador()
        menu1 = menu.submenu(_("Training ratings"), Iconos.Elo())
        xopcion(menu1, "lucaselo", "%s (%d)" % (_("Lucas-Elo"), self.configuracion.eloNC), Iconos.Elo())
        menu1.separador()
        xopcion(menu1, "micelo", "%s (%d)" % (_("Tourney-Elo"), self.configuracion.micheloNC), Iconos.EloTimed())
        menu1.separador()
        fics = self.configuracion.ficsNC
        menuf = menu1.submenu("%s (%d)" % (_("Fics-Elo"), fics), Iconos.Fics())
        rp = QTVarios.rondoPuntos()
        for elo in range(900, 2800, 100):
            if (elo == 900) or (0 <= (elo + 99 - fics) <= 400 or 0 <= (fics - elo) <= 400):
                xopcion(menuf, "fics%d" % (elo / 100,), "%d-%d" % (elo, elo + 99), rp.otro())
        menu1.separador()
        fide = self.configuracion.fideNC
        menuf = menu1.submenu("%s (%d)" % (_("Fide-Elo"), fide), Iconos.Fide())
        rp = QTVarios.rondoPuntos()
        for elo in range(1500, 2700, 100):
            if (elo == 1500) or (0 <= (elo + 99 - fide) <= 400 or 0 <= (fide - elo) <= 400):
                xopcion(menuf, "fide%d" % (elo / 100,), "%d-%d" % (elo, elo + 99), rp.otro())

        return menu, dicMenu
示例#51
0
    def __init__(self, mAnalisis, ventana, siBlancas, siLibre, siGrabar, muestraInicial):
        titulo = _("Analysis")
        icono = Iconos.Tutor()
        extparam = "analysis"

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

        self.mAnalisis = mAnalisis
        self.muestraActual = None

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.recuperarVideo(siTam=False)
        self.show()
        wm.cambiadoRM(muestraInicial.posElegida)
        self.activaMuestra(muestraInicial)
示例#52
0
 def tg_change(self):
     database = QTVarios.selectDB(self, self.configuracion, False)
     if database:
         path = os.path.dirname(database)
         if os.path.isdir(path):
             self.changeDBgames(database)
示例#53
0
 def tg_create(self):
     database = QTVarios.createDB(self, self.configuracion, False)
     if database:
         self.changeDBgames(database)
示例#54
0
    def menuPlay(self):
        menu = QTVarios.LCMenu(self.pantalla)
        menu.opcion(k_libre, _("Play against an engine of your choice"), Iconos.Libre())
        menu.separador()

        # Principiantes ----------------------------------------------------------------------------------------
        menu1 = menu.submenu(_("Opponents for young players"), Iconos.RivalesMP())

        menu1.opcion(1000 + kMP_1, _("Monkey"), Iconos.Monkey())
        menu1.opcion(1000 + kMP_2, _("Donkey"), Iconos.Donkey())
        menu1.opcion(1000 + kMP_3, _("Bull"), Iconos.Bull())
        menu1.opcion(1000 + kMP_4, _("Wolf"), Iconos.Wolf())
        menu1.opcion(1000 + kMP_5, _("Lion"), Iconos.Lion())
        menu1.opcion(1000 + kMP_6, _("Rat"), Iconos.Rat())
        menu1.opcion(1000 + kMP_7, _("Snake"), Iconos.Snake())
        menu1.separador()

        menu2 = menu1.submenu(_("Albums of animals"), Iconos.Penguin())
        albumes = Albums.AlbumesAnimales()
        dic = albumes.listaMenu()
        anterior = None
        for animal in dic:
            siDeshabilitado = False
            if anterior and not dic[anterior]:
                siDeshabilitado = True
            menu2.opcion(( "animales", animal ), _F(animal), Iconos.icono(animal), siDeshabilitado=siDeshabilitado)
            anterior = animal
        menu1.separador()

        menu2 = menu1.submenu(_("Albums of vehicles"), Iconos.Wheel())
        albumes = Albums.AlbumesVehicles()
        dic = albumes.listaMenu()
        anterior = None
        for character in dic:
            siDeshabilitado = False
            if anterior and not dic[anterior]:
                siDeshabilitado = True
            menu2.opcion(( "vehicles", character ), _F(character), Iconos.icono(character),
                         siDeshabilitado=siDeshabilitado)
            anterior = character

        resp = menu.lanza()
        if resp:
            if resp == k_libre:
                self.procesarAccion(resp)

            elif type(resp) == int:
                rival = resp - 1000
                uno = QTVarios.blancasNegrasTiempo(self.pantalla)
                if uno:
                    siBlancas, siTiempo, minutos, segundos = uno
                    if siBlancas is not None:
                        if not siTiempo:
                            minutos = None
                            segundos = None
                        self.entrenaRivalesMPC(siBlancas, rival, rival >= kMP_6, minutos, segundos)
            else:
                tipo, cual = resp
                if tipo == "animales":
                    self.albumAnimales(cual)
                elif tipo == "vehicles":
                    self.albumVehicles(cual)