The simple Jython function below accepts a url string for an image and displays it in a Swing window.
1 2 3 4 5 6 7 8 9 10 | from pawt import swing
from java import net
def view(url):
frame = swing.JFrame("Image: " + url, visible=1)
frame.getContentPane().add(swing.JLabel(swing.ImageIcon(net.URL(url))))
frame.setSize(400,250)
frame.show()
view("http://www.python.org/pics/pythonHi.gif")
|
Swing's JLabel and ImageIcon can be combined in Jython to make a simple image viewer. This combination is a not so obvious but easy way to display a web-based image. You can also use the "file:///" protocol to display images on your file system.
Tags: jython