将Qt窗口停靠在Maya界面中

问题描述:

将PySide2/PyQt工具的窗口停靠在Maya的界面中

解决方法:

python 复制代码
from PySide2 import QtCore, QtGui, QtWidgets

from maya.app.general.mayaMixin import MayaQWidgetDockableMixin

class MainWindow(MayaQWidgetDockableMixin, QtWidgets.QMainWindow):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)
        
        self.setWindowTitle("test")
        # Main widget
        main_widget = QtWidgets.QWidget()
        main_layout = QtWidgets.QVBoxLayout()

        # Create UI widgets
        self.test_btn = QtWidgets.QPushButton('Test')

        # Attach widgets to the main layout
        main_layout.addWidget(self.test_btn)

        # Set main layout
        main_widget.setLayout(main_layout)
        self.setCentralWidget(main_widget)

        # Connect buttons signals
        self.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')
相关推荐
天空属于哈夫克39 分钟前
Java 开发|企微外部群主动发送小程序消息实战
开发语言·python·小程序·自动化·企业微信·rpa
戴西软件10 分钟前
PreSys在爆炸与多介质流固耦合中的建模方法:从ALE到SPH的工程实践
linux·python·程序人生·cae
程序员南飞14 分钟前
排序算法举例
java·开发语言·数据结构·python·算法·排序算法
有点心急102116 分钟前
图表展示 MCP 工具
python·aigc·mcp
coding者在努力19 分钟前
LangChain之解析器核心组件.2026年新版讲解,超详细
windows·python·机器学习·langchain·pip
伶俐的猪26 分钟前
性能测试以及面试题
python
52Hz11828 分钟前
力扣394.字符串解码、739.每日温度、84.柱状图中最大的矩形
python·算法·leetcode
XW010599936 分钟前
4-10大公约数和最小公倍数
python·gcd·lcm
Cxiaomu40 分钟前
Python 文件解析: Excel / Word / PDF 的解析、处理、预览与下载
python·word·excel
啊阿狸不会拉杆1 小时前
《计算机视觉:模型、学习和推理》第 10 章-图模型
人工智能·python·学习·机器学习·计算机视觉·图模型