>>> Let's run Python on Mobile

วันจันทร์, มกราคม 22, 2550

jython06.py

import java.lang
from java.awt import Frame,MenuBar,Menu,MenuItem,TextArea
from java.awt.event import ActionEvent
class jython06(java.awt.Frame):
def __init__(self):
self.size=(208,276)
self.myOutput=java.awt.TextArea("Hello UIQ from Jython!!!\n")
self.add("Center",self.myOutput)
self.myMenuBar=java.awt.MenuBar()
self.myMenu=java.awt.Menu("Menu")
self.one=java.awt.MenuItem("Say Hello",actionPerformed=self.sayHello)
self.two=java.awt.MenuItem("Say Hi",actionPerformed=self.sayHi)
self.myMenuExit=java.awt.MenuItem("Exit",actionPerformed=self.doExit)
self.myMenuBar.add(self.myMenu)
self.myMenu.add(self.one)
self.myMenu.add(self.two)
self.myMenu.add(self.myMenuExit)
self.setMenuBar(self.myMenuBar)
self.setVisible(1)
def sayHello(self,event):
self.addSomething("Hello\n")
def sayHi(self,event):
self.setOutput("hi\n")
def addSomething(self,tx):
self.myOutput.appendText(tx)
def setOutput(self,tx):
self.myOutput.setText(tx)
def doExit(self,event):
java.lang.System.exit(0)
if __name__=="__main__":
myApp=jython06()


Jython on PC


Jython on UIQ