We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Jython Integration
Page Index Toggle Pages: 1
Jython Integration (Read 844 times)
Jython Integration
Mar 26th, 2006, 6:28am
 
I'd like to be able to access the basic drawing API used by Processing to create an output-only drawing engine for Jython.  (Yes, I know, I started a Python Integration chat earlier, but recent work by our team has raised use of Jython as a possibility)

I think I'd need to use the PGraphics2 interface rather than the PApplet because I don't think there's a way to subclass PApplet correctly from Jython .. but I'm not certain of that.  PApplet.main() needs a class file, for example.

So the question is: Is there a chunk of plain PGraphics code I can look at in Java that could translate to Jython easily?  Mainly how to create a window for a PGraphics object I think is the main problem.  I searched but didn't find an example that didn't use the PApplet as well.

Any help appreciated!

Owen
Re: Jython Integration
Reply #1 - Mar 26th, 2006, 8:39am
 
If Jython is anything like Rhino (javascript engine for java), then you should be able to make a processing program that instantiates Jython, and then load and perhaps compile a script (assuming there is some method that is optimized for multiple executions), then simply run that script in draw().  You could probably export all the processing methods to jython, alternatively you can probably make the PGraphics available in the global namespace.  Depending how much control Jython gives you, should should be able to call specific functions within your python script.

Doesn't exactly answer your question, but it might be another approach to consider.

Marcello
Re: Jython Integration
Reply #2 - Mar 26th, 2006, 10:52pm
 
cello wrote on Mar 26th, 2006, 8:39am:
If Jython is anything like Rhino (javascript engine for java), then you should be able to make a processing program that instantiates Jython, and then load and perhaps compile a script (assuming there is some method that is optimized for multiple executions), then simply run that script in draw().  You could probably export all the processing methods to jython, alternatively you can probably make the PGraphics available in the global namespace.  Depending how much control Jython gives you, should should be able to call specific functions within your python script.

Doesn't exactly answer your question, but it might be another approach to consider.

Marcello


Hi Marcello .. grazie mille per l'aiuto.

This is a helpful idea .. sorta inverting the approach I was looking for.  I'll cogitate a bit because there is such an embedding stunt for Jython I think.

BTW: One further idea I've had is to look at how the Processing IDE actually launches the PApplet .. this might clarify  for me a bit how PApplet, PGraphics, etc work together.

But the embedding idea is a new direction that might be quite effective, thanks!

Owen
Page Index Toggle Pages: 1