Skip to content

Instantly share code, notes, and snippets.

@fereria
Created August 2, 2018 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fereria/e0653bf28f43dfa437e32a170288032a to your computer and use it in GitHub Desktop.
Save fereria/e0653bf28f43dfa437e32a170288032a to your computer and use it in GitHub Desktop.
## -*- coding: utf-8 -*-
#*----------------------------------------------*#
# 各種モジュール読み込み
#*----------------------------------------------*#
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *
from maya import OpenMayaUI as omUI
import shiboken2 as shiboken
#*----------------------------------------------*#
# MAIN
#*----------------------------------------------*#
def getMayaWindow():
"""
Get the main Maya window as a QtGui.QMainWindow instance
@return: QtGui.QMainWindow instance of the top level Maya windows
"""
ptr = omUI.MQtUtil.mainWindow()
if ptr is not None:
return shiboken.wrapInstance(long(ptr), QMainWindow)
class testUI(QDialog):
def __init__(self):
super(testUI,self).__init__(getMayaWindow())
[x.close() for x in self.parent().findChildren(self.__class__)]
btn = QPushButton("Hello World")
layout = QVBoxLayout()
layout.addWidget(btn)
self.setLayout(layout)
def main():
win = testUI()
win.show()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment