[Edu-sig] Python applets, was (re: Why is Logo popular, while Python isn't?)

Terry Hancock hancock@anansispaceworks.com
Fri, 22 Nov 2002 10:32:03 -0800


On Friday 22 November 2002 06:20 am, Arthur wrote:
> >And other than needing to compromise on speed issues (I am doing 3d
> graphics) I have yet to come across anythng I >wanted to accomplish that I
> couldn't  get done in Python in a way that ended up seeming succinct and
> elegant.  Though I am >not doing anything tremendously sophisticated, of
> course.

I bet you are, actually. You probably just don't know what to call it. ;-)
There are advantages to learning the terminology -- but, just as with 
grammar, you don't have to be aware of it to use it.

> I should add to that, the ability to do something equivalent to Java
> web-based applets - that is without giving up my access to C based Python
> libraries, like Numeric and VPython.
> 
> Not a feature request - just verbalizing.

I am, however, working on something that would allow you to run a GUI Python 
program like a Java program (on Jython) OR as a python application without 
changing the code.  I am aiming to have this ready before the end of the year
at the latest, as I plan to begin developing for it next year as the client 
side of my current project ( http://www.anansispaceworks.net/NaryaInfo/ ).

You can, of course, currently write two versions of a program to run in these 
two environments now (Jython provides this, http://www.jython.org ), but 
there is no shared GUI environment or even canvas object. The mapping between 
the different available packages isn't that complicated, but no one has 
actually made the leap of spanning them.

If you are content to force your users to download Sun's Java plugin so they 
can run Java2+Swing applets, then you *can* code to AnyGUI and use the 
Java-Swing backend for the web, and any of several GUIs for running natively.
But that won't run in "stock" proprietary browsers or free browsers 
(generally speaking, though, free browsers require a Java OJI plugin to run 
any kind of Java).

My research says the easiest solution is to write a Jython+Java1+AWT renderer 
for PyUI ( http://pyui.sourceforge.net ), and to improve the existing 
PyGame+SDL renderer (which should support at least Linux, Unix, Windows, Mac, 
BeOS, and should be portable to just about anything), so that they are truly 
100% compatible.  This looks like 200 - 500 lines of Python code added to 
PyUI.

Then application/applets can be written on PyUI directly  -- OR, one could 
finish the PyUI backend for AnyGUI ( http://anygui.sourceforge.net ), and 
code on the AnyGUI API (which gives the end-user the additional possibility 
of running the application with wxWindows, Tkinter, PyGTK, and other Python 
GUIs if they prefer).

Unfortunately, this is unlikely to work for something like VPython (unless 
you are prepared to do a *lot* of work to port it), which uses extension 
modules.  Would love to see that work, of course -- but it's a little beyond 
me. ;-D

I understand that Numeric has in fact been ported to Jython (as a Java 
extension), which is understandable considering that Jython and Numeric were 
written by the same person. I don't have details on that, though.

Someday, it might be possible to have a Python plugin that runs Python 
applets, just as the Sun Java plugin runs Java2 applets.  But my initial 
research into that suggests it will take a lot more work.  Part of the 
attraction of the approach I'm taking, though, is that it makes such a 
solution viable, and creates a motivation to create the applets that such a 
system would run. If and when there is a supply of applets that could be sped 
up and/or extended by a native Python applet plugin, there will be a demand 
to create one.  This is one path to a Free applet platform, and it would be 
able to run native extension modules, as you want.

The other is making the KaffeOJI or other Free JVM fully compatible.  But 
that of course, won't run native extension modules, nor would it be as fast. 
That's perhaps reason enough to prefer the native Python applet plugin 
approach.

I'm getting a little off-topic here, but I do think this will be good for 
education, by making the software more accessible. 

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com