Using pyglet.graphics in wxPython

Post here if you need help with creating a Graphical User Interface in Python.

Using pyglet.graphics in wxPython

Postby hrs » Sun Apr 21, 2013 8:10 pm

Hi,

What does pyglet.graphics.draw() draw to? Is it possible to let it draw on a wx.glcanvas? Or how can you integrate it?
What little examples there are (http://pastebin.com/fMjUNV6H) doesn't work here (maybe because it uses shader and anti aliasing stuffs that arent supported by my driver yet) and it uses pyglet.gl instead of pyglet.graphics.

If I wanted to have something like this in a wxPython application, how can I achieve that?

Code: Select all
import math
import pyglet

window = pyglet.window.Window()

N_LINES = 200

def a_drawing():
   lines = []
   for phi in xrange(N_LINES):
        lines.append(50*math.sin(0.02*phi)+250)
        lines.append(150*math.cos(0.03*phi)+250)
        lines.append(100*math.sin(0.04*phi)+250)
        lines.append(100*math.cos(0.03*phi)+250)
   return lines

@window.event
def on_draw():
    window.clear()
    drawing = a_drawing()

    pyglet.graphics.draw(2*N_LINES, pyglet.gl.GL_LINES, ('v2f', drawing))

pyglet.app.run()
hrs
 
Posts: 86
Joined: Thu Feb 07, 2013 9:26 pm

Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests