Change Handlers for UI Controls


#1

I’ve got a class with some values that are being held.

I’ve got a UI which is a series of floatfields and checkboxes. I can initiate the UI controls getting the value from the class, but how do I make the changecommand work to be able to set the value of the UI control back to the class?

Below is wrong but that’s what I’m expecting it to be… (from a maxscript background)

chk_aaFilterOn = cmds.checkBox( label=‘AA Filter’, value=lowSettings.aaFilterOn changeCommand=(lowSettings.aaFilterOn = value))

And what’s the same thing for floatfields?

Thanks

Dave


#2

I haven’t used maya.cmds for UI related methods in Maya in a long time.
I would recommend using PySide, however… this may help.

You could just apply a method/function that applies that variable lowSettings.aaFilterOn equal to the queried value of that checkbox.

Assuming this is within a class, and lowSettings is an attr of that class.

chk_aaFilterOn = cmds.checkBox( 'nameOfCheckBox', label='AA Filter', value=self.lowSettings.aaFilterOn, changeCommand=self.changedAAFilter() )

def changedAAFilter(self):
    self.lowSettings.aaFilterOn = cmds.checkBox('nameOfCheckBox', q=True, value=True)

hope this helps.


#3

Thanks Dan, that looks like it should work!