PyQt help

PyQt help

Anonymous
Not applicable
1,926 Views
13 Replies
Message 1 of 14

PyQt help

Anonymous
Not applicable
Sorry, i know this is a python q, but i didn't know where else to post it. I'm trying to get PyQt running under Maya 2k8 and have a few questions:

----
The docs included state that to run PyQt in maya you simply have to do the following:
1. Install everything (PyQt,Qt,Python2.5)
1. Copy the PyQt and SIP related files from Python25/lib/site-packages to Maya2008/Python/lib/site-packages
2. run the following code to test:

import sys
import PyQt4 as qt
app = qt.QApplication(sys.argv)
hello = qt.QLavel("Hello world!",None)
hello.show()


-----
All well and good, but here's what i actually had to do to get PyQt running in Maya:
-----
1. Install everything (PyQt,Qt,Python2.5)
2. Copy everything from Python25/lib/site-packages to Maya2008/Python/lib/site-packages
3. Add a reference in my PYTHONPATH variable to C:/Program Files/Autodesk/Maya2008/lib/site-packages/PyQt4
4. Run the following:

import sys
import PyQt4 as qt
import Qt
# SystemError: dynamic module not initialized properly #
app = qt.QtGui.QApplication(sys.argv)
hello = qt.QtGui.QLabel("Hello World",None)
hello.show()

-----
Note that i have to refer to QApplication and QLabel with their full paths vs what is shown in the doc example.

My question is the obvious, am i missing something? Granted everything works, but the fact that what i'm doing is so diff from the included doc makes me wonder if there's not something wrong with my installs. Thanks in advance
0 Likes
1,927 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable
I am having the exact same problem. I'm running on Windows Vista 64 bit. I recompiled Python, Qt and PyQt. The PyQt standalone examples work fine. In Maya nothing worked until I did what djTomServo did.

Any ideas?
0 Likes
Message 3 of 14

Anonymous
Not applicable
Don't think there is much wrong with your installs since you are almost there.
This may be what is going on...

If in the Qt.py file in your site-packages\PyQt4\ directory, you haven't commented out the line

#from PyQt4.QtDesigner import *

(this may be giving you the SystemError:)
Then it isn't finishing up the import of Qt and bringing it into the * python space thus forcing you to use the longer names.

If there are other import statements after QtDesigner, they may be causing an issue - the examples were created against 4.2.3, but there shouldn't be that much difference.

about the need to append the path to PyQt4 to sys.path...
Do you still need to do this if the import of PyQt4 as qt works correctly? (you'll know it's working if you don't have to use the long names)
It could be something simple like re-starting maya after you copy the files over to maya's site-packages
0 Likes
Message 4 of 14

Anonymous
Not applicable
The thing is I don't have a Qt.py in site-packages\PyQt4\. I have a Qt.pyd. Did I miss something when I installed PyQt? Almost everything in site-packages\PyQt4\ are .pyd files.

Thanks for the help!
0 Likes
Message 5 of 14

Anonymous
Not applicable
I tried this again with Qt/PyQt 4.2.3 instead of 4.3.3 and I get the Qt.py file this time in site-packages\PyQt4\. I comment out the line

from PyQt4.QtDesigner import *

but it doesn't help. Same problem.
0 Likes
Message 6 of 14

Anonymous
Not applicable
You still get the
# SystemError: dynamic module not initialized properly #
?

Can you open up Qt.py, copy the contents into Maya's Python tab and try executing each line individually? (There are maybe 12)
You may need to append - the paths to these modules - to your sys.path during this process.
When does this error occur?
0 Likes
Message 7 of 14

Anonymous
Not applicable
Yes I still get that error message.

I am able to source the Qt.py file line by line ok.

I just run this now and it seems to work better:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
app = QApplication(sys.argv)
hello = QLabel("Hello world!",None)
hello.show()

I left out the other PyQt packages because I didn't need them. Note all the Qt stuff is now in the global namespace.
0 Likes
Message 8 of 14

Anonymous
Not applicable
I finally figured it out...

import PyQt4 as qt

isn't picking up the Qt.py file which brings in EVERYTHING else.

import PyQt4.Qt as qt

does

And then it seems to work as expected.

Understand that this is not recommended work flow - just a quick look to see if it's working.
If you run the app= and the hello= lines again after getting your first widget to show you'll blip Maya out of existence with no warning and no CER. This is expected behavior and that is what the pumpThread module helps you avoid.

Also below I added in a print dir(qt). This shows you what is in the qt namespace and was helpful in working out the issue.

import sys
import PyQt4.Qt as qt
print dir(qt)
app = qt.QApplication(sys.argv)
hello = qt.QLabel("Hello world!",None)
hello.show()
0 Likes
Message 9 of 14

Anonymous
Not applicable
That works great. Thanks John!
0 Likes
Message 10 of 14

macgio
Explorer
Explorer
Hi,

I have been trying to build Sip and PYQT4 for 64 bit python but without success, have been googling for quite bit and got here, irony it was because of Maya that I wanted to build PyQt for 64bit.
Could anyone share with us how to build SIP and PyQt4 for python 64bit?

Thanks in advance
0 Likes
Message 11 of 14

Anonymous
Not applicable
It might help to provide some more details about the problems you're having. Platform, Dev environment etc...
0 Likes
Message 12 of 14

macgio
Explorer
Explorer
The platform is Xp64 bit, the dev environment that I have been using is MinGw tried the 32 bit and 64 bit options, also tried to compile sip with Visual C++ 2008 express.
With the latest snapshots of PyQt and SIP

Basically I have been following this guide:
http://www.diotavelli.net/PyQtWiki/BuildPyQt4Windows

Thanks for the help.
0 Likes
Message 13 of 14

Anonymous
Not applicable
Hi There i am also trying to recompile / get a compiled version of PyQt 64 Bit for Windows XP. Has anyone had any luck and would like to share?
0 Likes
Message 14 of 14

macgio
Explorer
Explorer
Hi,

I found a guide here, http://blog.shadowgears.com/2008/10/making-qt4-dance-with-msvc-2008.html but the only way of compiling for xp64 bit using MSVC is with the standard MSVC, the express edition just compiles for 32bit .

Hope this helps, cheers,
MacGio
0 Likes