コード例 #1
0
    def __init__(self, procesador, dbop):
        self.dbop = dbop
        self.title = dbop.gettitle()

        QTVarios.WDialogo.__init__(self, procesador.main_window, self.title,
                                   Iconos.OpeningLines(), "studyOpening")

        self.procesador = procesador
        self.configuration = procesador.configuration
        self.gamebase = self.dbop.getgamebase()
        self.num_jg_inicial = self.gamebase.num_moves()
        self.num_jg_actual = None
        self.game = None

        self.resultado = None
        si_figurines_pgn = self.configuration.x_pgn_withfigurines

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Remove"), Iconos.Borrar(), self.borrar),
            None,
            (_("Import"), Iconos.Import8(), self.importar),
            None,
            (_("Export"), Iconos.Export8(), self.exportar),
            None,
            (_("Utilities"), Iconos.Utilidades(), self.utilidades),
            None,
            (_("Train"), Iconos.Study(), self.train),
            None,
        )
        self.tb = QTVarios.LCTB(self, li_acciones, icon_size=20)

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("LINE",
                        _("Line"),
                        35,
                        edicion=Delegados.EtiquetaPOS(False, True))
        start = self.gamebase.num_moves() // 2 + 1
        ancho_col = int(
            ((self.configuration.x_pgn_width - 35 - 20) / 2) * 80 / 100)
        for x in range(start, 75):
            o_columns.nueva(str(x),
                            str(x),
                            ancho_col,
                            edicion=Delegados.EtiquetaPOS(
                                si_figurines_pgn, True))
        self.glines = Grid.Grid(self, o_columns, siCabeceraMovible=False)
        self.glines.setAlternatingRowColors(False)
        self.glines.tipoLetra(puntos=self.configuration.x_pgn_fontpoints)
        self.glines.ponAltoFila(self.configuration.x_pgn_rowheight)

        self.pboard = POLBoard.BoardLines(self, self.configuration)

        self.tabsanalisis = POLAnalisis.TabsAnalisis(self, self.procesador,
                                                     self.configuration)

        widget = QtWidgets.QWidget()
        widget.setStyleSheet("background-color:lightgray;")
        widget_layout = Colocacion.V().control(self.glines)
        widget_layout.setSpacing(10)
        widget_layout.margen(3)
        widget.setLayout(widget_layout)

        splitter = QtWidgets.QSplitter(self)
        splitter.setOrientation(QtCore.Qt.Vertical)
        splitter.addWidget(widget)
        splitter.addWidget(self.tabsanalisis)

        sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        splitter.setSizePolicy(sp)

        self.register_splitter(splitter, "SPLITTER")

        layout_down = Colocacion.H().control(
            self.pboard).control(splitter).margen(3)
        layout = Colocacion.V().control(self.tb).otro(layout_down).margen(3)
        self.setLayout(layout)

        self.colorPar = QTUtil.qtColor("#DBDAD9")
        self.colorNon = QTUtil.qtColor("#F1EFE9")
        self.colorLine = QTUtil.qtColor("#CDCCCB")

        self.game = self.gamebase

        self.pboard.MoverFinal()

        self.restore_video()

        self.last_numlines = 0
        self.show_lines()
コード例 #2
0
ファイル: WBG_Games.py プロジェクト: svasan/lucaschess
    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()
コード例 #3
0
    def __init__(self, procesador):

        self.procesador = procesador
        self.configuration = procesador.configuration
        self.resultado = None
        self.listaOpenings = OpeningLines.ListaOpenings(self.configuration)

        QTVarios.WDialogo.__init__(self, procesador.main_window, self.getTitulo(), Iconos.OpeningLines(), "openingLines")

        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("TITLE", _("Name"), 240)
        o_columns.nueva("BASEPV", _("First moves"), 280)
        o_columns.nueva("NUMLINES", _("Lines"), 80, centered=True)
        o_columns.nueva("FILE", _("File"), 200)
        self.glista = Grid.Grid(self, o_columns, siSelecFilas=True, siSeleccionMultiple=True)

        sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Edit"), Iconos.Modificar(), self.modificar),
            None,
            (_("New"), Iconos.Nuevo(), self.new),
            None,
            (_("Copy"), Iconos.Copiar(), self.copy),
            None,
            (_("Rename"), Iconos.Modificar(), self.renombrar),
            None,
            (_("Up"), Iconos.Arriba(), self.arriba),
            (_("Down"), Iconos.Abajo(), self.abajo),
            None,
            (_("Remove"), Iconos.Borrar(), self.borrar),
            None,
            (_("Update"), Iconos.Reiniciar(), self.reiniciar),
            None,
            (_("Folder"), Iconos.File(), self.changeFolder),
            None,
        )
        tb = QTVarios.LCTB(self, li_acciones)

        tb.setSizePolicy(sp)

        li_acciones = (
            (_("Sequential"), Iconos.TrainSequential(), self.tr_sequential),
            None,
            (_("Static"), Iconos.TrainStatic(), self.tr_static),
            None,
            (_("Positions"), Iconos.TrainPositions(), self.tr_positions),
            None,
            (_("With engines"), Iconos.TrainEngines(), self.tr_engines),
        )
        self.tbtrain = tbtrain = Controles.TBrutina(self, li_acciones, with_text=False)

        lbtrain = Controles.LB(self, _("Trainings")).align_center().set_background("lightgray")
        lytrain = Colocacion.V().control(lbtrain).control(tbtrain).margen(0)
        self.wtrain = QtWidgets.QWidget()
        self.wtrain.setLayout(lytrain)

        lytb = Colocacion.H().control(tb).control(self.wtrain).margen(0)
        wtb = QtWidgets.QWidget()
        wtb.setFixedHeight(62)
        wtb.setLayout(lytb)

        # Colocamos

        ly = Colocacion.V().control(wtb).control(self.glista).margen(4)

        self.setLayout(ly)

        self.register_grid(self.glista)
        self.restore_video(anchoDefecto=self.glista.anchoColumnas() + 20)

        self.wtrain.setVisible(False)
        self.glista.gotop()
