Python Class: Color Picker Dialog


https://forum.reallusion.com/Topic402188.aspx
Print Topic | Close Window

By jlittle - 5 Years Ago
Here I've attached a module with the same ColorPickerDialog but as a class.
Usage would be as follows:
import PickColorDialogClass

# create a PickColorDialog object
PickColor_Dlg = PickColorDialogClass.myPickColorDialog()
# show dialog and return color or None if cancelled
clr = PickColor_Dlg.getSelectedColor()


You can also set the initial color:
# get current color
currClr = QColor.fromRgb(0,255,0,255)
# show dialog, using current color, and return color or None if cancelled
clr = PickColor_Dlg.getSelectedColor(currClr)

This does the same as the color picker dialog module except as a class.
A class is useful is you need to create multiple instances of the same object.

In this case you normally would not create multiple instances of a Color Dialog but only used it as an example to demonstrate how you can easily turn a module into a class.

Jeff