Using PyQT and OpenGL

David Boddie david at boddie.org.uk
Wed Jul 26 18:33:10 EDT 2006


Peter TB Brett wrote:

> Although the PyQt documentation indicates that QGLWidget & friends have
> been ported to Python for the PyQt bindings, I'm not entirely sure what's
> necessary to make the normal OpenGL/GLUT interface available.
>
> Does PyQt work okay with PyOpenGL?  Or is a more complicated workaround
> needed?

PyQt works fine with PyOpenGL. The QtOpenGL module only provides
widgets and other features for use with an existing OpenGL library.
It doesn't provide or expose its own OpenGL implementation.

For example, you would typically subclass QGLWidget and reimplement
the initializeGL(), paintGL() and resizeGL() methods to handle
initialization, painting (with PyOpenGL calls) and updates to the
transformation matrices. Since QGLWidget is itself a subclass of
QWidget, you can use standard PyQt code to handle user input
and other non-OpenGL tasks.

> If anyone has experience with working with Python/Qt/OpenGL and can offer
> any advice I'd much appreciate it.

Take a look at the examples provided in the PyQt distribution to get
started.

Good luck!

David




More information about the Python-list mailing list