Sorry… managed to copy-paste the wrong code where I didn’t parent to the
MayaWindow. Still can’t make it to work though, so any input is greatly
appreciated!

from PySide2 import QtWidgets, QtCore
def _maya_main_window():
    """Return Maya's main window"""
    for obj in QtWidgets.qApp.topLevelWidgets():
        if obj.objectName() == 'MayaWindow':
            return obj
    raise RuntimeError('Could not find MayaWindow instance')
class ToolWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super(ToolWindow, self).__init__()

        self.setWindowFlags(QtCore.Qt.Tool)

        self.widget = QtWidgets.QWidget()
        self.layout = QtWidgets.QVBoxLayout()
        self.button = QtWidgets.QPushButton('Yoghurt')
        self.layout.addWidget(self.button)
        self.widget.setLayout(self.layout)
        self.setCentralWidget(self.widget)

window = ToolWindow(parent=_maya_main_window())
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAD%3DwhWPEb%3DXL1TSzzGJ_A5VbwL82ET0PvPudyHV%3DJSZgK7TNRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to