Getting a pyglet window onto a Tkinter frame/canvas/etc

1,926 views
Skip to first unread message

tleeuw...@gmail.com

unread,
Aug 28, 2007, 6:49:36 PM8/28/07
to pyglet-users
Is this possible?

We have a Tkinter application and it would be great to use pyglet's
functionality in an embedded way. Is it possible to pack (or otherwise
attach) a pyglet window into a Tkinter frame or canvas?

Cheers,
-T

Alex Holkner

unread,
Aug 29, 2007, 11:04:51 AM8/29/07
to pyglet...@googlegroups.com

On 30/08/2007, at 12:45 AM, Alex Holkner wrote:

> You can use Tkinter to create the OpenGL context (for example,
> PyOpenGL contains a Tk widget, or search "tkinter opengl" for more
> examples), then use pyglet's gl, image, audio, video and font modules.

On second thought, the image and font modules will be looking for an
active context and won't find one. You should be able to create a
"pretend" context to represent the one created by Tk::

from pyglet import gl
c = gl.Context()
c.set_current()

Let me know how it goes.

Alex.

Alex Holkner

unread,
Aug 29, 2007, 10:45:23 AM8/29/07
to pyglet...@googlegroups.com

It depends what functionality you're after. You can use Tkinter to

create the OpenGL context (for example, PyOpenGL contains a Tk
widget, or search "tkinter opengl" for more examples), then use
pyglet's gl, image, audio, video and font modules.

You will still need to handle events through Tkinter though, so won't
be able to make use of anything in pyglet.window.

Alternatively, you could use one or more separate pyglet windows in
the usual way in addition to the Tkinter GUI (which would be in its
own window).

Cheers
Alex.

Reply all
Reply to author
Forward
0 new messages