PyQt5, OpenGL, where to start, minimal example code?

John Ladasky john_ladasky at sbcglobal.net
Sun Oct 2 21:13:33 EDT 2016


Hi there,

I am making my first attempt at 3D rendering.  My system configuration:

OS     : Ubuntu 16.04 64-bit
Python : 3.5.1
Qt     : 5.5.1
PyQt   : 5.5.1
OpenGL : 4.5.0 (I have a modern GPU)

All software was installed from the Canonical repository.  I didn't build any binaries myself.

>From my reading, I have concluded that Qt, PyQt, and OpenGL are all rapidly-evolving, and huge, software packages.  There may be compatibility problems, and relevant examples with the right software combination may be hard to find.

Two weeks of searching web pages hasn't turned up a single example which demonstrates PyQt5 doing something simple in 3D with OpenGL that I can study.  My own attempt to write such a program displays my QOpenGLWidget subclass instance, and calls the methods I defined, but throws this exception:

ImportError: No module named 'PyQt5._QOpenGLFunctions_4_5_Compatibility'

Here's a snippet of the offending method of my QOpenGLWidget:

    def initializeGL(self):
        ctx = self.context()  # This works, ctx is a PyQt5.QtGui.QOpenGLContext
        print(ctx.versionFunctions())  # ImportError occurs here

Searching for that ImportError, I found a page which says that error occurs when "you have a more capable version of OpenGL than PyQt has support for", but no advice is offered on how to fix that problem.

I like the idea of using PyQt5, because I'm getting pretty familiar with it, BUT I am open to trying any quick and clear route to 3D rendering.  I would appreciate the community's recommendations.  Thanks.



More information about the Python-list mailing list