Exemplo n.º 1
0
    def __init__(self, wowner, configuracion, with_remcomments=False):
        QtWidgets.QWidget.__init__(self, wowner)

        self.wowner = wowner
        self.file = ""
        self.configuracion = configuracion
        self.with_remcomments = with_remcomments
        self.vars_read()

        lb_file = Controles.LB(self, _("File to save") + ": ")
        bt_history = Controles.PB(self, "", self.history).ponIcono(
            Iconos.Favoritos(), 24).ponToolTip(_("Previous"))
        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)

        # 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, (_("Same as file"), "file"))
        liCodecs.insert(0,
                        ("%s: %s" % (_("By default"), _("UTF-8")), "default"))
        self.cb_codecs = Controles.CB(self, liCodecs, self.codec)

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

        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)
        if with_remcomments:
            ly.control(self.chb_remove_c_v)
        ly.relleno(1)

        self.chb_overwrite.hide()

        self.setLayout(ly)
Exemplo n.º 2
0
    def create_toolbar(self):
        self.tb = QtWidgets.QToolBar("BASIC", self)
        iconsTB = self.configuration.tipoIconos()
        self.tb.setToolButtonStyle(iconsTB)
        sz = 32 if iconsTB == QtCore.Qt.ToolButtonTextUnderIcon else 16
        self.tb.setIconSize(QtCore.QSize(sz, sz))
        style = "QToolBar {border-bottom: 1px solid gray; border-top: 1px solid gray;}"
        self.tb.setStyleSheet(style)
        # sp = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtGui, QtWidgets.QSizePolicy.Expanding)
        # self.tb.setSizePolicy(sp)
        self.tb.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.tb.customContextMenuRequested.connect(self.lanzaAtajos)

        self.dic_toolbar = {}

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

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

        for key, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.key = key
            self.dic_toolbar[key] = accion
Exemplo n.º 3
0
    def __init__(self, owner, game, configuracion):
        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()
        self.li_labels = self.game.li_tags
        self.configuracion = configuracion
        self.file = ""
        self.vars_read()

        # 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)

        # Tab-fichero -----------------------------------------------------------------------------------------------
        lb_file = Controles.LB(self, _("File to save") + ": ")
        bt_history = Controles.PB(self, "", self.history).ponIcono(
            Iconos.Favoritos(), 24).ponToolTip(_("Previous"))
        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)

        # 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, (_("Same as file"), "file"))
        liCodecs.insert(0,
                        ("%s: %s" % (_("By default"), _("UTF-8")), "default"))
        self.cb_codecs = Controles.CB(self, liCodecs, self.codec)

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

        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,
                                       tamIcon=16,
                                       siTexto=False)

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

        self.grid_labels = Grid.Grid(self, o_columns, siEditable=True)
        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)
        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()
Exemplo n.º 4
0
    def preparaTB(self):
        self.dicTB = {}

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

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

        for clave, (titulo, icono) in dic_opciones.items():
            accion = QtWidgets.QAction(titulo, None)
            accion.setIcon(icono)
            accion.setIconText(titulo)
            accion.setFont(font)
            accion.triggered.connect(self.run_action)
            accion.clave = clave
            self.dicTB[clave] = accion