Executing this code in Maya 2018 I've got an error:
# Error: ImportError: file <maya console> line 3: No module named PyQt5.QtWidgets #
Isn't PyQt5
a part of Maya 2018?
import maya.cmds as cmds
import sys
from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton)
from PyQt5.QtGui import QFont
class Example(QWidget):
def __init__(self):
super(Example,self).__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
btn = QPushButton('Button', self)
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.move(50, 50)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Tooltips')
self.show()
ex = Example()
Qt is part of Maya, but if you want to use PyQt5 you need to build it. Be careful, you need to build it against maya’s modified version of Qt.