On 9/1/07, Kenneth McDonald <kenneth.m.mcdonald@...> wrote:
> At the moment, I'd guess that Jython users are a (small) sub-group of
> Python hackers,
> i.e. not users but rather the subgroup who both use and really enjoy
> playing with Python.
> This is an unfortunate consequence of the fact that Jython went dormant
> for such a long time;
> there's going to be a certain hesitancy about Jython until people
> believe it's here to stay.
> I myself confess to using JRuby at the moment, though I'd (probably)
> prefer Jython, which
> is why I'm looking at it :-).
I'm 100% Jythonista. No dabbling with Python whatsoever. As for JRuby,
it sucks. Just compare the two:
frame = JFrame.new()
frame.getContentPane().add(JLabel.new("This is an example."))
from javax.swing import JFrame, JLabel
frame = JFrame('no more new keyword',
With Jython, it's easy to convert Java code to Jython code. Plus, you
can do this in Jython:
iframe = JInternalFrame('Title', internalFrameClosing=myfunc,
That means you can make a subclass of a JFrame/JInternalFrame, et. al.
without having to implement an interface. Example:
def __init__(self, strTitle):
JInternalFrame.__init__(self, strTitle, 1, 1, 1, 1,
self.contentPane.add(JButton('press me', actionPerformed=self.onButton))
def onActive(self, event):
print 'This iframe was activated!'
def onIconify(self, event):
print 'This iframe was iconified!'
def onButton(self, event):
print 'Dont try this at home kids'
Basically, I've covered the event-handling for both the JInternalFrame
AND its JButton in one class. It's simple, straightforward, clean,
manageable, not confusing, etc.
And I seriously hate the def/end in Ruby. Reminds me of VB.
> 2) It needs to be really, really solid, both with respect to correctness
> and (to a useful level)
> completeness in its interoperability with Java. I don't know what
> Jython's status is at this point.
> Both Groovy
Groovy is a joke. Sorry if there are any groovy developers out there :-/
> 3) Here is the big one that will be the biggest stumbling block for most
> of these efforts; it needs
> good documentation so that a person can start doing useful things
> immediately, and also be able to go
> back to find the highly technical information they'll need as they start
> tacking more complex
I guess that's true. The docs will come when Jython gains more popularity.
> I don't know about others, but my main interest in getting Python
> or Ruby working with Java is to (finally) have a (half-)decent, true,
> crossplatform GUI platform
> that I can write a decent high-level API around. To get more people
> interested in Jython
> (assuming it's solid and complete enough right now to focus on this),
> perhaps illustrate Jython
> by example by starting to develop a UI library on top of Swing, and
> documenting aspects of that?
> This approach has these advantages:
> 1) It can solve a real problem; writing Swing apps in Java is
> absurdly nasty, that's why all
> these GUI dev tools are needed.
> 2) It's visually appealing, so you'll get eyeballs.
> 3) It provides lots of scope for illustrating how to do things like
> subclass Java classes in Jython
> (if that's possible), define Java classes in Jython (if that's
> possible), etc.
It's true that writing a Swing app sucks. This is not the case in
Jython, however. And I don't think a UI lib should be written on top
of Jython. No need to reinvent the wheel, IMHO.
I'm developing a desktop application in Jython right now and I think
this has been the easiest language to use when writing GUI apps.
Here's a sample line from my project:
s = (105, 25)
self.button = JToggleButton(self._getTitle(), self._getIcon(), focusable=0,
preferredSize=s, minimumSize=s, maximumSize=s,
horizontalAlignment=SwingConstants.LEFT, margin=(1, 2, 1, 2),
And, you can still do self.button.setHorizontalAlignment(something) later on.
Even if we compare Jython and WxPython, the former is more Pythonic
than the latter.
Here's a screenshot of the first generation of my app, written purely in Jython:
Sorry for the quality of the screenshot. I'm rewriting it right now,
and the newer version looks better and has more features.
And that concludes my $0.02 on this discussion :-)