Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Together,
please can you support me with this...
I try to connect a QSlider with an easy QWindow with simple Attributes of an object. The slider should be connected with a QTextEdit to manually edit the values. everything should be updated in realtime. I found the Python command: "connectControl" which should do the Job, but I dont get evereything up and running.
Here is my code:
from PySide2 import QtCore, QtGui, QtWidgets import maya.cmds as cmds class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 300) self.horizontalSlider = QtWidgets.QSlider(Dialog) self.horizontalSlider.setGeometry(QtCore.QRect(60, 60, 160, 22)) self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider.setObjectName("horizontalSlider") self.horizontalSlider.setTickInterval(1000) self.horizontalSlider.setSingleStep(0.1) self.horizontalSlider.setRange(0, 1000) self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(230, 60, 41, 31)) self.textEdit.setObjectName("textEdit") self.horizontalSlider.valueChanged.connect(self.print_it) def retranslateUi(self, Dialog): Dialog.setWindowTitle(QtWidgets.QApplication.translate("Dialog", "Dialog", None, -1)) def print_it(self,x): try: print float(x) self.horizontalSlider.valueChanged[int].connect(self.textEdit.setText(str(x))) except Exception as e: print e if __name__ == "__main__": if cmds.window("Dialog", q = True, ex = True): cmds.deleteUI("Dialog") Dialog = QtWidgets.QDialog() ui = Ui_Dialog() ui.setupUi(Dialog) Dialog.show()
and this is the code I found from the Maya docs:
import maya.cmds as cmds sphereNames = cmds.polySphere() sphereName = sphereNames[0] window = cmds.window() cmds.columnLayout() cmds.text( l='X Value:' ) cmds.floatField( 'xx' ) cmds.connectControl( 'xx', '%s.tx' % sphereName ) cmds.text( l='Visibility' ) cmds.checkBox( 'vis' ) cmds.connectControl( 'vis', '%s.visibility' % sphereName ) cmds.floatFieldGrp( 'rot', l='Rotation:', numberOfFields=3 ) # index 1 would be the text label cmds.connectControl( 'rot', '%s.rx' % sphereName, index=2 ) cmds.connectControl( 'rot', '%s.ry' % sphereName, index=3 ) cmds.connectControl( 'rot', '%s.rz' % sphereName, index=4 ) cmds.showWindow( window )
and the result:
Many thanks for any support on this.
5inch
Solved! Go to Solution.