[Edu-sig] PySqueak: pyGTK & Cairo & pygtkglext (OpenGL) next?

Paul D. Fernhout pdfernhout at kurtz-fernhout.com
Sat Jun 3 01:00:14 CEST 2006


Short version:

Would people here be willing to install PyGTK 2.x and pygtkglext (OpenGL 
on GTK) and related files on their machines *if* there was a Python-based 
software package they *really* wanted to use?  Mac and Windows are of 
issue mainly, since GNU/Linux probably is probably trivial install. Does 
anyone under Mac or Windows have happy experience doing that for either 
PyGTK or the 3D extension pygtkglext (either in a home or a lab setting

Long version:

While exploring the issue of restricted evaluation environments (I am 
considering having PataPata windows communicate by passing textual Python 
programs :-) I came across this on Python 3.0 wish list:
   http://wiki.python.org/moin/PythonThreeDotOh
"Include wxPython or PyGtk in core library [for Py3K]? Would anygui also 
be a good option. Place Tkinter into legacy status? (Musing again. Seems 
like we need a more mainstream, higher performance standard GUI in the 
core distribution. wxPython is very popular, so I suggested it as an 
option. The PyGtk is an awesomely thin layer over the C library and it 
makes Gtk objects look like native Python classes.)"

Now given the wx bashing lately (including from the OSI Chandler project I 
linked to), and the Cairo blessing(?), that PyGTK comment got me thinking. 
Also, Francois mentions somewhere he wanted to move beyond TK for his work.

Well, I just implemented a rudimentary TK proof-of-concept version of 
PataPata. And the inspector is live in the world. And I am not as 
dissatisfied with the look or performance of TK as I thought I would. 
[Though of course it still needs more work.(*)] BUT, I read that, and the 
squeaky gears in my brain start creaking, thinking, "hmmm, Python2.x, GTK, 
and Cairo?".

And after a Google, this link has me pretty excited:
  Writing a Widget Using Cairo and PyGTK 2.8
  http://www.pygtk.org/articles/cairo-pygtk-widgets/cairo-pygtk-widgets.htm
and so I tried the file there and it ran on my Debian machine without 
needing to install anything (though I have in the past installed lots of 
stuff, so I don't know about stock distributions of Debian Python, but 
clearly this support is just an apt-get away apparently, at least as far 
as Cairo).

 From the link:
"Cairo is a powerful 2-dimensional graphics library designed to support a 
number of modern graphics techniques including stroking, alpha blending 
and antialiasing. It supports multiple output formats, which allows 
developers to use the same code to display graphics on the screen, print 
them to the printer or accelerate them with OpenGL. As of GTK+ 2.8, GTK+ 
has been integrated with the Cairo 1.0 rendering library, giving 
developers access to this flexible graphics API. PyGTK added Cairo support 
in the 2.8 version. See the wiki for further info."

There is also PyGtkGLExt for Python 3D OpenGL support (though I have not 
tried it):
   http://gtkglext.sourceforge.net/
Example Python 3D program:
   http://mail.gnome.org/archives/gtkglext-list/2004-April/msg00012.html

I really like the idea of using something like Cairo if it is picking up 
steam (see my previous post in "Elementary Graphics Library"). And 3D 
support sounds good too (rather than the TK developers leaving behind TK's 
togl :-( ). As I reflect on it, I am also willing to trade-off 90% of 
popularity for PataPata right now in terms of easy install for Mac/Windows 
*if* it would make my life under Debian easier to get something neat 
working that I and a few others want to use, and has the promise of 
picking up easy install in a couple of years (like if Python3K went with 
pyGTK as a default). Plus I already have wx and tk versions, so it's not 
like people could not try the basic idea on those platforms.

The issue is more a matter of where I shoudl be putting more energy, since 
if I could use GTK and Cairo and PyGtkGLExt for cross-platform widgets, 2D 
graphics, and 3D graphics, then long-term it makes it easier for me to 
maintain a system using common cross-platform standards, especially 
because I don't have to put in much of an extra dumbed down 
"compatibility" layer. For example, I can just pass GTK events around 
rather than translate them to my own; I can use Cairo calls rather than my 
own simplified 2D context; I can assume everyone is using the same way to 
access 3D graphics rather than try to abstract initialization out; and so 
on. Now, this compatibility issue is a bit more complex, because I would 
like to run PataPata things as applets on Jython, but I'm not sure that is 
important enough at the start to prevent using an otherwise promising 
cross-platform solution CPython works with, given that I'm not sure how 
important Applets really are, and in the future there might be more 
person-power to make some GUI object wrappers that runs both on GTK and Swing.

Obviously, I could search the PyGTK and gtkglext list archives:
   http://www.daa.com.au/mailman/listinfo/pygtk
   http://mail.gnome.org/mailman/listinfo/gtkglext-list/
but I was curious what people here had to say from an educator context.
There are also other cool software projects like PythonCAD that use PyGTK:
   http://www.pythoncad.org/

It woudl be more work to switch yet again, but I find just about anything 
can be made right if you are willing to start over a couple of times. :-) 
Or, in short, having done the sensible thing of deciding to "Run away!" to 
TK when faced with all the choices in the "Elementary graphics library" 
thread, I'm wondering now whether the "Holy Hand Grenade" sacred relic 
Brother GTK Maynard from Cairo carries:
   http://en.wikipedia.org/wiki/Holy_Hand_Grenade_of_Antioch
could get the PataPata entourage safely past the killer rabbit of 
cross-platform issues. :-)

I'm certainly not the only one asking that question right around now:
   http://www.myddrin.com/trashdeerwood/index.cgi/Development/67
   http://wiki.osafoundation.org/bin/view/Jungle/TechnologyChoices

I've looked in the edusig list's archive and pyGTK is mentioned in about 
30 posts over about six thread. Dave Reed on 12/26/2004 05:30 PM was very 
encouraging of is a year and a half ago.
   http://mail.python.org/pipermail/edu-sig/2004-December/004302.html
He wrote:
"I've used it on Linux/Solaris, Windows XP and Mac OS X and it works fine 
on all of them. If I was coding for Windows only, I'd probably pick a
different widget set, but since I have little interest in programming
for Windows right now, I think glade/gtk is a great combination."
So it seems like by now it should be a fairly safe choice?

So, my question to educators or parents here using Mac and Windows is, are 
you willing to go to the trouble (or have you already?) to make sure PyGTK 
and a >= 2.8 GTK are running on your system at school or at home *if* 
there was an application you really wanted to use? Would using PyGTK & 
PyCairo & pygtkglext be more a show stopper or an incentive? I'm not 
saying you would do it right now, just more, would you or could you do it 
if you really wanted to? If so, or if there is at least a sense that it is 
possible, I think I will be very tempted to (once again) make another 
version of PataPata (PySqueak) that is GTK oriented. I've never tried to 
use PyGTK on the Mac or Windows, so any feedback on it's current use in an 
educational context of for packages you use for other things would be 
appreciated (i.e. do you already use packages that depend on PyGTK?)

--Paul Fernhout
(*) The TK version still has a bug retrieving text from a multi-line TK 
text box. And everything is sloppily floating around. And no save/load 
world buttons yet.


More information about the Edu-sig mailing list