Search - User list
Full Version: H22: Get UI Color with Python
Root » Technical Discussion » H22: Get UI Color with Python
alexeyvanzhula1984
Is it somehow possible to find out this theme's highlighted menu item color using Python?
Italimpex Productions
Hello. Default houdini theme uses this highlight color
Hex: #fdba00
RGB (0-255): (253, 186, 0)
RGB (0-1):

This code will pull highlight color of whatever theme you are using. For v20 or older, in first line change PySide6 to PySide2.

from PySide6 import QtGui

app = QtGui.QGuiApplication.instance()
if app:
    color = app.palette().color(QtGui.QPalette.Highlight)
    print(f"Hex: {color.name()}")
    print(f"RGB (0-255): {color.getRgb()[:3]}")
    print(f"RGB (0-1): {[round(x / 255.0, 3) for x in color.getRgb()[:3]]}")

Another thing, if you will use that color on a mesh it won't match how it looks in the UI because of ACES colorspace. Then you will need to disable OCIO by going to Color Correction > sRGB - Display > uncheck toggle "Enable OpenColorIO" to see true color. I attached a screenshot for reference.
alexeyvanzhula1984
Italimpex Productions
This code will pull highlight color...
Thank you for such a detailed answer. Everything works.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.