Created
February 24, 2014 20:45
-
-
Save RobinDavid/9196657 to your computer and use it in GitHub Desktop.
Just a sample of Jython script to use swing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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