コード例 #4
0
    def __init__(self, manager, elo, titulo, icono, tipo):
        QTVarios.WDialogo.__init__(self, manager.main_window, titulo, icono, tipo.lower())

        self.siMicElo = tipo == "MICELO"
        self.siMicPer = tipo == "MICPER"
        self.siMic = self.siMicElo or self.siMicPer

        self.manager = manager

        self.colorNoJugable = QTUtil.qtColorRGB(241, 226, 226)
        self.colorMenor = QTUtil.qtColorRGB(245, 245, 245)
        self.colorMayor = None
        self.elo = elo
        self.tipo = tipo

        # Toolbar
        li_acciones = [
            (_("Choose"), Iconos.Aceptar(), self.elegir),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("Random opponent"), Iconos.FAQ(), self.selectRandom),
            None,
        ]
        if self.siMicElo:
            li_acciones.append((_("Reset"), Iconos.Reiniciar(), self.reset))
            li_acciones.append(None)

        self.tb = QTVarios.LCTB(self, li_acciones)

        self.liMotores = self.manager.list_engines(elo)
        self.liMotoresActivos = self.liMotores

        liFiltro = (
            ("---", None),
            (">=", ">"),
            ("<=", "<"),
            ("+-100", "100"),
            ("+-200", "200"),
            ("+-400", "400"),
            ("+-800", "800"),
        )

        self.cbElo = Controles.CB(self, liFiltro, None).capture_changes(self.filtrar)

        minimo = 9999
        maximo = 0
        for mt in self.liMotores:
            if mt.siJugable:
                if mt.elo < minimo:
                    minimo = mt.elo
                if mt.elo > maximo:
                    maximo = mt.elo
        self.sbElo, lbElo = QTUtil2.spinBoxLB(self, elo, minimo, maximo, maxTam=50, etiqueta=_("Elo"))
        self.sbElo.capture_changes(self.filtrar)

        if self.siMic:
            liCaract = []
            st = set()
            for mt in self.liMotores:
                mt.liCaract = li = mt.id_info.split("\n")
                mt.txtCaract = ", ".join([_F(x) for x in li])
                for x in li:
                    if not (x in st):
                        st.add(x)
                        liCaract.append((_F(x), x))
            liCaract.sort(key=lambda x: x[1])
            liCaract.insert(0, ("---", None))
            self.cbCaract = Controles.CB(self, liCaract, None).capture_changes(self.filtrar)

        ly = Colocacion.H().control(lbElo).control(self.cbElo).control(self.sbElo)
        if self.siMic:
            ly.control(self.cbCaract)
        ly.relleno(1)
        gbRandom = Controles.GB(self, "", ly)

        # Lista
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("NUMBER", _("N."), 35, centered=True)
        o_columns.nueva("ENGINE", _("Name"), 140)
        o_columns.nueva("ELO", _("Elo"), 60, siDerecha=True)
        if not self.siMicPer:
            o_columns.nueva("GANA", _("Win"), 80, centered=True)
            o_columns.nueva("TABLAS", _("Draw"), 80, centered=True)
            o_columns.nueva("PIERDE", _("Lost"), 80, centered=True)
        if self.siMic:
            o_columns.nueva("INFO", _("Information"), 300, centered=True)

        self.grid = Grid.Grid(self, o_columns, siSelecFilas=True, siCabeceraMovible=False, altoFila=24)
        n = self.grid.anchoColumnas()
        self.grid.setMinimumWidth(n + 20)
        self.register_grid(self.grid)

        f = Controles.TipoLetra(puntos=9)
        self.grid.ponFuente(f)

        self.grid.gotop()

        # Layout
        lyH = Colocacion.H().control(self.tb).control(gbRandom)
        layout = Colocacion.V().otro(lyH).control(self.grid).margen(3)
        self.setLayout(layout)

        self.filtrar()

        self.restore_video()
コード例 #5
0
    def __init__(self, procesador):
        self.procesador = procesador
        self.configuration = procesador.configuration
        self.reinit = False
        self.db = EndingsGTB.DBendings(self.configuration)
        self.t4 = LibChess.T4(self.configuration)

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

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

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

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

        self.chb_help = Controles.CHB(self, _("Help mode"),
                                      False).capture_changes(
                                          self, self.help_changed)
        self.bt_back = Controles.PB(self,
                                    _("Takeback"),
                                    self.takeback,
                                    plano=False).ponIcono(Iconos.Atras())
        ly_bt.espacio(20).control(self.bt_back).control(self.chb_help)

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

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

        li_acciones = (
            None,
            (" " + _("Restart"), Iconos.Reset(), self.restart),
            None,
            (" " + _("New"), Iconos.New1(), self.nuevo),
            None,
            (" " + _("Remove"), Iconos.Remove1(), self.remove),
            None,
        )
        self.tb_run = Controles.TBrutina(
            self,
            li_acciones,
            icon_size=32,
            puntos=self.configuration.x_tb_fontpoints)

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

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

        config_board = self.configuration.config_board("ENDINGSGTB", 64)
        self.board = BoardEndings(self, config_board)
        self.board.set_startup_control(self.startup_control)
        self.board.crea()
        self.board.ponerPiezasAbajo(True)
        self.board.set_dispatcher(self.player_has_moved)

        self.pzs = self.board.piezas
        self.playing = False

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

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

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

        self.restore_video()

        dic = self.configuration.read_variables("endingsGTB")

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

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

        self.grid.gotop()
        self.pos_game = -1
        self.help_changed()
        self.restart()
コード例 #6
0
    def init_working(self, route, lyTitle, lySVG):

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

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

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

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

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

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

        ly = Colocacion.V().otro(lyTitle).otro(lySVG).otro(lyLine).otro(lyTrack).otro(lyAll).relleno(1)
        self.setLayout(ly)
コード例 #7
0
    def __init__(self, w_parent, o_columns, liFiltro, dbSaveNom=None):
        super(WFiltrar, self).__init__()

        if dbSaveNom is None:
            dbSaveNom = Code.configuration.ficheroFiltrosPGN

        self.setWindowTitle(_("Filter"))
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog
                            | QtCore.Qt.WindowTitleHint)
        self.setWindowIcon(Iconos.Filtrar())

        self.liFiltro = liFiltro
        nFiltro = len(liFiltro)
        self.dbSaveNom = dbSaveNom

        li_fields = [(x.head, '"%s"' % x.key) for x in o_columns.li_columns
                     if x.key != "number" and x.key != "opening"]
        li_fields.insert(0, ("", None))
        liCondicion = [
            ("", None),
            (_("Equal"), "="),
            (_("Not equal"), "<>"),
            (_("Greater than"), ">"),
            (_("Less than"), "<"),
            (_("Greater than or equal"), ">="),
            (_("Less than or equal"), "<="),
            (_("Like (wildcard = *)"), "LIKE"),
            (_("Not like (wildcard = *)"), "NOT LIKE"),
        ]

        liUnion = [("", None), (_("AND"), "AND"), (_("OR"), "OR")]

        f = Controles.TipoLetra(puntos=12)  # 0, peso=75 )

        lbCol = Controles.LB(self, _("Column")).ponFuente(f)
        lbPar0 = Controles.LB(self, "(").ponFuente(f)
        lbPar1 = Controles.LB(self, ")").ponFuente(f)
        lbCon = Controles.LB(self, _("Condition")).ponFuente(f)
        lbVal = Controles.LB(self, _("Value")).ponFuente(f)
        lbUni = Controles.LB(self, "+").ponFuente(f)

        ly = Colocacion.G()
        ly.controlc(lbUni, 0, 0).controlc(lbPar0, 0, 1).controlc(lbCol, 0, 2)
        ly.controlc(lbCon, 0, 3).controlc(lbVal, 0, 4).controlc(lbPar1, 0, 5)

        self.numC = 8
        liC = []

        union, par0, campo, condicion, valor, par1 = None, False, None, None, "", False
        for i in range(self.numC):
            if i > 0:
                c_union = Controles.CB(self, liUnion, union)
                ly.controlc(c_union, i + 1, 0)
            else:
                c_union = None

            c_par0 = Controles.CHB(self, "", par0).anchoFijo(20)
            ly.controlc(c_par0, i + 1, 1)
            c_campo = Controles.CB(self, li_fields, campo)
            ly.controlc(c_campo, i + 1, 2)
            c_condicion = Controles.CB(self, liCondicion, condicion)
            ly.controlc(c_condicion, i + 1, 3)
            c_valor = Controles.ED(self, valor)
            ly.controlc(c_valor, i + 1, 4)
            c_par1 = Controles.CHB(self, "", par1).anchoFijo(20)
            ly.controlc(c_par1, i + 1, 5)

            liC.append(
                (c_union, c_par0, c_campo, c_condicion, c_valor, c_par1))

        self.liC = liC

        # Toolbar
        li_acciones = [
            (_("Accept"), Iconos.Aceptar(), self.aceptar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.reject),
            None,
            (_("Reinit"), Iconos.Reiniciar(), self.reiniciar),
            None,
            (_("Save/Restore"), Iconos.Grabar(), self.grabar),
            None,
        ]

        tb = QTVarios.LCTB(self, li_acciones)

        # Layout
        layout = Colocacion.V().control(tb).otro(ly).margen(3)
        self.setLayout(layout)

        liC[0][2].setFocus()

        if nFiltro > 0:
            self.lee_filtro(self.liFiltro)
