By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Advice needed: large OpenGL + Widgets Project for Molecular Graphics

P: n/a
I have a problem that I would like to get some advice on from other
Pythonistas. I currently manage a (soon to be) open source project for
displaying molecular graphics for a variety of different programs. To
do this I need to draw pictures of the molecules, typically using
OpenGL, and do some basic control, using some widget set.

The code currently uses GTK, and runs on Macintosh OS X under Fink,
and Linux. I would like to support the "normal" (i.e. non-Fink)
distribution on Macintosh, as well as Windows. I'm currently in the
process of doing the Windows port, and it's been harder than I had
hoped, although I haven't given up quite yet.

But the porting issue is the main problem with the code so far. I'd
like this project to be something that gets other people excited about
Python here, but I'm afraid that the installation issues is going to
make people say things like "see, Java is better after all". So I'm
seriously thinking about switching widget sets sometime down the road,
to try and get a more cross platform application.

One thing that really puzzles me is how rare putting an OpenGL window
inside of a widget seems to be. Togl is either dead or is
dying. Gtk.GLArea is either dead or dying as well. Gtk.GLExt seems to
be doing well, and wxPython.glcanvas works nicely. In making these
module decisions I normally try to figure out what most people do,
with the reasoning that whatever option that is will be the best
supported choice. However, it seems that *no one* is really interested
in putting an OpenGL panel inside of a widget. Please tell me I'm
wrong!

What follows are the options I'm considering. I would be grateful for
any advice other python programmers can offer.

1. GTK/PyGTK/PyOpenGL/GTK.GLArea
Advantages: This is the path of least resistance, since this is
what the program already uses. Currently works well, looks nice,
and seems stable.

Disadvantages: GTK isn't really a standard on Windows, and can be
problematic on other non-Linux platforms (such as Macintosh/Aqua).
Plus, the number of different packages that need to be installed is
daunting. Finally, GTK.GLArea is either dead or dying, so I would
probably have to distribute this module myself.

2. GTK/PyGTK/PyOpenGL/GTK.GLExt
Advantages: Upgrade to the GTK.GLExt method of putting an OpenGL
window inside a widget. Looks better and is supported.

Disadvantages: Need to rewrite some of the uglier code (which
probably needs to be rewritten anyway) that uses GTK.GLArea. Still
requires a long list of modules to be installed. And GTK still is
not a standard library outside of Linux.

3. Tkinter/PyOpenGL/Togl
Advantages: Least amount of modules to install.

Disadvantages: Tk is ugly. Tk is old. Tk doesn't look good on
Macintosh/Aqua. Togl is either dead or dying?

4. wxPython/PyOpenGL
Advantages: Seems to be a healthy, integrated solution to putting
an OpenGL window inside of a widget. Pretty widgets, and lots of
fancy features.

Disadvantages: The OpenGL install still crashed under Windows. A
widget set that not many people use? Also requires the most amount
of code rewrite, although if it's the best option it isn't a
problem.

5. Other ideas:
It is a sign of my own desperation that I'm even considering things
like writing a canvas widget that can draw balls and sticks, and
then just doing the matrix algebra in NumPy, rather than using
OpenGL.

Thanks in advance for any help or sympathy that people can offer.
Jul 18 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
DH wrote:
....
The problem I have though is - can you have an opengl canvas in the
same window with other wxpython controls. I've done this in java,
basic and C, but the wxpython demo only showed opengl animations
running in their own window. This is my problem with vpython and sdl
too. I want something that can be embedded in a tk/wx/qt/gtk window
with other controls, even other opengl canvases. At the C level, it's
just a matter of clipping the drawing and switching the current
drawing context.


