问题描述:
将PySide2/PyQt工具的窗口停靠在Maya的界面中
解决方法:
from PySide2 import QtCore, QtGui, QtWidgetsfrom maya.app.general.mayaMixin import MayaQWidgetDockableMixinclass MainWindow(MayaQWidgetDockableMixin, QtWidgets.QMainWindow):def __init__(self, parent=None):super(MainWindow, self).__init__(parent=parent)self.setWindowTitle("test")# Main widgetmain_widget = QtWidgets.QWidget()main_layout = QtWidgets.QVBoxLayout()# Create UI widgetsself.test_btn = QtWidgets.QPushButton('Test')# Attach widgets to the main layoutmain_layout.addWidget(self.test_btn)# Set main layoutmain_widget.setLayout(main_layout)self.setCentralWidget(main_widget)# Connect buttons signalsself.test_btn.clicked.connect(self.on_test_btn_click)def on_test_btn_click(self):print('Test button was clicked')w = MainWindow()
w.show(dockable=True, floating=False, area='left')