Ah, didn’t notice this in her original example.
Here’s an updated example that fetches the Qt object of a Maya widget and
calls a method on it, again without sip or shiboken.
from PySide2 import QtWidgetsimport maya.cmds as cmds
def on_button_clicked():
print("Repainting..")
modelPanel.repaint()
window = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout(window)
layout.setObjectName("viewportLayout")
cmds.setParent(layout.objectName())
modelPanel = cmds.modelPanel("embeddedModelPanel#", cam="persp")
modelPanel = window.findChild(QtWidgets.QWidget, modelPanel)
button = QtWidgets.QPushButton("Repaint")
button.clicked.connect(on_button_clicked)
layout.addWidget(button)
window.resize(500,500)
window.show()
Replace PySide2 with PySide and you’ve got your Qt 4 implementation, or use
Qt.py <https://github.com/mottosso/Qt.py> for cross-compatibility.
from Qt import QtWidgets
In the name of cross-compatibility with Qt 4 and 5, I’m in the process of
disproving the need for sip and shiboken here
<https://github.com/mottosso/Qt.py/issues/53>. The premise being that all
can be done with Qt’s findChild alone. If anyone has further examples of sip
or shiboken please share. If we can rid the world of these libraries, the
transition from Qt 4 to 5 would be that much easier.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBHM-H8JUv-S%3DW8rrbVXsyTHq_gyOvL0VJd0cdbV16Kiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.