From: Glen S. <gl...@en...> - 2001-04-30 16:30:11
|
O > Any thougts on the best way to bind events? > > I'm working with a form that has two text fields and a button; eventually > it's going to be a login form. For the button I'm using: > > btnLogin = java.awt.Button("Login", actionPerformed=processLogin(txtLoginID.text, > txtPasswd.txt)) Inherits from awt.Event.ActionListener in your class and implement the actionPerformed method... like... from java.awt import * from java.awt.event import * class LogonForm(ActionListener): def __init__(self): self.btnLogin = Button("Login") self.txtLoginID = TextField() self.txtPasswd = TextField() ..... (implenent the GUI, etc...) def actionPerformed(self, event): source = event.getSource() if source==self.Login: self.processLogin(self.txtLoginID.text, self.txtPasswd.text) else: #handle some other event... def processLogin(loginID, passwd): #do something... Hope that helps. -- Glen Starchman Enabled Ventures/Enabled Technology Group gl...@en... 206.234.7330 |