import shiboken2
import maya.OpenMayaUI as mui
def getMayaWindow():
main_window_ptr = mui.MQtUtil.mainWindow()
return shiboken2.wrapInstance(long(main_window_ptr), QtWidgets.Qwidget)
###############
from PySide2 import QtWidgets
import pymel.core as pm
from maya import OpenMayaUI
import shiboken2
def maya_mainwindow():
maya_main_window_name = pm.language.melGlobals['gMainWindow']
maya_main_window = OpenMayaUI.MQtUtil.findControl(maya_main_window_name)
widget = shiboken2.wrapInstance(long(maya_main_window), QtWidgets.QWidget)
return widget
widget有个StayOnTopHint,设置一下就好