I developed a plugin with the Python internal GUI and now wanted to change to PyQt. I now found that, whenever I load and start the plugin, maya does not update its scene screen anymore.
E.g.: I have a simple box in the scene. Once my plugin is loaded and I select the box, I do not see the selection of the box until I move around in the scene (e.g. rotate the camera). Since my plugin changes the scene and even can start an animation, this is really annoying. I post party of my code to give you a better idea.
Thanks for your help guys
###########################################################
import maya.OpenMaya as OpenMaya
import maya.OpenMayaAnim as OpenMayaAnim
import sys
import math
import maya.OpenMayaMPx as OpenMayaMPx
import maya.cmds as cmds
import PyQt4.QtCore as QtCore
import PyQt4.QtGui as QtGui
import sip
kPluginCmdName = "MakeMeSwim";
##### Deformer class does all the calculations and set keyframes #####
class Deformer:
[...]
class MainWindow(QtGui.QMainWindow):
applyAnimSignal = QtCore.pyqtSignal(int, float, float, int, int, int,name='applyAnimSignal')
def __init__(self, *args):
QtGui.QMainWindow.__init__(self, *args)
self.setWindowTitle('Make Me Swim')
self.vertical = QtGui.QVBoxLayout()
self.horizontal1 = QtGui.QHBoxLayout()
self.axis1 = QtGui.QRadioButton("x-axis");
self.axis1.setChecked(1);
self.axis2 = QtGui.QRadioButton("y-axis");
self.axis3 = QtGui.QRadioButton("z-axis");
[...]
#### register command and connect to UI #####
class scriptedCommand(OpenMayaMPx.MPxCommand):
def __init__(self):
OpenMayaMPx.MPxCommand.__init__(self);
def doIt(self,argList):
app = QtGui.QApplication(sys.argv)
mainWindow = MainWindow()
deform=Deformer();
app.connect(app, QtCore.SIGNAL("lastWindowClosed()"),app, QtCore.SLOT("quit()"))
mainWindow.applyAnimSignal.connect(deform.addAnimation)
mainWindow.show()
app.exec_()
# Creator
def cmdCreator():
return OpenMayaMPx.asMPxPtr( scriptedCommand() );
# Initialize the script plug-in
def initializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject);
try:
mplugin.registerCommand( kPluginCmdName, cmdCreator );
except:
sys.stderr.write( "Failed to register command: %s\n" %kPluginCmdName );
raise;
# Uninitialize the script plug-in
def uninitializePlugin(mobject):
mplugin = OpenMayaMPx.MFnPlugin(mobject);
try:
mplugin.deregisterCommand( kPluginCmdName );
except:
sys.stderr.write( "Failed to unregister command: %s\n" %kPluginCmdName );
raise;
###############################################################