将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')
相关推荐
傻啦嘿哟18 分钟前
Python 操作 Excel 条件格式指南
开发语言·python·excel
2301_8073671920 分钟前
Python日志记录(Logging)最佳实践
jvm·数据库·python
2301_7957417931 分钟前
构建一个基于命令行的待办事项应用
jvm·数据库·python
小鸡吃米…42 分钟前
Python 网络爬虫 —— 环境设置
开发语言·爬虫·python
sw1213891 小时前
Python字典与集合:高效数据管理的艺术
jvm·数据库·python
进击的小头1 小时前
第13篇:基于伯德图的超前_滞后校正器深度设计
python·算法
m0_738098021 小时前
使用Python操作文件和目录(os, pathlib, shutil)
jvm·数据库·python
好家伙VCC1 小时前
# 发散创新:用 Rust构建高性能游戏日系统,从零实现事件驱动架构 在现代游戏开发中,**性能与可扩展性**是核心命题。传统基于
java·python·游戏·架构·rust
小璐资源网2 小时前
Java 21 新特性实战:虚拟线程详解
java·开发语言·python