Problems I was having with incomplete images have been fixed in the current version of the web library, available in shoebots mecurial repository.
Using Processing from Jython is a promising idea, so I took the base from this post on backspaces.net where they explained how to use Jython and built on it a little.
This is great as Shoebot/Nodebox have great libraries for data manipulation, while processing is more focused on graphics.
The result is the attached Netbeans project which demonstrates using the nodebox web library and drawing with processing.
The glue code is in slowcessing.py
Theres a special version of PApplet (PJApplet), and 'pj_frame' which can put this in a JFrame.
The other method is 'shoebot_imports' adds the shoebot imports to the library path
In case anybody doesn't want to download the whole project, heres the code:
from slowcessing import PJApplet, pj_frame, shoebot_imports
from processing.opengl import *
Download images in the background and add them to a list
def __init__(self, search, size):
self._search = search
self._image_size = size
def _image_downloaded(self, path):
p = PJApplet()
for image in self._search:
class WebTest (PJApplet):
self.size(400, 400, self.P3D)
self.images = ImageQueue(web.morguefile.search("sweets", max=1), size='small')
y = (self.height * 0.2) - self.mouseY * (len(self.images) * 0.58)
for image in self.images:
self.image(image, 20, y)
y += image.height
if __name__ == '__main__':
from javax.swing import JFrame
from processing.core import PApplet
# rqd due to PApplet's using frameRate and frameRate(n) etc.
def getField(self, name):
def pj_frame(pj_applet, **kwargs):
from time import sleep
frame = JFrame(kwargs.get('title', 'Slowcessing'))
frame.defaultCloseOperation = kwargs.get('defaultCloseOperation', JFrame.EXIT_ON_CLOSE)
frame.resizable = kwargs.get('resizable', False)
panel = pj_applet()
while panel.defaultSize and not panel.finished:
frame.visible = 1
Allow import of the shoebot libraries
##APP = 'shoebot'
DIR = sys.prefix + '/share/shoebot/locale'
##_ = gettext.gettext
LIB_DIR = sys.prefix + '/share/shoebot/lib'
There are some things I couldn't work :
The callback to say that images have been downloaded happens before the whole file is available, for this reason there are grey parts on the images on the first run.
While I did manage to fix things to get this working in Jython and get Morguefile working, I had a lot of trouble understanding what was going on here.
Cheers to Tom De Smedt for fixing these the areas of nodebox-web that I couldn't 🙂
Some parts of PApplet to do with image loading seem to be static, which may also explain problems I was getting with reentrancy.
If you want to have a go, you'll need to:
Install Netbeans 6.8
Install Jython (2.5 or higher) by installing the Netbeans python module
Add python to the path (if using Netbeans it's copy is where Netbeans is installed).
Get nodebox-web by downloading shoebot and install it with:
jython setup.py install
In Netbeans, add all the jars in the processing\lib folder to the Jython classpath, and opengl\library\opengl.jar
Download the PythonOnProcessing (tested on Netbeans 6.8)