469,595 Members | 2,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,595 developers. It's quick & easy.

Python GUI + OpenGL

Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

regards,
Achim
Mar 2 '07 #1
9 7256
Achim Domma wrote:
Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?
PyQt, but then there is the licensing question of course.

Diez
Mar 2 '07 #2
Achim Domma wrote:
Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

regards,
Achim
PyOpenGL 3.x (currently in alpha state, but reasonably usable) works on
Python 2.5, there are no binaries because the system no longer requires
binary versions. Install the setuptools package, then run easy_install
PyOpenGL and the egg file should be downloaded and installed to your
machine. The current version doesn't package GLE along with the code,
however, so you'll have to find a DLL for that if you need it.

HTH,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Mar 2 '07 #3
On Mar 2, 9:17 am, Achim Domma <d...@procoders.netwrote:
I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?
You could use pygtk + pygtkglext.

http://pygtk.org/
http://gtkglext.sourceforge.net/

Regards,
Jordan

Mar 2 '07 #4
Dag
On Fri, 02 Mar 2007 18:30:34 +0100, Diez B. Roggisch <de***@nospam.web.dewrote:
Achim Domma wrote:
>Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

PyQt, but then there is the licensing question of course.
I'm facing a similar problem. Would you care to explain why PyQt is
better in this particular case. I've used both PyQt and wx for 'normal'
GUI programming (but I'm more familiar with wx) so I know about their
difference in general. But why is PyQt better than wx for working with
OpenGL?

Dag
Mar 5 '07 #5
You don't necessarily need an OpenGL wrapper like PyOpenGL. If you
only use a handful of OpenGL functions, it would be relatively
straight-forward to make your own, using ctypes.

Here is what it would look like:

from ctypes import cdll, windll, c_double, c_float, c_int

GL_POINTS = 0x0000
GL_LINES = 0x0001
GL_LINE_LOOP = 0x0002
GL_LINE_STRIP = 0x0003
GL_TRIANGLES = 0x0004
GL_TRIANGLE_STRIP = 0x0005
GL_TRIANGLE_FAN = 0x0006
GL_QUADS = 0x0007
GL_QUAD_STRIP = 0x0008
GL_POLYGON = 0x0009

gl = windll.LoadLibrary("opengl32")

glEnd = gl.glEnd
glEnd.restype = None

glBegin = gl.glBegin
glBegin.argtypes = [c_int]
glBegin.restype = None

glVertex2f = gl.glVertex2d
glVertex2f.argtypes = [c_double, c_double]
glVertex2f.restype = None

glColor3f = gl.glColor3d
glColor3f.argtypes = [c_double, c_double, c_double]
glColor3f.restype = None

glClear = gl.glClear
glClear.argtypes = [c_int]
glClear.restype = None

glClearColor = gl.glClearColor
glClearColor.argtypes = [c_double, c_double, c_double, c_double]
glClearColor.restype = None

glViewport = gl.glViewport
glViewport.argtypes = [c_int, c_int, c_int, c_int]
glViewport.restype = None

[...etc]

Regards,

Laurent

On Mar 2, 4:17 pm, Achim Domma <d...@procoders.netwrote:
Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

regards,
Achim

Mar 5 '07 #6
Dag wrote:
On Fri, 02 Mar 2007 18:30:34 +0100, Diez B. Roggisch <de***@nospam.web.de>
wrote:
>Achim Domma wrote:
>>Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

PyQt, but then there is the licensing question of course.

I'm facing a similar problem. Would you care to explain why PyQt is
better in this particular case. I've used both PyQt and wx for 'normal'
GUI programming (but I'm more familiar with wx) so I know about their
difference in general. But why is PyQt better than wx for working with
OpenGL?
I didn't say so. I just pointed out an alternative, as the OP had issues
with obtaining binary packages for wx + py2.5

Beside that, I do love the Qt library and would always use it in preference
to wx, but this is a general thing and by no means tied to the
OpenGL-programming. After all, that actually is done using PyOpenGL

Diez
Mar 5 '07 #7
On 3/5/07, Diez B. Roggisch <de***@nospam.web.dewrote:
Dag wrote:
On Fri, 02 Mar 2007 18:30:34 +0100, Diez B. Roggisch <de***@nospam.web.de>
wrote:
Achim Domma wrote:

Hi,

I'm developing a GUI app in Python/C++ to visualize numerical results.
Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
are no windows binaries for Python 2.5 for quite some time now.

I need a OpenGL context without restrictions and some settings dialogs.
Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
of tools/libs?

PyQt, but then there is the licensing question of course.
I'm facing a similar problem. Would you care to explain why PyQt is
better in this particular case. I've used both PyQt and wx for 'normal'
GUI programming (but I'm more familiar with wx) so I know about their
difference in general. But why is PyQt better than wx for working with
OpenGL?

I didn't say so. I just pointed out an alternative, as the OP had issues
with obtaining binary packages for wx + py2.5
I believe he was having trouble with binary packages for PyOpenGL,
wxPython has 2.5 binaries and has since it was released.

That said, it's my understanding that the most recent version of
PyOpenGL uses ctypes and no longer requires a windows binary, which is
why they are not provided.

Also, if you're writing a C++/Python app on Windows then you must have
the correct environment to build Python extensions, so even if my
understanding is incorrect, you should be able to build PyOpenGL via
distutils with minimal if any trouble.
Beside that, I do love the Qt library and would always use it in preference
to wx, but this is a general thing and by no means tied to the
OpenGL-programming. After all, that actually is done using PyOpenGL
wx and Qt support OpenGL in essentially the same manner. I believe he
took from your earlier post that Qt had its own built in OpenGL
wrapper (and thus didn't rely on PyOpenGL) but to my knowledge that is
not correct.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
Mar 5 '07 #8
On Monday 05 March 2007 18:22, Chris Mellon wrote:
On 3/5/07, Diez B. Roggisch <de***@nospam.web.dewrote:
>Beside that, I do love the Qt library and would always use it in
preference to wx, but this is a general thing and by no means tied to the
OpenGL-programming. After all, that actually is done using PyOpenGL

wx and Qt support OpenGL in essentially the same manner. I believe he
took from your earlier post that Qt had its own built in OpenGL
wrapper (and thus didn't rely on PyOpenGL) but to my knowledge that is
not correct.
Yes, you need PyOpenGL (or any other suitable OpenGL wrapper) to use
OpenGL with PyQt. Qt itself doesn't provide its own API for OpenGL; you
just use the implementation available on your system.

It is possible to get OpenGL-rendered 2D graphics without having
PyOpenGL installed; you just paint on a QGLWidget in the usual way.
However, I suspect that the original poster wanted to render 3D
graphics, so Python bindings to the system's OpenGL library are still
required.

David
Mar 6 '07 #9
>I didn't say so. I just pointed out an alternative, as the OP had issues
>with obtaining binary packages for wx + py2.5

I believe he was having trouble with binary packages for PyOpenGL,
wxPython has 2.5 binaries and has since it was released.

Ah, I didn't read it that way as the OP didn't say exactly _what_ package he
was missing. Obviously if it's PyOpenGL then using Qt won't buy him much...
Diez
Mar 6 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by max(01)* | last post: by
4 posts views Thread by Dave | last post: by
reply views Thread by Simon Bunker | last post: by
3 posts views Thread by jg.campbell.ng | last post: by
852 posts views Thread by Mark Tarver | last post: by
13 posts views Thread by Thomas Troeger | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.