将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')
相关推荐
Java后端的Ai之路12 小时前
【Python 教程15】-Python和Web
python
冬奇Lab14 小时前
一天一个开源项目(第15篇):MapToPoster - 用代码将城市地图转换为精美的海报设计
python·开源
二十雨辰16 小时前
[python]-AI大模型
开发语言·人工智能·python
Yvonne爱编码16 小时前
JAVA数据结构 DAY6-栈和队列
java·开发语言·数据结构·python
前端摸鱼匠17 小时前
YOLOv8 环境配置全攻略:Python、PyTorch 与 CUDA 的和谐共生
人工智能·pytorch·python·yolo·目标检测
WangYaolove131417 小时前
基于python的在线水果销售系统(源码+文档)
python·mysql·django·毕业设计·源码
AALoveTouch17 小时前
大麦网协议分析
javascript·python
ZH154558913117 小时前
Flutter for OpenHarmony Python学习助手实战:自动化脚本开发的实现
python·学习·flutter
xcLeigh18 小时前
Python入门:Python3 requests模块全面学习教程
开发语言·python·学习·模块·python3·requests
xcLeigh18 小时前
Python入门:Python3 statistics模块全面学习教程
开发语言·python·学习·模块·python3·statistics