コード例 #8
0
    def __init__(self, tableroOriginal):
        pantalla = tableroOriginal.parent()
        titulo = _("Colors")
        icono = Iconos.EditarColores()
        extparam = "WColores"
        QTVarios.WDialogo.__init__(self, pantalla, titulo, icono, extparam)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.setLayout(ly)

        self.elegido = None

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

        self.extendedColor()

        self.siActualizando = False

        self.recuperarVideo(siTam=False)
コード例 #9
0
    def __init__(self, procesador, winBookGuide, dbGames, siMoves=True):
        QtGui.QWidget.__init__(self)

        self.winBookGuide = winBookGuide

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

        self.leeConfig()

        self.aperturasStd = AperturasStd.ap

        self.siFigurinesPGN = self.configuracion.figurinesPGN

        self.pvBase = ""

        self.orden = ["games", False]

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

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

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

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

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

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

        layout.margen(1)

        self.setLayout(layout)

        self.qtColor = (QTUtil.qtColorRGB(221, 255, 221),
                        QTUtil.qtColorRGB(247, 247, 247),
                        QTUtil.qtColorRGB(255, 217, 217))
        self.qtColorTotales = QTUtil.qtColorRGB(170, 170, 170)
コード例 #10
0
ファイル: WRunMate15.py プロジェクト: xaizek/lucaschessR
    def __init__(self, owner, db_mate15, mate15):

        QTVarios.WDialogo.__init__(self, owner, _("Mate in 1½"),
                                   Iconos.Mate15(), "runmate15")

        self.configuracion = Code.configuracion
        self.mate15 = mate15
        self.db_mate15 = db_mate15

        conf_board = self.configuracion.config_board("RUNMATE15", 64)

        self.board = Tablero.TableroEstatico(self, conf_board)
        self.board.crea()

        # Rotulo informacion
        self.lb_info = Controles.LB(
            self,
            "[%d] %s" % (self.mate15.pos + 1, self.mate15.info)).ponTipoLetra(
                puntos=self.configuracion.x_pgn_fontpoints).alinCentrado()
        self.lb_info.setStyleSheet(
            "QWidget { background-color: #1f497d; color: #FFFFFF;padding: 16px; }"
        )

        self.lb_first_move = Controles.LB(self).ponTipoLetra(puntos=12,
                                                             peso=500)

        self.bt_check = Controles.PB(self, _("Check"), self.check,
                                     False).ponIcono(Iconos.Check(),
                                                     tamIcon=20)

        self.lb_result = Controles.LB(self).ponTipoLetra(puntos=12, peso=500)

        # Movimientos
        self.li_lb_wm = []
        ly = Colocacion.G().margen(4)
        for fila in range(10):
            lb = Controles.LB(self).ponTipoLetra(puntos=12, peso=500)
            wm = WRunCommon.WEdMove(self)
            self.li_lb_wm.append((lb, wm))
            ly.controld(lb, fila, 0)
            ly.columnaVacia(1, 20)
            ly.control(wm, fila, 2)
            lb.hide()
            wm.hide()
        ly.filaVacia(10, 20)
        ly.controlc(self.bt_check, 11, 0, numColumnas=3)
        ly.controlc(self.lb_result, 12, 0, numColumnas=3)
        self.gb = Controles.GB(self, _("Next moves and their solutions"),
                               ly).ponFuente(
                                   Controles.TipoLetra(puntos=10, peso=75))
        self.gb.hide()

        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,
                                style=QtCore.Qt.ToolButtonTextBesideIcon,
                                tamIcon=32)
        self.show_tb(self.terminar, self.begin)

        ly_right = Colocacion.V().control(self.tb).\
            controlc(self.lb_info).espacio(40).\
            controlc(self.lb_first_move).espacio(20).\
            control(self.gb).relleno()

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

        self.setLayout(ly_center)

        self.restore_video()
        self.adjustSize()

        self.gb.setDisabled(True)

        self.li_lb_wm[0][1].activa()

        self.ultimaCelda = None
コード例 #11
0
    def __init__(self, wParent, sts, work, procesador):
        titulo = "%s - %s - %s" % (sts.name, work.ref, work.pathToExe())
        icono = Iconos.STS()
        extparam = "runsts"
        QTVarios.WDialogo.__init__(self, wParent, titulo, icono, extparam)

        self.work = work
        self.sts = sts
        self.ngroup = -1
        self.xengine = procesador.creaGestorMotor(work.configEngine(),
                                                  work.seconds * 1000,
                                                  work.depth)
        self.xengine.set_direct()
        self.playing = False
        self.configuracion = procesador.configuracion
        self.run_test_close = work.seconds > 3 or work.depth > 10

        # Toolbar
        li_acciones = [
            (_("Close"), Iconos.MainMenu(), self.cerrar),
            None,
            (_("Run"), Iconos.Run(), self.run),
            (_("Pause"), Iconos.Pelicula_Pausa(), self.pause),
            None,
        ]
        self.tb = tb = QTVarios.LCTB(self, li_acciones, tamIcon=24)

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

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

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

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

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

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

        self.setLayout(ly)

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

        resp = self.sts.siguientePosicion(self.work)
        if resp:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, True)
        else:
            self.tb.setAccionVisible(self.pause, False)
            self.tb.setAccionVisible(self.run, False)
