Beispiel #1
0
def cambiaColoresPGN(ventana, configuracion):
    liGen = [(None, None)]

    dicNAGs = TrListas.dicNAGs()
    config = FormLayout.Colorbox(dicNAGs[1], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag1))

    config = FormLayout.Colorbox(dicNAGs[2], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag2))

    config = FormLayout.Colorbox(dicNAGs[3], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag3))

    config = FormLayout.Colorbox(dicNAGs[4], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag4))

    config = FormLayout.Colorbox(dicNAGs[5], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag5))

    config = FormLayout.Colorbox(dicNAGs[6], 80, 20, siSTR=True)
    liGen.append((config, configuracion.color_nag6))

    resultado = FormLayout.fedit(liGen,
                                 title=_("PGN"),
                                 parent=ventana,
                                 icon=Iconos.Vista(),
                                 siDefecto=True)
    if resultado:
        accion, liResp = resultado
        if accion == "defecto":
            configuracion.coloresPGNdefecto()
            configuracion.graba()
            cambiaColoresPGN(ventana, configuracion)
        else:
            configuracion.color_nag1 = liResp[0]
            configuracion.color_nag2 = liResp[1]
            configuracion.color_nag3 = liResp[2]
            configuracion.color_nag4 = liResp[3]
            configuracion.color_nag5 = liResp[4]
            configuracion.color_nag6 = liResp[5]
            configuracion.graba()
    def __init__(self, owner, regFlecha, siNombre):

        QtGui.QDialog.__init__(self, owner)

        self.setWindowTitle(_("Arrow"))
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.siNombre = siNombre

        if not regFlecha:
            regFlecha = TabVisual.PFlecha()

        liAcciones = [
            (_("Save"), Iconos.Aceptar(), "grabar"),
            None,
            (_("Cancel"), Iconos.Cancelar(), "reject"),
            None,
        ]
        tb = Controles.TB(self, liAcciones)

        # Tablero
        confTablero = owner.tablero.confTablero.copia(
            owner.tablero.confTablero.id())
        confTablero.anchoPieza(32)
        self.tablero = Tablero.TableroVisual(self, confTablero)
        self.tablero.crea()
        self.tablero.copiaPosicionDe(owner.tablero)

        # Datos generales
        liGen = []

        if siNombre:
            # nombre de la flecha que se usara en los menus del tutorial
            config = FormLayout.Editbox(_("Name"), ancho=120)
            liGen.append((config, regFlecha.nombre))

        # ( "forma", "t", "a" ), # a = abierta -> , c = cerrada la cabeza, p = poligono cuadrado,
        liFormas = (
            (_("Opened"), "a"),
            (_("Head closed"), "c"),
            (_("Polygon  1"), "1"),
            (_("Polygon  2"), "2"),
            (_("Polygon  3"), "3"),
        )
        config = FormLayout.Combobox(_("Form"), liFormas)
        liGen.append((config, regFlecha.forma))

        # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine
        config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas())
        liGen.append((config, regFlecha.tipo))

        # liGen.append( (None,None) )

        # ( "color", "n", 0 ),
        config = FormLayout.Colorbox(_("Color"), 80, 20)
        liGen.append((config, regFlecha.color))

        # ( "colorinterior", "n", -1 ), # si es cerrada
        config = FormLayout.Colorbox(_("Internal color"),
                                     80,
                                     20,
                                     siChecked=True)
        liGen.append((config, regFlecha.colorinterior))

        # ( "opacidad", "n", 1.0 ),
        config = FormLayout.Dial(_("Degree of transparency"), 0, 99)
        liGen.append((config, 100 - int(regFlecha.opacidad * 100)))

        # liGen.append( (None,None) )

        # ( "redondeos", "l", False ),
        liGen.append((_("Rounded edges"), regFlecha.redondeos))

        # ( "grosor", "n", 1 ), # ancho del trazo
        config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50)
        liGen.append((config, regFlecha.grosor))

        # liGen.append( (None,None) )

        # ( "altocabeza", "n", 1 ), # altura de la cabeza
        config = FormLayout.Spinbox(_("Head height"), 0, 100, 50)
        liGen.append((config, regFlecha.altocabeza))

        # ( "ancho", "n", 10 ), # ancho de la base de la flecha si es un poligono
        config = FormLayout.Spinbox(_("Base width"), 1, 100, 50)
        liGen.append((config, regFlecha.ancho))

        # ( "vuelo", "n", 5 ), # vuelo de la flecha respecto al ancho de la base
        config = FormLayout.Spinbox(
            _("Additional width of the base of the head"), 1, 100, 50)
        liGen.append((config, regFlecha.vuelo))

        # ( "descuelgue", "n", 2 ), # vuelo hacia arriba
        config = FormLayout.Spinbox(_("Height of the base angle of the head"),
                                    -100, 100, 50)
        liGen.append((config, regFlecha.descuelgue))

        # liGen.append( (None,None) )

        # ( "destino", "t", "c" ), # c = centro, m = minimo
        config = FormLayout.Combobox(_("Target position"), tiposDestino())
        liGen.append((config, regFlecha.destino))

        # liGen.append( (None,None) )

        # orden
        config = FormLayout.Combobox(_("Order concerning other items"),
                                     QTUtil2.listaOrdenes())
        liGen.append((config, regFlecha.posicion.orden))

        self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios)

        # Layout
        layout = Colocacion.H().control(self.form).relleno().control(
            self.tablero)
        layout1 = Colocacion.V().control(tb).otro(layout)
        self.setLayout(layout1)

        # Ejemplos
        liMovs = ["d2d6", "a8h8", "h5b7"]
        self.liEjemplos = []
        for a1h8 in liMovs:
            regFlecha.a1h8 = a1h8
            regFlecha.siMovible = True
            flecha = self.tablero.creaFlecha(regFlecha)
            self.liEjemplos.append(flecha)
