H22: Get UI Color with Python

   249   2   1
User Avatar
Member
109 posts
Joined: Nov. 2023
Offline
Is it somehow possible to find out this theme's highlighted menu item color using Python?
Edited by alexeyvanzhula1984 - Sept. 3, 2026 13:30:29

Attachments:
Screenshot 2026-09-03 at 20.26.57.png (547.5 KB)

User Avatar
Member
26 posts
Joined: Aug. 2021
Offline
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.
Edited by Italimpex Productions - Sept. 3, 2026 17:39:37

Attachments:
get_ui_color.png (348.9 KB)

Italimpex Productions
CGI Studio specializing in directing and producing advertisements & films
User Avatar
Member
109 posts
Joined: Nov. 2023
Offline
Italimpex Productions
This code will pull highlight color...
Thank you for such a detailed answer. Everything works.
  • Quick Links