Use pythonOCC with PyQt4 under MacOSX Snow Leopard (10.6)

The OpenCASCADE library is built upon X11. It doesn’t use Cocoa/Carbon. In order to be able to use the 3D viewer of pythonOCC with PyQt, you must first install Qt4-x11 and then PyQt4.7.

First, from the finkproject, download/install the qt4-x11 package. You can use finkcommander, a graphical frontend to fink, to manage your fink packages. Select the package named ‘qt4-X11’, install from source, and just be patient. When the build is achieved, your fink commander window should look like that:

The Qt4.5.2 libraries have been installed to /sw/lib/qt4-X11. Add the following line to your .bash_profile:

export PATH=$PATH:/sw/lib/qt4-x11/lib/:/sw/lib/qt4-x11/bin/

To check that your Qt installation is clean, just try to launch Qt Designer:

thomas-macbookpro:bin thomas$ designer

The next step is to install PyQt4. You will find below a link to a precopiled binary of PyQt4.7 that works with the previous installation.

PyQt4.7-MacOSX-SL-64.zip (11.5Mb)

Just extract the content of this file to /Library/Python/2.6/site-packages and you should get done. Test the installation (no linkage errors):

Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from PyQt4.QtCore import *
>>> from PyQt4.QtGui import *
>>>

You can run one of the pythonOCC samples. The PyQt4 package should be automatically detected. For instance, running the Geometry.py sample (/samples/Level1/Geometry) :