Skip to content

Instantly share code, notes, and snippets.

@tm8r
Last active March 13, 2020 18:28
Show Gist options
  • Save tm8r/d8093f96cf0b01dd4bf209674f3196f1 to your computer and use it in GitHub Desktop.
Save tm8r/d8093f96cf0b01dd4bf209674f3196f1 to your computer and use it in GitHub Desktop.
Extract QColor from Maya
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)
@tm8r
Copy link
Author

tm8r commented Apr 20, 2018

Qt.py使える環境がない場合はPySideまたはPySide2に読み替えてください

@tm8r
Copy link
Author

tm8r commented Apr 20, 2018

Maya2018の結果

WindowText (187, 187, 187, 255) #bbbbbb
Foreground (187, 187, 187, 255) #bbbbbb
Button (93, 93, 93, 255) #5d5d5d
Light (97, 97, 97, 255) #616161
Midlight (55, 55, 55, 255) #373737
Dark (37, 37, 37, 255) #252525
Mid (45, 45, 45, 255) #2d2d2d
Text (200, 200, 200, 255) #c8c8c8
BrightText (37, 37, 37, 255) #252525
ButtonText (238, 238, 238, 255) #eeeeee
Base (43, 43, 43, 255) #2b2b2b
Window (68, 68, 68, 255) #444444
Background (68, 68, 68, 255) #444444
Shadow (0, 0, 0, 255) #000
Highlight (82, 133, 166, 255) #5285a6
HighlightedText (255, 255, 255, 255) #ffffff
Link (0, 0, 238, 255) #00ee
LinkVisited (82, 24, 139, 255) #52188b
AlternateBase (46, 46, 46, 255) #2e2e2e
ToolTipBase (255, 255, 199, 255) #ffffc7
ToolTipText (0, 0, 0, 255) #000
NColorRoles (128, 128, 128, 255) #808080
NoRole (0, 0, 0, 255) #000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment