Exemple #1
0
def set_maya_palette():
    """Apply maya palette.

    This allows interfaces outside maya to use the same colouring.
    """
    _base_palette = QtGui.QPalette()

    _base_palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(MID_COLOR))
    _base_palette.setBrush(QtGui.QPalette.WindowText, QtGui.QBrush(TEXT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Foreground,
                           QtGui.QBrush(BRIGHT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Base, QtGui.QBrush(DARK_COLOR))
    _base_palette.setBrush(QtGui.QPalette.AlternateBase,
                           QtGui.QBrush(ALTERNATE_BASE_COLOR))
    _base_palette.setBrush(QtGui.QPalette.ToolTipBase,
                           QtGui.QBrush(BASE_COLOR))
    _base_palette.setBrush(QtGui.QPalette.ToolTipText,
                           QtGui.QBrush(TEXT_COLOR))

    _base_palette.setBrush(QtGui.QPalette.Text, QtGui.QBrush(TEXT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text,
                           QtGui.QBrush(DISABLED_TEXT_COLOR))

    _base_palette.setBrush(QtGui.QPalette.Button, QtGui.QBrush(LIGHT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button,
                           QtGui.QBrush(DISABLED_BUTTON_COLOR))
    _base_palette.setBrush(QtGui.QPalette.ButtonText, QtGui.QBrush(TEXT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText,
                           QtGui.QBrush(DISABLED_TEXT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.BrightText, QtGui.QBrush(TEXT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText,
                           QtGui.QBrush(DISABLED_TEXT_COLOR))

    _base_palette.setBrush(QtGui.QPalette.Light, QtGui.QBrush(LIGHT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Midlight,
                           QtGui.QBrush(MID_LIGHT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Mid, QtGui.QBrush(MID_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Dark, QtGui.QBrush(DARK_COLOR))
    _base_palette.setBrush(QtGui.QPalette.Shadow, QtGui.QBrush(SHADOW_COLOR))

    _base_palette.setBrush(QtGui.QPalette.Highlight,
                           QtGui.QBrush(HIGHLIGHT_COLOR))
    _base_palette.setBrush(QtGui.QPalette.HighlightedText,
                           QtGui.QBrush(HIGHLIGHTEDTEXT_COLOR))

    # Setup additional palettes for QTabBar and QTabWidget to look more like
    # maya.
    _tab_palette = QtGui.QPalette(_base_palette)
    _tab_palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(LIGHT_COLOR))
    _tab_palette.setBrush(QtGui.QPalette.Button, QtGui.QBrush(MID_COLOR))

    _widget_palettes = {}
    _widget_palettes["QTabBar"] = _tab_palette
    _widget_palettes["QTabWidget"] = _tab_palette

    QtWidgets.QApplication.setStyle("Plastique")
    QtWidgets.QApplication.setPalette(_base_palette)
    for _name, _palette in _widget_palettes.items():
        QtWidgets.QApplication.setPalette(_palette, _name)
Exemple #2
0
    def set_col(self, col):
        """Set colour for this progress bar.

        Args:
            col (str): colour to apply
        """
        _col = get_col(col)
        _palette = QtGui.QPalette()
        _brush = QtGui.QBrush(_col)
        for _state in [QtGui.QPalette.Active, QtGui.QPalette.Inactive]:
            _palette.setBrush(_state, QtGui.QPalette.Highlight, _brush)
        self.setPalette(_palette)