Thanks for sharing this Lidia!
I had a closer look and found that you might not need shiboken2 nor the API to accomplish this.
from PySide2 import QtWidgets
import maya.cmds as cmds
window = QtWidgets.QWidget()
window.resize(500,500)
qtLayout = QtWidgets.QVBoxLayout(window)
qtLayout.setObjectName('viewportLayout')
cmds.setParent('viewportLayout')
cmds.modelPanel("embeddedModelPanel#", cam='persp')
window.show()
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAB1%3D8wqJ%3DBqpP06zQCtYqieqtYiOy62V90AcEps_bXD4WejXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for sharing this Lidia!
I had a closer look and found that you might not need
shiboken2nor the API to accomplish this.from PySide2 import QtWidgets import maya.cmds as cmds window = QtWidgets.QWidget() window.resize(500,500) qtLayout = QtWidgets.QVBoxLayout(window) qtLayout.setObjectName('viewportLayout') cmds.setParent('viewportLayout') cmds.modelPanel("embeddedModelPanel#", cam='persp') window.show()
On 17 March 2017 at 15:57, Lidia Martinez <darksi...@gmail.com> wrote:
Hi folks,I published an article about embedding Maya's UI into PySide2 for Maya2017.And again after the first fix I included, I had some errors running this code in a particular case. Maya was telling me '|' or '||' didn't exist.As you can see on the EDIT section (which is the second edit of the article), I wrote an explanation on how to fix this using setObjectName('layout') on the window and layout which generates a better UI path: window|layout|... instead of ||, and seems like Maya likes it better (I guess why).But then I found out I could even avoid getting the full name that just using setParent('layout') would work without errors instead of using a path.I wanted to understand why this is working, even when I use the same object name with different windows. There's no name clash in Qt, and magically Maya's UI understands setParent anyway...Any idea why this is happening?--
Lidia
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAB1%3D8wqJ%3DBqpP06zQCtYqieqtYiOy62V90AcEps_bXD4WejXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
----
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD2NeYiLExwsU5VfhCFDjjDGuOAjLSs_4yn0N-kFsqMPA%40mail.gmail.com.
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 QtWidgets
import 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 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. 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.
In the name of cross-compatibility with Qt 4 and 5, I’m in the process of disproving the need for
sipandshibokenhere. The premise being that all can be done with Qt’sfindChildalone. If anyone has further examples ofsiporshibokenplease 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 python_inside_m...@googlegroups.com.
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.
Thanks, that’s a good suggestion. Though I wonder whether the MQtUtil.findControl() wouldn’t be suffering from the same consequence, both being driven by the object name of widgets.
# With
pointer = MQtUtil.findControl("someName")
widget = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
# Without
widget = window.findChild(QtWidgets.QWidget, "someName")
Where the Maya-approach is looking for a widget on a global scale, with more room for collision, and the Qt-based approach is looking in just the window.