コード例 #12
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 = QTVarios.LCTB(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)
コード例 #13
0
    def __init__(self, owner, file):
        self.litourneys = Everest.str_file(file)
        self.configuration = owner.configuration
        titulo = _("New expedition")
        icono = Iconos.Trekking()
        extparam = "newexpedition"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.selected = None

        # Torneo
        li = [("%s (%d)" % (_F(tourney["TOURNEY"]), len(tourney["GAMES"])),
               tourney) for tourney in self.litourneys]
        li.sort(key=lambda x: x[0])
        self.cbtourney, lbtourney = QTUtil2.comboBoxLB(self, li, li[0],
                                                       _("Expedition"))
        btmas = Controles.PB(self, "", self.mas).ponIcono(Iconos.Mas22())
        lytourney = Colocacion.H().control(lbtourney).control(
            self.cbtourney).control(btmas).relleno(1)

        # tolerance
        self.sbtolerance_min, lbtolerance_min = QTUtil2.spinBoxLB(
            self, 20, 0, 99999, _("From"))
        self.sbtolerance_min.capture_changes(self.tolerance_changed)
        self.sbtolerance_max, lbtolerance_max = QTUtil2.spinBoxLB(
            self, 1000, 0, 99999, _("To"))
        lbexplanation = Controles.LB(
            self, _("Maximum lost points for having to repeat active game"))
        ly = Colocacion.H().relleno(2).control(lbtolerance_min).control(
            self.sbtolerance_min).relleno(1)
        ly.control(lbtolerance_max).control(self.sbtolerance_max).relleno(2)
        layout = Colocacion.V().otro(ly).control(lbexplanation)
        gbtolerance = Controles.GB(self, _("Tolerance"), layout)

        # tries
        self.sbtries_min, lbtries_min = QTUtil2.spinBoxLB(
            self, 2, 1, 99999, _("From"))
        self.sbtries_min.capture_changes(self.tries_changed)
        self.sbtries_max, lbtries_max = QTUtil2.spinBoxLB(
            self, 15, 1, 99999, _("To"))
        lbexplanation = Controles.LB(
            self, _("Maximum repetitions to return to the previous game"))
        ly = Colocacion.H().relleno(2).control(lbtries_min).control(
            self.sbtries_min).relleno(1)
        ly.control(lbtries_max).control(self.sbtries_max).relleno(2)
        layout = Colocacion.V().otro(ly).control(lbexplanation)
        gbtries = Controles.GB(self, _("Tries"), layout)

        # color
        liColors = ((_("Default"), "D"), (_("White"), "W"), (_("Black"), "B"))
        self.cbcolor = Controles.CB(self, liColors, "D")
        layout = Colocacion.H().relleno(1).control(self.cbcolor).relleno(1)
        gbcolor = Controles.GB(self, _("Color"), layout)

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

        layout = Colocacion.V().control(tb).otro(lytourney).control(
            gbtolerance).control(gbtries).control(gbcolor)

        self.setLayout(layout)
コード例 #14
0
    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=14, peso=500)

        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()
コード例 #15
0
    def __init__(self, w_parent, procesador, file_database, is_temporary,
                 si_select):
        self.is_temporary = is_temporary
        icono = Iconos.Database()
        extparam = "databases"
        titulo = _("Temporary database") if self.is_temporary else _(
            "Database")
        QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam)
        self.owner = w_parent

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

        self.reiniciar = False  # lo usamos para cambiar de database

        self.dbGames = DBgames.DBgames(file_database)

        self.dicvideo = self.restore_dicvideo()
        dicVideo = self.dicvideo

        siSummary = not si_select

        self.wplayer = WDB_Players.WPlayer(procesador, self, self.dbGames)
        self.wplayer_active = False

        if siSummary:
            self.wsummary = WDB_Summary.WSummary(procesador,
                                                 self,
                                                 self.dbGames,
                                                 siMoves=False)
            self.register_grid(self.wsummary.grid)

        else:
            self.wsummary = None

        self.wgames = WDB_Games.WGames(procesador, self, self.dbGames,
                                       self.wsummary, si_select)

        self.ultFocus = None

        self.tab = Controles.Tab()
        self.tab.nuevaTab(self.wgames, _("Games"))
        if siSummary:
            self.tab.nuevaTab(self.wsummary, _("Summary"))
            self.tab.dispatchChange(self.tabChanged)
        if not si_select:
            self.tab.nuevaTab(self.wplayer, _("Players"))
        self.tab.ponTipoLetra(puntos=procesador.configuration.x_tb_fontpoints)

        if self.owner and not self.is_temporary:
            liAccionesWork = [(_("Select other"), Iconos.Database(),
                               self.tw_select_other)]
            self.tbWork = QTVarios.LCTB(self, liAccionesWork, icon_size=20)
            self.tbWork.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
            self.tab.setCornerWidget(self.tbWork)

        w = QtWidgets.QWidget(self)
        layoutv = Colocacion.V().control(self.tab).margen(4)
        w.setLayout(layoutv)

        self.infoMove = WDB_InfoMove.WInfomove(self)

        self.splitter = splitter = QtWidgets.QSplitter()
        splitter.addWidget(w)
        splitter.addWidget(self.infoMove)

        layout = Colocacion.H().control(splitter).margen(0)
        self.setLayout(layout)

        self.restore_video(anchoDefecto=1200, altoDefecto=600)
        if not dicVideo:
            dicVideo = {
                "SPLITTER": [800, 380],
                "TREE_1": 25,
                "TREE_2": 25,
                "TREE_3": 50,
                "TREE_4": 661
            }

        if not ("SPLITTER" in dicVideo):
            ancho = self.width()
            ancho_board = self.infoMove.board.width()
            sz = [ancho - ancho_board, ancho_board]
        else:
            sz = dicVideo["SPLITTER"]
        self.splitter.setSizes(sz)

        dic_grid = self.dbGames.read_config("dic_grid")
        if not dic_grid:
            key = "databases_columns_default"
            dic_grid = self.configuration.read_variables(key)
        if dic_grid:
            self.wgames.grid.restore_video(dic_grid)
            self.wgames.grid.releerColumnas()

        self.inicializa()
コード例 #16
0
    def __init__(self, procesador, wb_database, dbGames, siMoves=True):
        QtWidgets.QWidget.__init__(self)

        self.wb_database = wb_database

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

        self.leeConfig()

        self.aperturasStd = OpeningsStd.ap

        self.si_figurines_pgn = self.configuration.x_pgn_withfigurines

        self.pvBase = ""

        self.orden = ["games", False]

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

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

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

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

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

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

        layout.margen(1)

        self.setLayout(layout)

        self.qtColor = (
            QTUtil.qtColorRGB(221, 255, 221),
            QTUtil.qtColorRGB(247, 247, 247),
            QTUtil.qtColorRGB(255, 217, 217),
        )
        self.qtColorTotales = QTUtil.qtColorRGB(170, 170, 170)
