Hi,
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
color_dialog.set_a_color(0.2)
# show it: by default, it shows an RGB picker
color_dialog.show()
# if you need an RGBA picker, you need to specify the color depth parameter:
color_dialog.show(ix.api.Gui.COLOR_DEPTH_RGBA)
# 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
app.reset_color_dialog()
# 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:
https://www.clarissewiki.com/4.0/sdk/cl ... ialog.html- GuiApp:
https://www.clarissewiki.com/4.0/sdk/class_gui_app.html- Gui::ColorDepth:
https://www.clarissewiki.com/4.0/sdk/class_gui.htmlLet us know if you need more details.
Cheers,