Owen Densmore wrote:
> 2 - inner classes: Processing works by subclassing its primary class,
> PApplet. It is a huge class (~8000 lines!) with all the handy
> utilities for drawing and 2D/3D calculations. Thus when your own
> subclass of PApplet itself uses classes of its own, the simplest way
> to proceed is to use inner classes, so that they too will inherit
> these utilities. I tried using:
> #from __future__ import nested_scopes
> .. but it did not appear to work for my attempt at using inner
> classes. I got un-resolved names none the less. So I punted,
> passing the PApplet instance into all the additional classes, which
> made the code quite verbose.
>
> Should inner-classes work in Jython the same way they do in Java?
No. Python and Jython do not have inner classes that have an automatic
reference to an instance of containing class. You have to pass it
explicitly as you are doing. "Explicit is better than implicit" is an
explicit guideline of the Python community.
But the methods of PApplet that you want to access are static so you can
call them as e.g. PApplet.max(); you don't need a PApplet instance. You
could define P=PApplet at the top of your module and then it would just
be P.max().
Kent
|