コード例 #17
0
    def __init__(self, owner, db_counts, count):

        QTVarios.WDialogo.__init__(self, owner, _("Count moves"), Iconos.Count(), "runcounts")

        self.configuration = Code.configuration
        self.count = count
        self.db_counts = db_counts

        conf_board = self.configuration.config_board("RUNCOUNTS", 64)

        self.board = Board.BoardEstaticoMensaje(self, conf_board, None)
        self.board.crea()

        # Rotulo informacion
        self.lb_info_game = Controles.LB(self, self.count.game.titulo("DATE", "EVENT", "WHITE", "BLACK", "RESULT")).ponTipoLetra(
            puntos=self.configuration.x_pgn_fontpoints
        )

        # Movimientos
        self.ed_moves = Controles.ED(self, "").ponTipoLetra(puntos=32)
        self.ed_moves.setValidator(QtGui.QIntValidator(self.ed_moves))
        self.ed_moves.setAlignment(QtCore.Qt.AlignRight)
        self.ed_moves.anchoFijo(72)

        ly = Colocacion.H().relleno().control(self.ed_moves).relleno()

        self.gb_counts = Controles.GB(self, _("Number of moves"), ly).ponFuente(Controles.TipoLetra(puntos=10, peso=75))

        self.lb_result = Controles.LB(self).ponTipoLetra(puntos=10, peso=500).anchoFijo(254).altoFijo(32).set_wrap()
        self.lb_info = (
            Controles.LB(self).ponTipoLetra(puntos=14, peso=500).anchoFijo(254).set_foreground_backgound("white", "#496075").align_center()
        )

        # Botones
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Begin"), Iconos.Empezar(), self.begin),
            (_("Check"), Iconos.Check(), self.check),
            (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir),
        )
        self.tb = QTVarios.LCTB(self, li_acciones, style=QtCore.Qt.ToolButtonTextBesideIcon, icon_size=32)
        self.show_tb(self.terminar, self.begin)

        ly_right = (
            Colocacion.V()
            .control(self.tb)
            .controlc(self.lb_info)
            .relleno()
            .control(self.gb_counts)
            .relleno()
            .control(self.lb_result)
            .relleno()
        )

        ly_center = Colocacion.H().control(self.board).otro(ly_right)

        ly = Colocacion.V().otro(ly_center).control(self.lb_info_game).margen(3)

        self.setLayout(ly)

        self.restore_video()
        self.adjustSize()

        # Tiempo
        self.time_base = time.time()

        self.gb_counts.setDisabled(True)

        self.pon_info_posic()
        self.set_position()
コード例 #18
0
ファイル: WindowAnalysis.py プロジェクト: gamaBHC/lucaschessR
    def __init__(self, tb_analysis, ventana, is_white, siLibre, must_save,
                 muestraInicial):
        titulo = _("Analysis")
        icono = Iconos.Tutor()
        extparam = "analysis"

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

        self.tb_analysis = tb_analysis
        self.muestraActual = None

        configuration = Code.configuration
        config_board = configuration.config_board("ANALISIS", 48)
        self.siLibre = siLibre
        self.must_save = must_save
        self.is_white = is_white

        tbWork = QTVarios.LCTB(self, icon_size=24)
        tbWork.new(_("Close"), Iconos.MainMenu(), self.terminar)
        tbWork.new(_("New"), Iconos.NuevoMas(), self.crear)

        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.ponerPiezasAbajo(is_white)
        self.board.dispatchSize(self.size_board_changed)

        self.lbMotor = Controles.LB(self).align_center()
        self.lbTiempo = Controles.LB(self).align_center()
        self.lbPuntuacion = (Controles.LB(self).align_center().ponTipoLetra(
            puntos=configuration.x_pgn_fontpoints, peso=75))
        self.lbPGN = Controles.LB(self).set_wrap().ponTipoLetra(
            puntos=configuration.x_pgn_fontpoints).anchoFijo(self.board.ancho)

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

        liMasAcciones = (("FEN:%s" % _("Copy to clipboard"), "MoverFEN",
                          Iconos.Clipboard()), )
        lytb, self.tb = QTVarios.lyBotonesMovimiento(
            self,
            "",
            siLibre=siLibre,
            must_save=must_save,
            siGrabarTodos=must_save,
            siJugar=tb_analysis.max_recursion > 10,
            liMasAcciones=liMasAcciones,
        )

        lyTabl = Colocacion.H().relleno().control(self.board).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.restore_video(siTam=False)
        wm.cambiadoRM(muestraInicial.pos_selected)
        self.activaMuestra(muestraInicial)
