Search code examples
pythonpluginspyqtmaya

How to create maya plugin with PyQt interface?


I'm read this article and created simple "Hello World" plugin. But I need to create plugin with some PyQt interface, for example,

from maya import OpenMayaUI as omui 

try:
  from PySide2.QtCore import * 
  from PySide2.QtGui import * 
  from PySide2.QtWidgets import *
  from PySide2 import __version__
  from shiboken2 import wrapInstance 
except ImportError:
  from PySide.QtCore import * 
  from PySide.QtGui import * 
  from PySide import __version__
  from shiboken import wrapInstance 

mayaMainWindowPtr = omui.MQtUtil.mainWindow() 
mayaMainWindow= wrapInstance(long(mayaMainWindowPtr), QWidget) 

hello = QLabel("Hello, World", parent=mayaMainWindow) 
hello.setObjectName('MyLabel') 
hello.setWindowFlags(Qt.Window)
hello.show()   

How I can do it?


Solution

  • Problem solved. I just created command-plugin with hello.show() and it works.