Profile Picture

Python Class: Color Picker Dialog

Posted By jlittle 3 Months Ago
You don't have permission to rate!
Author
Message
jlittle
jlittle
Posted 3 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.5K, Visits: 11.7K
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



See my CTA Tutorials on the YouTube channel CTAStepByStep
Check out EZColors for CTA. The easy way to change Render Styled (RS) colors.

Attachments
PickColorDialogClass.zip (18 views, 1.00 KB)
Edited
3 Months Ago by jlittle



Reading This Topic