コード例 #19
0
    def __init__(self, wParent, nombre_torneo):

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

        self.configuracion = VarGen.configuracion

        # Datos
        torneo = self.torneo = Torneo.leer(nombre_torneo)

        self.liEnActual = []
        self.xjugar = None
        self.liResult = None

        # Toolbar
        liAcciones = (
            (_("Save") + "+" + _("Quit"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.cancelar),
            None,
            (_("Play"), Iconos.Empezar(), self.gmJugar),
            None,
        )
        tb = QTVarios.LCTB(self, liAcciones)

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

        # Tab-configuracion --------------------------------------------------
        w = QtGui.QWidget()
        # # Nombre
        lbNombre = Controles.LB(self, _("Name") + ": ")
        self.edNombre = Controles.ED(w, torneo.nombre())
        # # Resign
        lbResign = Controles.LB(self,
                                _("Minimum points to assign winner") + ": ")
        self.sbResign = Controles.SB(self, torneo.resign(), 60, 100000)
        # Draw-plys
        lbDrawMinPly = Controles.LB(self,
                                    _("Minimum moves to assign draw") + ": ")
        self.sbDrawMinPly = Controles.SB(self, torneo.drawMinPly(), 20, 1000)
        # Draw-puntos
        lbDrawRange = Controles.LB(self,
                                   _("Maximum points to assign draw") + ": ")
        self.sbDrawRange = Controles.SB(self, torneo.drawRange(), 0, 50)

        lbBook = Controles.LB(self, _("Opening book") + ": ")
        fvar = self.configuracion.ficheroBooks
        self.listaLibros = Books.ListaLibros()
        self.listaLibros.recuperaVar(fvar)
        # Comprobamos que todos esten accesibles
        self.listaLibros.comprueba()
        li = [(x.nombre, x.path) for x in self.listaLibros.lista]
        li.insert(0, ("* " + _("None"), "-"))
        self.cbBooks = Controles.CB(self, li, torneo.book())
        btNuevoBook = Controles.PB(self, "", self.nuevoBook,
                                   plano=False).ponIcono(Iconos.Nuevo(),
                                                         tamIcon=16)
        lyBook = Colocacion.H().control(
            self.cbBooks).control(btNuevoBook).relleno()

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

        # Posicion inicial
        lbFEN = Controles.LB(self, _("Initial position") + ": ")
        self.fen = torneo.fen()
        self.btPosicion = Controles.PB(self, " " * 5 + _("Change") + " " * 5,
                                       self.posicionEditar).ponPlano(False)
        self.btPosicionQuitar = Controles.PB(
            self, "", self.posicionQuitar).ponIcono(Iconos.Motor_No())
        self.btPosicionPegar = Controles.PB(self, "",
                                            self.posicionPegar).ponIcono(
                                                Iconos.Pegar16()).ponToolTip(
                                                    _("Paste FEN position"))
        lyFEN = Colocacion.H().control(self.btPosicionQuitar).control(
            self.btPosicion).control(self.btPosicionPegar).relleno()

        # Norman Pollock
        lbNorman = Controles.LB(
            self,
            '%s(<a href="https://komodochess.com/pub/40H-pgn-utilities">?</a>): '
            % _("Initial position from Norman Pollock openings database"))
        self.chbNorman = Controles.CHB(self, " ", self.torneo.norman())

        # Layout
        layout = Colocacion.G()
        layout.controld(lbNombre, 0, 0).control(self.edNombre, 0, 1)
        layout.controld(lbResign, 1, 0).control(self.sbResign, 1, 1)
        layout.controld(lbDrawMinPly, 2, 0).control(self.sbDrawMinPly, 2, 1)
        layout.controld(lbDrawRange, 3, 0).control(self.sbDrawRange, 3, 1)
        layout.controld(lbBook, 4, 0).otro(lyBook, 4, 1)
        layout.controld(lbBookDepth, 5, 0).control(self.sbBookDepth, 5, 1)
        layout.controld(lbFEN, 6, 0).otro(lyFEN, 6, 1)
        layout.controld(lbNorman, 7, 0).control(self.chbNorman, 7, 1)
        layoutV = Colocacion.V().relleno().otro(layout).relleno()
        layoutH = Colocacion.H().relleno().otro(layoutV).relleno()

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

        # Tab-engines --------------------------------------------------
        self.splitterEngines = QtGui.QSplitter(self)
        self.registrarSplitter(self.splitterEngines, "engines")
        # TB
        liAcciones = [
            (_("New"), Iconos.TutorialesCrear(), self.enNuevo),
            None,
            (_("Modify"), Iconos.Modificar(), self.enModificar),
            None,
            (_("Remove"), Iconos.Borrar(), self.enBorrar),
            None,
            (_("Copy"), Iconos.Copiar(), self.enCopiar),
            None,
            (_("Import"), Iconos.MasDoc(), self.enImportar),
            None,
        ]
        tbEnA = QTVarios.LCTB(self, liAcciones, tamIcon=24)

        # Grid engine
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("ALIAS", _("Alias"), 209)
        self.gridEnginesAlias = Grid.Grid(self,
                                          oColumnas,
                                          siSelecFilas=True,
                                          xid="EA",
                                          siSeleccionMultiple=True)
        self.registrarGrid(self.gridEnginesAlias)

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

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

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

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

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

        # Creamos

        # Tab-games --------------------------------------------------
        w = QtGui.QWidget()
        # TB
        liAcciones = [
            (_("New"), Iconos.TutorialesCrear(), self.gmCrear),
            None,
            (_("Remove"), Iconos.Borrar(), self.gmBorrar),
            None,
            (_("Show"), Iconos.PGN(), self.gmMostrar),
            None,
            (_("Save") + "(%s)" % _("PGN"), Iconos.GrabarComo(),
             self.gmGuardar),
            None,
        ]
        tbEnG = QTVarios.LCTB(self, liAcciones, tamIcon=24)
        # Grid engine
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("WHITE", _("White"), 190, siCentrado=True)
        oColumnas.nueva("BLACK", _("Black"), 190, siCentrado=True)
        oColumnas.nueva("RESULT", _("Result"), 190, siCentrado=True)
        oColumnas.nueva("TIEMPO", _("Time"), 170, siCentrado=True)
        self.gridGames = Grid.Grid(self,
                                   oColumnas,
                                   siSelecFilas=True,
                                   xid="G",
                                   siSeleccionMultiple=True)
        self.registrarGrid(self.gridGames)
        # Layout
        layout = Colocacion.V().control(tbEnG).control(self.gridGames)

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

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

        # Grid
        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("NUMERO", _("N."), 35, siCentrado=True)
        oColumnas.nueva("MOTOR", _("Engine"), 190, siCentrado=True)
        oColumnas.nueva("GANADOS", _("Wins"), 120, siCentrado=True)
        oColumnas.nueva("TABLAS", _("Draws"), 120, siCentrado=True)
        oColumnas.nueva("PERDIDOS", _("Losses"), 120, siCentrado=True)
        oColumnas.nueva("PUNTOS", _("Points"), 120, siCentrado=True)
        self.gridResult = Grid.Grid(self,
                                    oColumnas,
                                    siSelecFilas=True,
                                    xid="R")
        self.registrarGrid(self.gridResult)
        # Layout
        layout = Colocacion.V().control(self.gridResult)

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

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

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

        self.gridEnginesAlias.gotop()

        self.edNombre.setFocus()

        self.muestraPosicion()
コード例 #20
0
    def __init__(self, procesador, titulo, direct_option):

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

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

        self.direct_option = direct_option

        self.setFont(font)

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

        self.personalidades = Personalities.Personalities(self, self.configuration)

        self.motores = SelectEngines.SelectEngines(self.configuration)

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

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

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

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

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

        gb_style = Common.gb_style()

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

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

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

        lyG = nuevoG()

        # # Motores

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

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

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

        ly = Colocacion.G()
        ly.controld(lbTiempoSegundosR, 0, 0).otro(ly_tiempo, 0, 1)
        ly.controld(lb_depth, 1, 0).otro(ly_depth, 1, 1)
        self.gb_thinks = Controles.GB(self, _("Limits of engine thinking"), ly)
        self.gb_thinks.setStyleSheet(
            """
            QGroupBox {
                font: bold %d;
                background-color: #F2F2EC;/*qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);*/
                border: 1px solid gray;
                border-radius: 3px;
                padding: 18px;
                margin-top: 5ex; /* leave space at the top for the title */
            }
            QGroupBox::title {
                subcontrol-position: top center; /* position at the top center */
                padding: 8px;
                border: 1px solid gray;
             }
        """
            % procesador.configuration.x_menu_points
        )
        lyV = Colocacion.V().espacio(20).control(self.btRival).espacio(20).control(self.gb_thinks)

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

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

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

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

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

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

        liThinks = [(_("Nothing"), -1), (_("Score"), 0)]
        for i in range(1, 5):
            liThinks.append(("%d %s" % (i, _("ply") if i == 1 else _("plies")), i))
        liThinks.append((_("All"), 9999))
        lbThoughtTt = Controles.LB(self, _("It is showed") + ":").ponFuente(font)
        self.cbThoughtTt = Controles.CB(self, liThinks, -1).ponFuente(font)

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

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

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

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

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

        self.lbBoxHeight = Controles.LB2P(self, "%s (\"%s\")" %(_("Box height"), _("It is showed"))).ponFuente(font)
        self.sbBoxHeight = Controles.SB(self, 7, 0, 999).tamMaximo(50).ponFuente(font)

        lyBox = Colocacion.H().control(self.lbBoxHeight).control(self.sbBoxHeight).relleno()

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

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

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

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

        nueva_tab(lyG, _("Time"))

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

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

        # Openings
        self.btOpening = (
            Controles.PB(self, " " * 5 + _("Undetermined") + " " * 5, self.editOpening)
            .ponPlano(False)
            .ponFuente(font)
        )
        self.opening_block = None
        self.btOpeningsFavoritas = Controles.PB(self, "", self.preferred_openings).ponIcono(Iconos.Favoritos())
        self.btOpeningsQuitar = Controles.PB(self, "", self.aperturasQuitar).ponIcono(Iconos.Motor_No())
        hbox = (
            Colocacion.H()
            .relleno()
            .control(self.btOpeningsQuitar)
            .control(self.btOpening)
            .control(self.btOpeningsFavoritas)
            .relleno()
        )
        _label(lyG, _("Opening"), hbox)

        # Libros
        fvar = self.configuration.file_books
        self.list_books = Books.ListBooks()
        self.list_books.restore_pickle(fvar)
        self.list_books.check()

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

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

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

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

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

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

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

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

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

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

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

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

        nueva_tab(lyG, _("Advanced"))

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

        self.setLayout(layout)

        self.li_preferred_openings = []
        self.btOpeningsFavoritas.hide()

        file = self.configuration.ficheroEntMaquina if self.direct_option else self.configuration.ficheroEntMaquinaPlay
        if not os.path.isfile(file):
            file = self.configuration.ficheroEntMaquina
        dic = Util.restore_pickle(file)
        if not dic:
            dic = {}
        self.restore_dic(dic)

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

        self.restore_video()
コード例 #21
0
    def __init__(self, owner, game, configuration):
        titulo = _("Save to PGN")
        icono = Iconos.PGN()
        extparam = "savepgn"
        QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam)

        self.game = game
        self.game.order_tags()
        self.body = self.game.pgnBase()
        if self.game.opening:
            if not self.game.get_tag("ECO"):
                self.game.set_tag("ECO", self.game.opening.eco)
            if not self.game.get_tag("Opening"):
                self.game.set_tag("Opening", self.game.opening.trNombre)

        self.li_labels = [[k, v] for k, v in self.game.li_tags]
        self.configuration = configuration
        self.file = ""
        self.vars_read()

        f = Controles.TipoLetra(puntos=configuration.x_pgn_fontpoints)

        # Opciones
        li_options = [
            (_("Save"), Iconos.GrabarFichero(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.terminar),
            None,
            (_("Clipboard"), Iconos.Clipboard(), self.portapapeles),
            None,
            (_("Reinit"), Iconos.Reiniciar(), self.reinit),
            None,
        ]
        tb = QTVarios.LCTB(self, li_options)

        tabs = Controles.Tab(self)
        tabs.ponFuente(f)

        # Tab-file -----------------------------------------------------------------------------------------------
        lb_file = Controles.LB(self, _("File to save") + ": ").ponFuente(f)
        bt_history = Controles.PB(self, "", self.history).ponIcono(
            Iconos.Favoritos(), 24).ponToolTip(_("Previous")).ponFuente(f)
        bt_boxrooms = (Controles.PB(self, "", self.boxrooms).ponIcono(
            Iconos.BoxRooms(), 24).ponToolTip(_("Boxrooms PGN")))
        self.bt_file = Controles.PB(self, "", self.file_select,
                                    plano=False).anchoMinimo(300).ponFuente(f)

        # Codec
        lb_codec = Controles.LB(self, _("Encoding") + ": ").ponFuente(f)
        liCodecs = [
            k for k in set(v for k, v in encodings.aliases.aliases.items())
        ]
        liCodecs.sort()
        liCodecs = [(k, k) for k in liCodecs]
        liCodecs.insert(0, (_("Same as file"), "file"))
        liCodecs.insert(0,
                        ("%s: %s" % (_("By default"), _("UTF-8")), "default"))
        self.cb_codecs = Controles.CB(self, liCodecs, self.codec).ponFuente(f)

        # Rest
        self.chb_overwrite = Controles.CHB(self, _("Overwrite"),
                                           False).ponFuente(f)
        self.chb_remove_c_v = Controles.CHB(
            self, _("Remove comments and variations"),
            self.remove_c_v).ponFuente(f)

        lyF = Colocacion.H().control(lb_file).control(
            self.bt_file).control(bt_history).control(bt_boxrooms).relleno(1)
        lyC = Colocacion.H().control(lb_codec).control(
            self.cb_codecs).relleno(1)
        ly = (Colocacion.V().espacio(15).otro(lyF).otro(lyC).control(
            self.chb_overwrite).control(self.chb_remove_c_v).relleno(1))
        w = QtWidgets.QWidget()
        w.setLayout(ly)
        tabs.nuevaTab(w, _("File"))
        self.chb_overwrite.hide()

        # Tab-labels -----------------------------------------------------------------------------------------------
        liAccionesWork = (
            ("", Iconos.Mas22(), self.labels_more),
            None,
            ("", Iconos.Menos22(), self.labels_less),
            None,
            ("", Iconos.Arriba(), self.labels_up),
            None,
            ("", Iconos.Abajo(), self.labels_down),
            None,
        )
        tb_labels = Controles.TBrutina(self,
                                       liAccionesWork,
                                       icon_size=16,
                                       with_text=False)

        # Lista
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("ETIQUETA",
                        _("Label"),
                        150,
                        edicion=Delegados.LineaTextoUTF8())
        o_columns.nueva("VALOR",
                        _("Value"),
                        420,
                        edicion=Delegados.LineaTextoUTF8())

        self.grid_labels = Grid.Grid(self, o_columns, siEditable=True)
        self.grid_labels.ponFuente(f)
        n = self.grid_labels.anchoColumnas()
        self.grid_labels.setFixedWidth(n + 20)

        # Layout
        ly = Colocacion.V().control(tb_labels).control(
            self.grid_labels).margen(3)
        w = QtWidgets.QWidget()
        w.setLayout(ly)
        tabs.nuevaTab(w, _("Labels"))

        # Tab-Body -----------------------------------------------------------------------------------------------
        self.em_body = Controles.EM(self, self.body, siHTML=False).ponFuente(f)
        tabs.nuevaTab(self.em_body, _("Body"))

        layout = Colocacion.V().control(tb).control(tabs)

        self.setLayout(layout)

        if self.history_list:
            fich = self.history_list[0]
            if os.path.isfile(fich):
                self.file = fich
                self.show_file()

        self.register_grid(self.grid_labels)
        self.restore_video()
コード例 #22
0
    def __init__(self, procesador):

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

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

        self.position = Position.Position()
        self.position.set_pos_initial()

        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.game = None

        # Toolbar
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("External engines"), Iconos.Motores(), self.ext_engines),
            None,
        )
        tb = QTVarios.LCTB(self, li_acciones)

        # 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.config_board("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.items())
        ]
        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
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("LABEL",
                        _("Label"),
                        80,
                        edicion=Delegados.LineaTextoUTF8(),
                        centered=True)
        o_columns.nueva("VALUE",
                        _("Value"),
                        280,
                        edicion=Delegados.LineaTextoUTF8())
        self.grid_labels = Grid.Grid(self, o_columns, siEditable=True, xid=1)
        n = self.grid_labels.anchoColumnas()
        self.grid_labels.setFixedWidth(n + 20)
        self.register_grid(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.comboMotores()
        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)
        ##
        o_columns = Columnas.ListaColumnas()
        o_columns.nueva("PDT", _("Evaluation"), 100, centered=True)
        o_columns.nueva("PGN", _("Solution"), 360)
        self.grid_analysis = Grid.Grid(self, o_columns, siSelecFilas=True)
        self.register_grid(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 = QtWidgets.QSplitter(self)
        splitter_right.setOrientation(QtCore.Qt.Vertical)
        splitter_right.addWidget(gb_files)
        splitter_right.addWidget(gb_labels)
        splitter_right.addWidget(gb_analysis)

        self.register_splitter(splitter_right, "RIGHT")
        ##
        splitter = QtWidgets.QSplitter(self)
        splitter.addWidget(gb_left)
        splitter.addWidget(splitter_right)

        self.register_splitter(splitter, "ALL")

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

        self.setLayout(layout)

        self.inicializa()
コード例 #23
0
    def __init__(self, procesador, mapa):
        self.workmap = WorkMap.WorkMap(mapa)
        dic = TrListas.maps()
        titulo = dic[mapa]
        icono = getattr(Iconos, mapa)()

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

        self.procesador = procesador

        self.playCurrent = None

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("TIPO",
                        "",
                        24,
                        edicion=Delegados.PmIconosBMT(),
                        siCentrado=True)
        oColumnas.nueva("SELECT", _("Select one to play"), 150)

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

        self.registrarGrid(self.grid)

        liAcciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Play"), Iconos.Empezar(), self.play),
            None,
        )
        tbWork = QTVarios.LCTB(self, liAcciones, tamIcon=24)

        self.lbInfo = Controles.LB(self)

        self.wsvg = wsvg = QtSvg.QSvgWidget()
        p = wsvg.palette()
        p.setColor(wsvg.backgroundRole(), QtGui.QColor("#F5F5F5"))
        wsvg.setPalette(p)

        ly = Colocacion.V().control(tbWork).control(self.lbInfo).control(
            self.grid)
        w = QtGui.QWidget()
        w.setLayout(ly)

        splitter = QtGui.QSplitter(self)
        splitter.addWidget(w)
        splitter.addWidget(wsvg)
        self.registrarSplitter(splitter, "splitter")

        oColumnas = Columnas.ListaColumnas()
        oColumnas.nueva("ACTIVE", _("Active"), 80, siCentrado=True)
        oColumnas.nueva("TIPO", _("Type"), 110, siCentrado=True)
        oColumnas.nueva("DCREATION", _("Creation date"), 110, siCentrado=True)
        oColumnas.nueva("DONE", _("Done"), 110, siCentrado=True)
        oColumnas.nueva("DEND", _("Ending date"), 110, siCentrado=True)
        oColumnas.nueva("RESULT", _("Result"), 110, siCentrado=True)

        self.gridData = Grid.Grid(self, oColumnas, siSelecFilas=True, xid="H")
        self.registrarGrid(self.gridData)

        liAcciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Select"), Iconos.Seleccionar(), self.data_select),
            None,
            (_("New"), Iconos.NuevoMas(), self.data_new),
            None,
            (_("Remove"), Iconos.Borrar(), self.data_remove),
            None,
        )
        tb = QTVarios.LCTB(self, liAcciones, tamIcon=24)

        ly = Colocacion.V().control(tb).control(self.gridData)
        w = QtGui.QWidget()
        w.setLayout(ly)

        self.tab = Controles.Tab()
        self.tab.ponPosicion("W")
        self.tab.nuevaTab(splitter, _("Map"))
        self.tab.nuevaTab(w, _("Data"))

        ly = Colocacion.H().control(self.tab).margen(0)
        self.setLayout(ly)

        self.recuperarVideo(siTam=True, anchoDefecto=960, altoDefecto=600)

        self.workmap.setWidget(wsvg)
        self.workmap.resetWidget()
        self.grid.gotop()
        self.gridData.gotop()

        self.informacion()
