When you use the dynamic uic module with Qt Designer UI files, it translates the xml format into a Python UI module and imports it. Part of this conversion is to also tranlate a reference to a resource qrc file into a python import statement. But what I don't think it is doing for you, is actually converting the qrc file. Forgive me, but I never really use the dynamic UI loading so I can't be certain, but that is my guess. If you are going to use a qrc file, then I think you will need to convert it using the pyrcc tool from the command line. It is similar to using pyuic from the command line instead of dynamically at import. It expects you to use an output name of ploppy_rc.py This will produce a module with all of your images encoded into it. Now there may be the equivalent of a dynamic rcc module to do this at import, but I am not familiar with it. When I was still using Designer, I had always used the pattern of pre-generating my UI and rc files manually as they changed.
On Thu, 6 Nov 2014 10:54 PM Credible Mulk <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/python_inside_maya/34928a32-9340-4429-aeec-d8de48cc849e%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAPGFgA0Ayp6z-CJR2e5PcPK6amfmJ0Re9u54JnvFnoqvoPFRjA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
