Pyside2 connectControl


I’m back here looking for some answers! I’ve been converting my scripts from maya commands UI to Pyside2 . In Maya commands there is this command “connectControl” that allows you to connect a UI element to a specific attribute.
For example one could do (code just for reference):
color = cmds.colorSliderGrp()
connectControl(color, “pSphere1Shape.color”)

This would connect the colorSliderGrp UI to the color of the pSphere so that as you change the color in the UI it changes in the pSphere.
Is there a way of doing this exact same thing with PySide2? Or do we have to manually change the values every time?

I tried doing the following but an error came out:
self.first = wdg.QDoubleSpinBox()
cmds.connectControl(self.first, ‘LightRig_’ + self.CHARACTER + ‘’)

RuntimeError: connectControl: Object ‘<PySide2.QtWidgets.QDoubleSpinBox object at 0x000001E4C79D7488>’ not found.

Thank you!


The usual way to connect widgets is:

widget.signal.connect(some method)


def clicked():
    print 'clicked'
pushButton.clicked.connect(lambda : clicked())

In the clicked() function you can update all your scene elements.


Thank you haggi! I wasn’t refering to that kind of connection.
From the Autodesk connectControl documentation:

The good thing about this Maya command is that if you are importing a file with data, by modifying the attributes the UI controllers will be changed automatically. I was wondering if there was any workaround to this with PySide2.
As of now my way of doing it is reading the imported file, modifying manually all attributes and then modifying manually all controllers. It can be done but it is a bit tedious…