コード例 #24
0
    def __init__(self, procesador, wb_database, dbGames, wsummary, si_select):
        QtWidgets.QWidget.__init__(self)

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

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

        self.si_select = si_select

        self.terminado = False  # singleShot

        self.ap = AperturasStd.ap

        self.liFiltro = []
        self.where = None

        self.last_opening = None

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

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

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

            ]

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

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

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

        self.setLayout(layout)
コード例 #25
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)
コード例 #26
0
    def __init__(self, owner, configuracion, dic_data):
        super(WOptionsDatabase, self).__init__(owner)

        self.new = len(dic_data) == 0

        self.dic_data = dic_data
        self.dic_data_resp = None

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

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

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

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

        self.configuracion = configuracion
        self.resultado = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        x0 = 16

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

        self.setLayout(layout)

        self.ed_name.setFocus()
コード例 #27
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))
コード例 #28
0
    def __init__(self, owner, db_captures, capture):

        QTVarios.WDialogo.__init__(self, owner,
                                   _("Captures and threats in a game"),
                                   Iconos.Captures(), "runcaptures")

        self.configuration = Code.configuration
        self.capture = capture
        self.db_captures = db_captures

        conf_board = self.configuration.config_board("RUNCAPTURES", 64)

        self.board = Board.BoardEstaticoMensaje(self, conf_board, None)
        self.board.crea()

        # Rotulo informacion
        self.lb_info_game = Controles.LB(
            self,
            self.capture.game.titulo(
                "DATE", "EVENT", "WHITE", "BLACK", "RESULT")).ponTipoLetra(
                    puntos=self.configuration.x_pgn_fontpoints)

        # Movimientos
        self.liwm_captures = []
        ly = Colocacion.G().margen(4)
        for i in range(16):
            f = i // 2
            c = i % 2
            wm = WRunCommon.WEdMove(self)
            self.liwm_captures.append(wm)
            ly.control(wm, f, c)

        self.gb_captures = Controles.GB(self, _("Captures"), ly).ponFuente(
            Controles.TipoLetra(puntos=10, peso=750))

        self.liwm_threats = []
        ly = Colocacion.G().margen(4)
        for i in range(16):
            f = i // 2
            c = i % 2
            wm = WRunCommon.WEdMove(self)
            self.liwm_threats.append(wm)
            ly.control(wm, f, c)

        self.gb_threats = Controles.GB(self, _("Threats"), ly).ponFuente(
            Controles.TipoLetra(puntos=10, peso=750))

        self.lb_result = Controles.LB(self).ponTipoLetra(
            puntos=10, peso=500).anchoFijo(254).altoFijo(32).set_wrap()
        self.lb_info = (
            Controles.LB(self).anchoFijo(254).set_foreground_backgound(
                "white", "#496075").align_center().ponTipoLetra(puntos=14,
                                                                peso=500))

        # Botones
        li_acciones = (
            (_("Close"), Iconos.MainMenu(), self.terminar),
            None,
            (_("Begin"), Iconos.Empezar(), self.begin),
            (_("Check"), Iconos.Check(), self.check),
            (_("Continue"), Iconos.Pelicula_Seguir(), self.seguir),
        )
        self.tb = QTVarios.LCTB(self,
                                li_acciones,
                                style=QtCore.Qt.ToolButtonTextBesideIcon,
                                icon_size=32)
        self.show_tb(self.terminar, self.begin)

        ly_right = (Colocacion.V().control(self.tb).controlc(
            self.lb_info).relleno().control(
                self.gb_captures).relleno().control(self.gb_threats).control(
                    self.lb_result).relleno())

        ly_center = Colocacion.H().control(self.board).otro(ly_right)

        ly = Colocacion.V().otro(ly_center).control(
            self.lb_info_game).margen(3)

        self.setLayout(ly)

        self.restore_video()
        self.adjustSize()

        # Tiempo
        self.time_base = time.time()

        self.gb_captures.setDisabled(True)
        self.gb_threats.setDisabled(True)

        self.liwm_captures[0].activa()

        self.ultimaCelda = None

        self.pon_info_posic()
        self.set_position()