This works fine. See the browser sub-package of OpenGLContext for a
demo. See also much simpler demo in
OpenGLContext/tests/wx_with_controls.py, which just puts a button and a
wxPython Context (derived from wxGLCanvas) on a window and uses the
button to start/stop the animation. PyOpenGL and wxPython are both just
thin wrappers around their respective C/C++ libraries, so most of the
functionality in the lower levels is available.
Disadvantages: The OpenGL install still crashed under Windows. A
widget set that not many people use? Also requires the most amount
of code rewrite, although if it's the best option it isn't a
problem.


Yeah, it doesn't work on Windows for me either with python 2.3. It
used to work with python 2.2. Now it complains about not finding glut.


If you encounter a bug like this, please submit a bug-report to the
project so that it can be fixed. As a quick check though, you did
install the GLUT binary package in your system32 directory, right?
PyOpenGL doesn't include the GLUT library itself, only a binding for it.

Have fun,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #2

P: n/a
an***@vredegoor.doge.nl (Anton Vredegoor) wrote in message >
VPython [1] seems to combine all requirements, OpenGl and NumPy
integration, easy to install and use, and at least in my case it makes
one very enthusiastic about 3-d programming in Python.


I'm a long-time fan of VPython, but I didn't think it provided
widgets. Can I use some widget set to make buttons to control
applications?
Jul 18 '05 #3

P: n/a
"Mike C. Fletcher" <mc******@rogers.com> wrote in message news:<ma***********************************@python .org>...
For balls and sticks this is a pretty trivial task. 4th year comp-sci
students are made to do this (well, a lot more) for creating ray-trace
renderers in their computer graphics courses. However, being able to
load everything into the hardware buffers of a video card is pretty hard
to beat as a performance path.
Sorry, I didn't explain my own sarcasm. Writing the code isn't the
problem, it's generating an interface that looks nice and performs
well that is why I think this is only worthy of humorous mention.
Although the JMol project (http://jmol.sf.net) has done a surprisingly
good job with this type of graphics.
Thanks in advance for any help or sympathy that people can offer.

Hmm, sympathy? You get to work on graphics and you want sympathy? Some
of us would *kill* to have the time to work on graphics ;) .

Thanks for putting this in perspective!
Jul 18 '05 #4

P: n/a
"Mike C. Fletcher" <mc******@rogers.com> wrote in message news:<ma***********************************@python .org>...
Rick Muller wrote:
...
3. Tkinter/PyOpenGL/Togl
Advantages: Least amount of modules to install.

Disadvantages: Tk is ugly. Tk is old. Tk doesn't look good on
Macintosh/Aqua. Togl is either dead or dying?

Togl is pretty much history. I'll likely fix the installer one last
time for the next bug-fix release (2.0.2) and then drop the thing. I've
been looking for someone who uses Tkinter+Togl to champion maintenance
of the thing for years and never found anyone interested enough to
bother. I'm not a huge fan of Tkinter either, for that matter.


