1 year ago

#361666

test-img

Jst

How to make Maya colorSliderGrp's change command execute only once when picking color?

I am trying to work on a script to do the following: Whenever the user picks a color from the Maya UI, it prints the color value.

I have a simple code like this

import maya.cmds as cmds

cmds.window()
cmds.columnLayout()
cmds.colorSliderGrp(cc = lambda *args: printColor())

cmds.showWindow()

def printColor():
    print ('color')

When I run this, a color slider group shows up in a window as expected. Now I click on the color swatch and change color, and it prints 'color' as expected. But, when I move my cursor away (so the color picker goes away), it executes the printColor() function again (prints 'color' again).

What can I do to make it execute the printColor() function just once in the color-picking process?

python

python-3.x

maya

0 Answers

Your Answer

Accepted video resources