将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')
相关推荐
巴里巴气2 小时前
selenium基础知识 和 模拟登录selenium版本
爬虫·python·selenium·爬虫模拟登录
19892 小时前
【零基础学AI】第26讲:循环神经网络(RNN)与LSTM - 文本生成
人工智能·python·rnn·神经网络·机器学习·tensorflow·lstm
JavaEdge在掘金2 小时前
Redis 数据倾斜?别慌!从成因到解决方案,一文帮你搞定
python
ansurfen3 小时前
我的第一个AI项目:从零搭建RAG知识库的踩坑之旅
python·llm
前端付豪3 小时前
20、用 Python + API 打造终端天气预报工具(支持城市查询、天气图标、美化输出🧊
后端·python
前端付豪3 小时前
19、用 Python + OpenAI 构建一个命令行 AI 问答助手
后端·python
amazinging3 小时前
北京-4年功能测试2年空窗-报培训班学测开-第四十三天
python·学习
wgyang20164 小时前
我的第一个LangFlow工作流——复读机
python
Zhen (Evan) Wang4 小时前
(豆包)xgb.XGBRegressor 如何进行参数调优
开发语言·python
我爱一条柴ya4 小时前
【AI大模型】线性回归:经典算法的深度解析与实战指南
人工智能·python·算法·ai·ai编程