Beispiel #3
0
 def xcolor(txt, tipo):
     config = FormLayout.Colorbox( txt, 40, 20, siSTR=True)
     color = QtGui.QColor(palette[tipo]) if palette else palette_std.color(getattr(QtGui.QPalette, tipo))
     liColor.append((config, color))
     liPalette.append(tipo)
Beispiel #4
0
def cambiaColores(parent, configuracion):
    separador = (None, None)

    liColor = []
    liColor.append(separador)
    liColor.append((_("By default") + ":", False))
    liColor.append(separador)

    palette = configuracion.palette
    palette_std = QtGui.QApplication.style().standardPalette()

    liPalette = []
    def xcolor(txt, tipo):
        config = FormLayout.Colorbox( txt, 40, 20, siSTR=True)
        color = QtGui.QColor(palette[tipo]) if palette else palette_std.color(getattr(QtGui.QPalette, tipo))
        liColor.append((config, color))
        liPalette.append(tipo)

    xcolor(_("General background"), "Window")
    xcolor(_("General foreground"), "WindowText")
    liColor.append(separador)
    xcolor(_("Text entry background"), "Base")
    xcolor(_("Text entry foreground"), "Text")
    xcolor(_("Alternate background"), "AlternateBase")
    liColor.append(separador)
    xcolor(_("Tool tip background"), "ToolTipBase")
    xcolor(_("Tool tip foreground"), "ToolTipText")
    liColor.append(separador)
    xcolor(_("Button background"), "Button")
    xcolor(_("Button foreground"), "ButtonText")
    xcolor(_("Bright text"), "BrightText")
    liColor.append(separador)
    xcolor(_("Links"), "Link")

    # QtGui.QPalette.Window	10	A general background color.
    # QtGui.QPalette.WindowText	0	A general foreground color.
    # QtGui.QPalette.Base	9	Used mostly as the background color for text entry widgets, but can also be used for other painting - such as the background of combobox drop down lists and toolbar handles. It is usually white or another light color.
    # QtGui.QPalette.AlternateBase	16	Used as the alternate background color in views with alternating row colors (see QAbstractItemView::setAlternatingRowColors()).
    # QtGui.QPalette.ToolTipBase	18	Used as the background color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
    # QtGui.QPalette.ToolTipText	19	Used as the foreground color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
    # QtGui.QPalette.Text	6	The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.
    # QtGui.QPalette.Button	1	The general button background color. This background can be different from Window as some styles require a different background color for buttons.
    # QtGui.QPalette.ButtonText	8	A foreground color used with the Button color.
    # QtGui.QPalette.BrightText	7	A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text or WindowText would give poor contrast, such as on pressed push buttons. Note that text colors can be used for things other than just words; text colors are usually used for text, but it's quite common to use the text color roles for lines, icons, etc.

    liPGN = []
    liPGN.append(separador)
    liPGN.append((_("By default") + ":", False))
    liPGN.append(separador)

    dicNAGs = TrListas.dicNAGs()
    config = FormLayout.Colorbox(dicNAGs[1], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag1))

    config = FormLayout.Colorbox(dicNAGs[2], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag2))

    config = FormLayout.Colorbox(dicNAGs[3], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag3))

    config = FormLayout.Colorbox(dicNAGs[4], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag4))

    config = FormLayout.Colorbox(dicNAGs[5], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag5))

    config = FormLayout.Colorbox(dicNAGs[6], 40, 20, siSTR=True)
    liPGN.append((config, configuracion.color_nag6))

    liTables = []
    liTables.append(separador)
    liTables.append((_("By default") + ":", False))
    liTables.append(separador)

    liTables.append((None, _("Selected row")))
    config = FormLayout.Colorbox(_("Background"), 40, 20, siSTR=True)
    color = "#678DB2" if configuracion.tablaSelBackground is None else configuracion.tablaSelBackground
    liTables.append((config, color))

    lista = []
    lista.append((liColor, _("Windows"), ""))
    lista.append((liPGN, _("PGN"), ""))
    lista.append((liTables, _("Tables"), ""))

    # Editamos
    resultado = FormLayout.fedit(lista, title=_("Colors"), parent=parent, anchoMinimo=240, icon=Iconos.Opciones())

    if resultado:
        accion, resp = resultado

        liColor, liPGN, liTables = resp

        if liColor[0]:
            palette = None
        else:
            palette = {}
            for n, tipo in enumerate(liPalette):
                palette[tipo] = liColor[n+1]
        configuracion.palette = palette

        if liPGN[0]:
            configuracion.coloresPGNdefecto()
        else:
            (configuracion.color_nag1, configuracion.color_nag2, configuracion.color_nag3,
             configuracion.color_nag4, configuracion.color_nag5, configuracion.color_nag6) = liPGN[1:]

        if liTables[0]:
            configuracion.tablaSelBackground = None
        else:
            configuracion.tablaSelBackground = liTables[1]

        configuracion.graba()

        return True
    else:
        return False
    def __init__(self, owner, regMarco):

        QtWidgets.QDialog.__init__(self, owner)

        self.setWindowTitle(_("Box"))
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        if not regMarco:
            regMarco = TabVisual.PMarco()

        liAcciones = [
            (_("Save"), Iconos.Aceptar(), "grabar"),
            None,
            (_("Cancel"), Iconos.Cancelar(), "reject"),
            None,
        ]
        tb = Controles.TB(self, liAcciones)

        # Tablero
        confTablero = owner.tablero.confTablero
        self.tablero = Tablero.Tablero(self, confTablero, siDirector=False)
        self.tablero.crea()
        self.tablero.copiaPosicionDe(owner.tablero)

        # Datos generales
        liGen = []

        # nombre del marco que se usara en los menus del tutorial
        config = FormLayout.Editbox(_("Name"), ancho=120)
        liGen.append((config, regMarco.nombre))

        # ( "tipo", "n", Qt.SolidLine ), #1=SolidLine, 2=DashLine, 3=DotLine, 4=DashDotLine, 5=DashDotDotLine
        config = FormLayout.Combobox(_("Line Type"), QTUtil2.tiposDeLineas())
        liGen.append((config, regMarco.tipo))

        # ( "color", "n", 0 ),
        config = FormLayout.Colorbox(_("Color"), 80, 20)
        liGen.append((config, regMarco.color))

        # ( "colorinterior", "n", -1 ),
        config = FormLayout.Colorbox(_("Internal color"),
                                     80,
                                     20,
                                     siChecked=True)
        liGen.append((config, regMarco.colorinterior))

        # ( "opacidad", "n", 1.0 ),
        config = FormLayout.Dial(_("Degree of transparency"), 0, 99)
        liGen.append((config, 100 - int(regMarco.opacidad * 100)))

        # ( "grosor", "n", 1 ), # ancho del trazo
        config = FormLayout.Spinbox(_("Thickness"), 1, 20, 50)
        liGen.append((config, regMarco.grosor))

        # ( "redEsquina", "n", 0 ),
        config = FormLayout.Spinbox(_("Rounded corners"), 0, 100, 50)
        liGen.append((config, regMarco.redEsquina))

        # orden
        config = FormLayout.Combobox(_("Order concerning other items"),
                                     QTUtil2.listaOrdenes())
        liGen.append((config, regMarco.posicion.orden))

        self.form = FormLayout.FormWidget(liGen, dispatch=self.cambios)

        # Layout
        layout = Colocacion.H().control(self.form).relleno().control(
            self.tablero)
        layout1 = Colocacion.V().control(tb).otro(layout)
        self.setLayout(layout1)

        # Ejemplos
        liMovs = ["b4c4", "e2e2", "e4g7"]
        self.liEjemplos = []
        for a1h8 in liMovs:
            regMarco.a1h8 = a1h8
            regMarco.siMovible = True
            marco = self.tablero.creaMarco(regMarco)
            self.liEjemplos.append(marco)