def remove_exists_window(object_name): from maya import OpenMaya from maya import OpenMayaUI wind = OpenMayaUI.MQtUtil() if wind.findWindow(object_name): mel_command = 'deleteUI \"%s\"' % object_name OpenMaya.MGlobal.executeCommand(mel_command, False, True)
def get_top_window(): top_window = None try: from maya import OpenMayaUI as omui maya_main_window_ptr = omui.MQtUtil().mainWindow() top_window = QtCompat.wrapInstance(long(maya_main_window_ptr), QtWidgets.QWidget) except ImportError, e: pass
def get_app_window(): top_window = None try: from maya import OpenMayaUI as omui maya_main_window_ptr = omui.MQtUtil().mainWindow() top_window = wrapInstance(long(maya_main_window_ptr), QtWidgets.QMainWindow) except ImportError as e: pass return top_window
def get_window(): ptr = mui.MQtUtil().mainWindow() win = shiboken2.wrapInstance(long(ptr), QtWidgets.QMainWindow) return win
def remove_exists_window(object_name): from maya import OpenMayaUI from pymel import core wind = OpenMayaUI.MQtUtil() if wind.findWindow(object_name): core.deleteUI(object_name)
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from PySide import QtCore, QtGui from shiboken import wrapInstance from maya import OpenMayaUI as omui import maya.cmds as cmds import maya.mel as mel import os maya_main_window_ptr = omui.MQtUtil().mainWindow() maya_main_window = wrapInstance(long(maya_main_window_ptr), QtGui.QWidget) class HadanHowTo(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.__build_ui() def __build_ui(self): self.setGeometry(QtCore.QRect(100, 100, 450, 500)) self.setWindowTitle(QtGui.QApplication.translate("Hadan", "破断", None, QtGui.QApplication.UnicodeUTF8)) title_lbl = QtGui.QLabel(self) title_lbl.setGeometry(QtCore.QRect(10, 0, 75, 50)) font = QtGui.QFont() font.setPointSize(16) title_lbl.setFont(font) title_lbl.setText("Help") split_options = QtGui.QFrame(self)
def remove_exists_window(object_name): wind = OpenMayaUI.MQtUtil() if not wind.findWindow(object_name): return mel_command = 'deleteUI \"%s\"' % object_name OpenMaya.MGlobal.executeCommand(mel_command, False, True)