Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created February 24, 2014 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinDavid/9196657 to your computer and use it in GitHub Desktop.
Save RobinDavid/9196657 to your computer and use it in GitHub Desktop.
Just a sample of Jython script to use swing
#!/usr/bin/env jython
#-*- encoding:utf-8 -*-
from java.lang import System
from javax.swing import JFrame, JButton, JLabel
from java.awt import BorderLayout
# Exit application
def exitApp(event):
System.exit(0)
# Use a tuple for size
frame = JFrame(size=(300,100))
# Use a tuple for RGB color values.
frame.background = 127,255,127
button = JButton(label='Push to Exit', actionPerformed=exitApp)
label = JLabel(text="A Pythonic Swing Application", horizontalAlignment=JLabel.CENTER)
frame.contentPane.add(label, BorderLayout.CENTER)
frame.contentPane.add(button, BorderLayout.SOUTH)
frame.setVisible(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment