I am using Maya 2014 and writing a simple ui in QtDesigner. I copied the PyQt4 folder and the sip.pyd file to the correct location in the Maya install folder. So far, so good. I followed a tutorial that created a simple ui with a button that made a box. Everything was good until I changed the code slightly and attempted to import the ui.
On trying to import my file, the xml parser did fine but then I received an
error:* # Error: ImportError: file <string> line 59: No module named
ploppy_rc # *
The ui itself is ok, I added some radio buttons (which are not yet linked
to anything) and the only difference between my file and the tutorial file
is that I created a resource folder with an icon for the ui.
As the script I wrote is only 35 lines long, I was confused by the line 59
error. then I realised that it must be referring to the ui file, so I made
a very obvious name change to see if it was erroring where I thought it
was. The actual line in the ui script is not line 59 but line 33 where
there is a reference to the resource file (ploppy.qrc) as line 59 is a
width value
line 33: <iconset theme="flaps" resource="icons/ploppy.qrc">
line 59: <width>41</width>
I have attached the ui file if anyone wants a look.
*The import code, which I have as a shelf button is as follows:*
import sys
Dir = 'Z:\\ddtest\\Malc\\burrows_MayaTools\\burrowsMirrorTool'
if Dir not in sys.path:
sys.path.append(Dir)
#print(sys.path)
try: reload(brrwsMirrorScript)
except: import brrwsMirrorScript
brrwsMirrorScript.main()
*main python script code is as follows:*
from PyQt4 import QtGui, QtCore, uic
from pymel.core import *
import pymel.core as pm
from pymel import *
#Path to UI file
ui_filename =
'Z:\\ddtest\\Malc\\burrows_MayaTools\\burrowsMirrorTool\\ui\\brrwsMirrorScript.ui'
form_class, base_class = uic.loadUiType(ui_filename)
class brrwsMirrorScript(base_class, form_class):
def __init__(self):
super(base_class, self).__init__()
self.setupUi(self)
self.setObjectName('brrwsMirrorScript')
self.setDockNestingEnabled(True)
self.connectInterface()
def connectInterface(self):
QtCore.QObject.connect(self.bttn_mirrorCmd,
QtCore.SIGNAL('clicked()'), self.makeMirrorWin)
def makeMirrorWin(self):
mel.eval('global proc brrwsMirrorScript(){polyCube;}')
mel.brrwsMirrorScript()
def main():
global mirrorUi
mirrorUi = brrwsMirrorScript()
mirrorUi.show()
if __name__ == '__main__':
main()
Perhaps, I have used designer resource in the wrong way, but I do not think
so. I was wondering if there is an issue with the read in of the ui file
as it seems to have replaced the .q from the resource line to an
underscore. Anyone have any idea why this is happening
Thanks in advance for any help.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/34928a32-9340-4429-aeec-d8de48cc849e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
brrwsMirrorScript.ui
Description: Binary data
