Named code blockes

James_Althoff at i2.com James_Althoff at i2.com
Tue Apr 24 15:29:46 EDT 2001


D-Man writes:

I think the registering of a callback is a nicer way of achieving the
results, but that is just my preference.

-D

<jim response>
Mine too.  I use JPython/Jython extensively with Swing.  Normally I
would have to use the Java mechanism of creating a class for each
handler and then pass a single instance of the class in as the
argument to a handler registration method.  And since Python
does not support unnamed/"in place" classes this would be a pain
since I would have to create "dummy named" event handler classes all
over the place (each with one instance).  However, the JPython/Jython
implementation has a wonderful feature whereby you can assign
a Python object to any Swing "property".  In particular, you can designate
a Swing event handler to be a Python callback method (just like in your
example).  This very nice feature is much loved and extensivley used
by our programming team here at work.

(It makes it all worthwhile!)

</jim response>






More information about the Python-list mailing list