Isotropix Forums

Accessing Clarisse's 'Color Dialog' Widget In PyQT

Clarisse Scripting related topics

Accessing Clarisse's 'Color Dialog' Widget In PyQT

Unread postby mhamid3d » Wed Dec 04, 2019 5:25 pm

I was wondering if it is possible to create an instance of the 'Color Dialog' clarisse widget in PyQt or at least get the command the shows the dialog?

I noticed that when I clicked a color attribute and the color dialog opens, the name of the SceneObject and the target attribute is written on the window title. So it is possible to pass the color attribute of a SceneObject as an argument to some type of function that opens a color dialog?

Posts: 8
Joined: Wed Dec 04, 2019 5:20 pm

Re: Accessing Clarisse's 'Color Dialog' Widget In PyQT

Unread postby anemoff » Thu Dec 05, 2019 11:32 am


You can invoke the color dialog using Python with the following code:

python code

app = ix.application

# get the color dialog instance
color_dialog = app.get_color_dialog()

# customize the title
color_dialog.set_dialog_title("Hello Color Dialog!")

# set an RGB color (there are other APIs, like `set_hsv_color`, and `set_current_*_color` variants too)
color_dialog.set_rgb_color(1.0, 0.5, 0.5)

# set the alpha

# show it: by default, it shows an RGB picker

# if you need an RGBA picker, you need to specify the color depth parameter:

# get current color: the "current" color is the current color before it is validated with OK
# if you close the dialog with Cancel, current color is not saved
rgb = color_dialog.get_current_rgb_color()
hsv = color_dialog.get_current_hsv_color()
alpha = rgb = color_dialog.get_current_a_color()

# get the validated color (dialog was closed with the OK button):
rgb = color_dialog.get_rgb_color()
hsv = color_dialog.get_hsv_color()
alpha = rgb = color_dialog.get_a_color()

The Color Dialog stores its settings, calling get_color_dialog again will reuse get the previous color dialog with its previous settings.
To reset it, do this (this will actually delete it, and a new one will be created on the next call to get_color_dialog):

py code

# then you can call this again to create a fresh one:
color_dialog = app.get_color_dialog()

For more details, check the following SDK doc pages:
- GuiColorDialog: ... ialog.html
- GuiApp:
- Gui::ColorDepth:

Let us know if you need more details.
Anthony Nemoff
R&D Engineer
User avatar
Posts: 367
Joined: Wed Jan 13, 2016 10:10 am

Return to Scripting