将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')
相关推荐
程序员三藏1 分钟前
软件测试之环境搭建及测试流程
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
10岁的博客21 分钟前
PyTorch快速搭建CV模型实战
人工智能·pytorch·python
寒秋丶1 小时前
AutoGen多智能体协作、人机交互与终止条件
人工智能·python·microsoft·ai·人机交互·ai编程·ai写作
Turnsole_y1 小时前
pytest与Selenium结合使用指南
开发语言·python
AI量化投资实验室2 小时前
年化398%,回撤11%,夏普比5,免费订阅,5积分可查看参数|多智能体的架构设计|akshare的期货MCP代码
人工智能·python
夫唯不争,故无尤也2 小时前
AI调度框架全解析:从通用到LLM专用
python·大模型·调用框架
wudl55663 小时前
Python 虚拟环境和包管理
数据库·python·sqlite
Geoking.4 小时前
PyTorch torch.unique() 基础与实战
人工智能·pytorch·python
俊俊谢5 小时前
【第一章】金融数据的获取——金融量化学习入门笔记
笔记·python·学习·金融·量化·akshare
春蕾夏荷_7282977255 小时前
qcustomplot 显示坐标轴
qt·qcustomplot·坐标轴