- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
I am trying to create an empty fully dockable window using python.
None of the scripts from various tutorials work.
Most of them produces: # Error: invalid syntax #
For example this one:
https://www.youtube.com/watch?v=n4i4F2fmK2M
********************* empty window script **********************
import maya.cmds as cmds
class MR_Window(object):
#constructor
def __init__(self):
self.window = "MR_Window"
self.title = "Cube Creator"
self.size = (400, 400)
# close old window is open
if cmds.window(self.window, exists = True):
cmds.deleteUI(self.window, window=True)
#create new window
self.window = cmds.window(self.window, title=self.title, widthHeight=self.size)
#display new window
cmds.showWindow()
myWindow = MR_Window()
Or that one (updated):
https://www.youtube.com/watch?v=lBz8lEqHXYM
import PySide2 as ps2
import maya.OpenMayaUI as omui
import shiboken2
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
def mayaMainWindow():
mainWindowPointer = omui.MQtUtil.mainWindow()
return shiboken2.wrapInstance(int(mainWindowPointer), ps2.QtWidgets.QWidget)
class MyWindow(MayaQWidgetDockableMixin, ps2.QtWidgets.QDialog):
def __init__(self, parent=mayaMainWindow()):
super(MyWindow, self).__init__(parent)
self.myButton = ps2.QtWidgets.QPushButton('My Button')
mainLayout = ps2.QtWidgets.QVBoxLayout(self)
mainLayout.addWidget(self.myButton)
if __name__== '__main__':
myWindow = MyWindow()
myWindow.show(dockable=True)
I'm running out of ideas.
Please advise.
Cheers,
DS
Solved! Go to Solution.