from PyQt4 import QtCore,QtGui
import maya.cmds as cmds
import maya.OpenMayaUI as OpenMayaUI
import sip
def getMayaWindow():
windowPointer = OpenMayaUI.MQtUtil.mainWindow()
return sip.wrapinstance(long(windowPointer), QtCore.QObject)
class MayaView(QtGui.QDialog):
def __init__(self,parent=None,**kwargs):
super(MayaView,self).__init__(parent,**kwargs)
self.setObjectName('MyWindow')
self.setWindowTitle('3dView')
self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout.setContentsMargins(0,0,0,0)
self.verticalLayout.setObjectName("mainLayout")
applyBut = QtGui.QPushButton('Apply')
closeBut = QtGui.QPushButton('Close')
butLayout = QtGui.QHBoxLayout()
butLayout.addWidget(applyBut)
butLayout.addWidget(closeBut)
butLayout.setObjectName("xxxBut")
layout = OpenMayaUI.MQtUtil.fullName(long(sip.unwrapinstance(self.verticalLayout)))
print "vertical layout",layout
cmds.setParent(layout)
paneLayoutName = cmds.paneLayout()
# find a pointer to the paneLayout that we just created
ptr = OpenMayaUI.MQtUtil.findControl(paneLayoutName)
# warp the pointer into a python QObject
self.paneLayout = sip.wrapinstance(long(ptr),QtCore.QObject)
# new create a camera
self.cameraName = cmds.camera(n='PickerView_camera')[0]
cmds.hide(self.cameraName)
cmds.viewFit(self.cameraName,all=True)
self.modelPanelName = cmds.modelPanel(cam=self.cameraName,parent=paneLayoutName)
# edit model panel
modelEditorValue = cmds.modelPanel(self.modelPanelName,q=True,me=True)
cmds.modelEditor(modelEditorValue,e=True,da='smoothShaded',ca=False,grid=False,hud=False,\
manipulators=False,displayTextures=True,ha=False,j=False,ikh=False,df=False,\
dim=False,lc=False,nc=True,wos=False,dl='default',av=False)
# find a pointer to the modelPanel that we just created
ptr = OpenMayaUI.MQtUtil.findControl(self.modelPanelName)
#wrap the pointer into a python QObject
self.modelPanel = sip.wrapinstance(long(ptr),QtCore.QObject)
#add our QObject reference to the paneLayout to our layout
self.verticalLayout.addWidget(self.paneLayout)
self.verticalLayout.addLayout(butLayout)
self.verticalLayout.setSpacing(0)
self.setLayout(self.verticalLayout)
self.setFixedSize(400,600)
class MainWin(QtGui.QDialog):
def __init__(self,parent=getMayaWindow()):
super(MainWin,self).__init__(parent)
cam = MayaView()
# self.setObjectName('xxxxxx')
but = QtGui.QPushButton('zzz')
layout = QtGui.QVBoxLayout()
layout.addWidget(but)
layout.addWidget(cam)
self.setLayout(layout)
# layout.setObjectName('yyyyy')
a = MainWin()
a.show()
from PyQt4 import QtCore,QtGui
import maya.cmds as cmds
import maya.OpenMayaUI as OpenMayaUI
import sip
def getMayaWindow():
windowPointer = OpenMayaUI.MQtUtil.mainWindow()
return sip.wrapinstance(long(windowPointer), QtCore.QObject)
class MayaView(QtGui.QWidget):
def __init__(self,parent=None,**kwargs):
super(MayaView,self).__init__(parent,**kwargs)
self.setObjectName('MyWindow')
self.setWindowTitle('3dView')
self.verticalLayout = QtGui.QVBoxLayout(self)
self.verticalLayout.setContentsMargins(0,0,0,0)
self.verticalLayout.setObjectName("mainLayout")
applyBut = QtGui.QPushButton('Apply')
closeBut = QtGui.QPushButton('Close')
butLayout = QtGui.QHBoxLayout()
butLayout.addWidget(applyBut)
butLayout.addWidget(closeBut)
layout = OpenMayaUI.MQtUtil.fullName(long(sip.unwrapinstance(self.verticalLayout)))
cmds.setParent(layout)
paneLayoutName = cmds.paneLayout()
# find a pointer to the paneLayout that we just created
ptr = OpenMayaUI.MQtUtil.findControl(paneLayoutName)
# warp the pointer into a python QObject
self.paneLayout = sip.wrapinstance(long(ptr),QtCore.QObject)
# new create a camera
self.cameraName = cmds.camera(n='PickerView_camera')[0]
cmds.hide(self.cameraName)
cmds.viewFit(self.cameraName,all=True)
self.modelPanelName = cmds.modelPanel(cam=self.cameraName)
cmds.panel(self.modelPanelName,e=True,mbv=False)
flayout = cmds.modelPanel(self.modelPanelName,q=True,barLayout=True)
cmds.frameLayout(flayout,e=True,collapse=True)
# edit model panel
modelEditorValue = cmds.modelPanel(self.modelPanelName,q=True,me=True)
cmds.modelEditor(modelEditorValue,e=True,da='smoothShaded',ca=False,grid=False,hud=False,\
manipulators=False,displayTextures=True,ha=False,j=False,ikh=False,df=False,\
dim=False,lc=False,nc=True,wos=False,dl='default',av=False)
# find a pointer to the modelPanel that we just created
ptr = OpenMayaUI.MQtUtil.findControl(self.modelPanelName)
#wrap the pointer into a python QObject
self.modelPanel = sip.wrapinstance(long(ptr),QtCore.QObject)
#add our QObject reference to the paneLayout to our layout
self.verticalLayout.addWidget(self.paneLayout)
self.verticalLayout.addLayout(butLayout)
self.verticalLayout.setSpacing(0)
self.setLayout(self.verticalLayout)
self.setFixedSize(400,600)
class MainWin(QtGui.QMainWindow):
def __init__(self,parent=getMayaWindow()):
super(MainWin,self).__init__(parent)
self.setObjectName('QtMainWindow')
self.mid = QtGui.QMdiArea()
self.mid.setObjectName('QMdiArea')
self.setCentralWidget(self.mid)
cam = MayaView()
self.mid.addSubWindow(cam)
a = MainWin()
a.show()
Wasn't sure if this was a question or another example of how to do it?
Also another thing I found was that Maya didn't seem to like layouts being added to layouts. I had to add a widget in between. Maybe that has changed. Haven't tested it in the latest Maya.
- Justin (aka Justine)
--
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/34591c50-38dd-4155-977d-5422f0665649%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
...
ptr <span style="co
I'm not sure if there really is a "correct" way to be doing this anyways, since it is the process of hijacking Maya's UI elements and interacting with how it has implemented it's translation between QWidgets and the Maya object path.
I would have to say that as far as I know, and have tested, setting object names on all of the parent elements of the intended Maya UI element is kind of necessary.
The whole thing is pretty much an unsupported trick.
--
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/ff495809-87af-44e5-80ac-ae34767a63f9%40googlegroups.com.
shall i manually call setObjectName on all the “missing” layouts? this doesn’t feel correct to me .)
I might add that an object can only ever have 1 name. So if it turns out Maya is actually using the objectName that you are changing, you might end up breaking things; and there is no undo for that. :)
On the other hand, setting objectNames “manually” certainly isn’t “hacky” or even “manual”; Qt isn’t setting those names for you, they are meant to be set by you for you to distinguish them from other objects, however like I said, Maya may have already done that for a reason.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA07vL78M0CiN3RCQTd1-UgejPLC_NT3LNZ-PMKnyDvsgQ%40mail.gmail.com.
hello, and by the way have you found a solution for the |||| in the name when is a nested layout working as a parent ??
--
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/aaec3587-1350-49fc-97a0-6b8e015b5518%40googlegroups.com.
Hello, Thanks for the examples but I noticed that none of the icons in modelEditorIconBar seem to work. Clicking on shaded or wireframe icons have no effect in the viewport. Does anyone know how to fix this problem? I am referring to example1.Thanks
--
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/dfa30f8a-617b-4e4b-8aac-f373054739db%40googlegroups.com.
Thank Justin. I don't have access to my code right now to check the differences between mine and this one but this code works perfectly fine. Thanks again.
Hey Justin,
It seems like putting the paneLayout into a QSplitter causes the issue. I edited your code to add the splitter.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/DM5PR02MB36377ECD33C4A72D151B822DD3370%40DM5PR02MB3637.namprd02.prod.outlook.com.
Thanks for looking into Justin.
--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/BL0PR02MB363517A5490B81A69CEC8B85D3320%40BL0PR02MB3635.namprd02.prod.outlook.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/DM5PR02MB36377ECD33C4A72D151B822DD3370%40DM5PR02MB3637.namprd02.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.