I heard that the PyOpenGL project is pretty much dead. However, the good news is that wxPython has incorporated the Open Graphis Library (OGL). Here is an example:

# the Open Graphics Library (OGL) is now pretty well 
# integrated with wxPython

import wx
import wx.lib.ogl as ogl

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__( self, None, wx.ID_ANY,
            title="explore wx.lib.ogl stuff", size=(400,300))

        canvas = ogl.ShapeCanvas(self)
        canvas.SetBackgroundColour("yellow")

        diagram = ogl.Diagram()
        # marry the two ...
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        # create some standard shapes ...
        # (check how creation order affects overlap)
        circle = ogl.CircleShape(100.0) # radius
        circle.SetX(75.0)  # center x
        circle.SetY(75.0)
        circle.SetPen(wx.RED_PEN)
        circle.SetBrush(wx.CYAN_BRUSH)
        canvas.AddShape(circle)

        text = ogl.TextShape(250, 30)  # (w, h)
        text.SetX(180)  # center x
        text.SetY(240)
        text.AddText("you can drag the circle or the text")
        canvas.AddShape(text)

        diagram.ShowAll(True)

        # use a sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        # canvas will grow as frame is stretched
        sizer.Add(canvas, 1, wx.GROW)
        self.SetSizer(sizer)
        #self.SetAutoLayout(1)


app = wx.App()
ogl.OGLInitialize()
MyFrame().Show()
app.MainLoop()
This article has been dead for over six months. Start a new discussion instead.