Help me out with this: is it that the togl project is history, or that
the Python bindings for Togl are history? I've poked around the Togl
website (http://togl.sf.net), and I'm not overwhelmed with new
releases. Plus, there don't seem to be many posts to the mailing list
in the last year.

But I'm amazed that more people don't need to put an OpenGL window in
a graphical widget -- seems like a common task. How do people do this?

Thanks for the responses!
Jul 18 '05 #5

P: n/a
ri*********@yahoo.com (Rick Muller) wrote:
I'm a long-time fan of VPython, but I didn't think it provided
widgets. Can I use some widget set to make buttons to control
applications?


Look in the demos directory. A two-button mouse would be handy.

Anton

Jul 18 '05 #6

P: n/a
Rick Muller wrote:
"Mike C. Fletcher" <mc******@rogers.com> wrote in message news:<ma***********************************@python .org>...

....
Togl is pretty much history. I'll likely fix the installer one last
time for the next bug-fix release (2.0.2) and then drop the thing. I've
been looking for someone who uses Tkinter+Togl to champion maintenance
of the thing for years and never found anyone interested enough to
bother. I'm not a huge fan of Tkinter either, for that matter.


Help me out with this: is it that the togl project is history, or that
the Python bindings for Togl are history? I've poked around the Togl
website (http://togl.sf.net), and I'm not overwhelmed with new
releases. Plus, there don't seem to be many posts to the mailing list
in the last year.

Togl the Tcl/Tk project is moribund, but then, it's very old technology
that's been stable for years. Togl is just setting up a context for
Tkinter and hooking it up to various event handlers. For the most part
all GUI-library interfaces can be similarly static. The only problems
that come up with it in an average year are configuration and
installation ones. It's the Tkinter binding that's on it's way to the
graveyard, precisely because of those configuration and installation
headaches.

For instance, the upgrade of Tkinter to 8.4 in Python 2.3.x broke the
Togl install for us (it's still broken). It's possible to build and
install the widget manually, but the automated installer fails due to
some deep Tk or Tcl or Togl bug. Working around that is fairly trivial,
but it means going back and reworking the installer's Togl code... not a
big deal... but nowhere near the top of my list of priorities for the
few hours I get now and then to work on the project. So, the 8 or 9
line change doesn't get done, and the Tkinter/Togl binding languishes
(and eventually dies). The problems aren't huge, they just don't have
anyone available who's actually using the library and willing to
find/fix them.
But I'm amazed that more people don't need to put an OpenGL window in
a graphical widget -- seems like a common task. How do people do this?

wxPython.

I think there's a few with GTK, Qt and Fox as well, all of which can mix
in widgets fine, but I don't hang out on those user-groups any more to
hear from them and thus be able to say for sure. In all fairness, there
are also lots of people who have, in the past, used Tkinter/Togl, but
since they're not willing to speak up and help with the maintenance I
don't feel the need to plug their platform (in either applicable sense
of the word) ;) .

Have fun,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #7

P: n/a
DH
Yeah, it doesn't work on Windows for me either with python 2.3. It
used to work with python 2.2. Now it complains about not finding glut.

If you encounter a bug like this, please submit a bug-report to the
project so that it can be fixed. As a quick check though, you did
install the GLUT binary package in your system32 directory, right?
PyOpenGL doesn't include the GLUT library itself, only a binding for it.


I never installed OpenGL or GLUT. OpenGL comes with Windows. In python
2.2 everything worked fine. Does the python 2.3 version not weak link
glut or something?
Jul 18 '05 #8

P: n/a
DH wrote:
....
I never installed OpenGL or GLUT. OpenGL comes with Windows. In
python 2.2 everything worked fine. Does the python 2.3 version not
weak link glut or something?


No version of PyOpenGL 2.x has, to my knowledge, ever included GLUT.
Could be you installed it without noticing? It's not a complex process
after all, just drag a single DLL to a directory in the system path.
I've been known to forget doing such things in the past. That said,
could be that something is importing OpenGL.GLUT from the Python side
that wasn't importing it before... don't know what that would be, though.

<shrug>Otherwise engaged at the moment, so little time to explore.</shrug>

Have fun,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/

Jul 18 '05 #9

P: n/a
Just wanted to put a plug for our Python-controlled molecular viewer,
see http://www.cgl.ucsf.edu/chimera/. We use Togl and Tkinter and
while I'm annoyed that my patches to Togl were never accepted, I use
them and they're on sourceforge. There are chimera distributions for
x86-Windows, x86-linux/X11, OS X/X11, OS X/Aqua, Irix/X11, and
Tru64/X11. We've gone to bundling everything up into one
self-extracting zip file (a disk image for OS X) to avoid the hassle of
having the user install the 20 different packages that we depend on.
Chimera is only 90% open source at this time but for anybody who will
really do something with the source, we'll open up the rest (except for
the MSMS package from Scripps that we have no control over).

Good luck,

Greg Couch
UCSF Computer Graphics Lab
gregc at cgl dot ucsf dot edu
Jul 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.