将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')
相关推荐
workflower3 小时前
时序数据获取事件
开发语言·人工智能·python·深度学习·机器学习·结对编程
C++业余爱好者4 小时前
Java 提供了8种基本数据类型及封装类型介绍
java·开发语言·python
火山灿火山5 小时前
Qt常用控件(三)
开发语言·qt
AI Echoes5 小时前
构建一个LangChain RAG应用
数据库·python·langchain·prompt·agent
派大鑫wink6 小时前
从零到精通:Python 系统学习指南(附实战与资源)
开发语言·python
c骑着乌龟追兔子6 小时前
Day 38 官方文档的阅读
python
羸弱的穷酸书生6 小时前
国网 i1协议 python实现
开发语言·python
weixin_462022356 小时前
RAW-Adapter: Adapting Pre-trained Visual Model to Camera RAW Images
python·计算机视觉
电子硬件笔记6 小时前
Python语言编程导论第三章 编写程序
开发语言·python·编辑器
布谷歌6 小时前
在java中实现c#的int.TryParse方法
java·开发语言·python·c#