All things Jythonic 28.6.2004

June 2004
MoTuWeThFrSaSu
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
282930    
May
2004
 Jul
2004

A blog tracking jython developments

XML-Image Syndication

XML-Image Comment Feed

Letterimage Contact me

2004-06-28

Jython and Swing

Not so useless Jython from the Useless Python blog . A basic example of how to get going with Jython and Swing!

The following is an example of using the Jython interactive interpreter from the Windows 2000 command prompt. On this page, we demonstrate several Jython basics, including:

  • use of the jython interpreter from the MS Windows 2000 command prompt

  • collection of user input with javax.swing.JOptionPane.showInputDialog()

  • conversion of strings to integers, and integers to strings, plus simple addition

  • display of output with javax.swing.JOptionPane.showMessageDialog()

posted at 00:01:04    #

Write Your Own Mini Aggregator with Jython and Rome!

Rome is a new java API for reading RSS and ATOM feeds. Here is a quick demonstration of what you can do with it using Jython, the Java Scripting Swiss Army Knife.

Ok, you will need to add both the latest build of Rome and JDOM to your classpath. Next fire up jython or if you like use the Jython Console which will make exploring the ROME api a little easier.

Here is the source code then of a simple aggregator written in jython.

from java.net import URL
from com.sun.syndication.feed.synd import SyndFeedI
from com.sun.syndication.io import SyndFeedInput

myUrl = URL('http://www.pycs.net/users/0000177/rss.xml')

input = SyndFeedInput()
feed = input.build(myUrl.openStream())

entries = feed.getEntries()

for post in entries:
    title = post.getTitle()
    link = post.getLink()

    print """<a href='%s'>%s</a>""" % (title, link)

When you run this, you will get a list of links pointing to the posts in the feed, in this case the feed for my main site.

posted at 16:52:16    #
Creative Commons License
This work is licensed under a Creative Commons License.