Last active
March 13, 2020 18:28
-
-
Save tm8r/d8093f96cf0b01dd4bf209674f3196f1 to your computer and use it in GitHub Desktop.
Extract QColor from Maya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Qt import QtGui | |
from Qt import QtWidgets | |
app = QtWidgets.QApplication.instance() | |
palette = app.palette() | |
roles = [ | |
QtGui.QPalette.ColorRole.WindowText, | |
QtGui.QPalette.ColorRole.Foreground, | |
QtGui.QPalette.ColorRole.Button, | |
QtGui.QPalette.ColorRole.Light, | |
QtGui.QPalette.ColorRole.Midlight, | |
QtGui.QPalette.ColorRole.Dark, | |
QtGui.QPalette.ColorRole.Mid, | |
QtGui.QPalette.ColorRole.Text, | |
QtGui.QPalette.ColorRole.BrightText, | |
QtGui.QPalette.ColorRole.ButtonText, | |
QtGui.QPalette.ColorRole.Base, | |
QtGui.QPalette.ColorRole.Window, | |
QtGui.QPalette.ColorRole.Background, | |
QtGui.QPalette.ColorRole.Shadow, | |
QtGui.QPalette.ColorRole.Highlight, | |
QtGui.QPalette.ColorRole.HighlightedText, | |
QtGui.QPalette.ColorRole.Link, | |
QtGui.QPalette.ColorRole.LinkVisited, | |
QtGui.QPalette.ColorRole.AlternateBase, | |
QtGui.QPalette.ColorRole.ToolTipBase, | |
QtGui.QPalette.ColorRole.ToolTipText, | |
QtGui.QPalette.ColorRole.NColorRoles, | |
QtGui.QPalette.ColorRole.NoRole | |
] | |
for role in roles: | |
color = palette.brush(role).color() | |
rgb = color.getRgb() | |
code = "#{0:x}{1:x}{2:x}".format(color.red(), color.green(), color.blue()) | |
print(role.name, rgb, code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maya2018の結果