Python-based browser plugins?

Terry Hancock hancock at anansispaceworks.com
Thu Oct 31 23:13:12 EST 2002


Cameron Laird wrote:
> I can hardly overemphasize how difficult it is
> to write a plugin nowadays.  Compatibility be-
> tween Microsoft and Mozilla ... well, I'll just
> say that I'm almost certain you're better off
> doing anything else, and certainly learning Java,
> than trying this approach, however reasonable it
> seems.

Thanks for the information and suggestions. It does indeed appear that 
implementing in Java is the only really viable option, though I'm still 
interested in the Python/SDL concept -- mostly because it just sounds cool 
and it might be able to share code with another project I wanted to work on.

Of course, it seems to me that you don't really want to write "Python 
PlugIns" , but rather a "Python Applet Interpreter Plugin" that would 
interpret restricted or unrestricted python code loaded from a URL -- then 
you just write Python Applets for it.  If you pick a standard backend 
library like SDL for graphics, you'd get cross-platform support rather 
nicely. Of course presumeably there'll be some fuss getting SDL to paint 
its graphics into the browser window. 

If you don't care about that, of course, you could just use the unadorned 
Python interpreter and just provide instructions for configuring different 
browsers to run it as a "helper app" (actually maybe you want a 
restricted-execution-only version of the interpreter for that?).

I'm not seriously worried about learning Java for this (and I plan to cheat 
with liberal use of Jython, anyway). The issue is avoiding any non-free 
lock-in problems.  I always knew that Java2 was technically somewhat trying 
(supposedly you can run it in Netscape 4.x -- IF you download and install 
the right plugin), but it seems that it also may have licensing issues 
which will get in the way of having a free implementation.

>From the responses I've gotten, it sounds like it *is* possible to stick 
with Java 1.1 + Jython.  Apparently there are a couple of free Java 1 
clones which are fairly useable. I want to add a design requirement of 
working correctly on at least one of these (which I hope is not too harsh a 
demand).

I did found the following toolkit links for Free GUIs for Java:

http://www.thinlet.com
http://www.erights.org/download/swt
http://dog.net.uk/knife/gui.html

Only SWT seems to have a rich-text widget (called StyledText) already 
implemented, and it's a little simplistic (actually it just has one style 
for the text -- but you could make a rich-text widget by combining them, I 
would think).  Unfortunately, SWT requires native code components, so it's 
probably not so great for this application (although that's probably no 
worse than the C-Python solution in complexity).

It seems from the API that implementing a rich-text widget directly in AWT 
would be pretty complicated -- I think you'd have to actually paint the 
text in using the java.awt.Graphics.drawString method and handle your own 
pixel-math.  That's a bit low-level for what I wanted, and it'll add time 
to the project. Let's just say, I'd hate to do it if it were already done.

This is getting a little too Java for c.l.p, though so I guess I'd better 
take it elsewhere. I need to do some more web-searches too, now that I have 
a better handle on what to look for.

Cheers,
Terry


-- 
Anansi Spaceworks
http://www.anansispaceworks.com



More information about the Python-list mailing list