From: Slinger, N. <nei...@me...> - 2002-07-19 14:31:24
|
Hi, I have just started using Jython and have come stuck on a certain issue. I am calling a function when a button is pressed. e.g. def buttonPressed(event): print "HELLO" def showButton(): ... button = swing.JButton("Hello", actionPerformed=buttonPressed) ... This works fine obviously, however, I need to be able to send a string to the 'buttonPressed' function. Here is an example to show what I mean. def buttonPressed(event, text): print text def showButton(): ... text = "Hello" button = swing.JButton("Hello", actionPerformed=buttonPressed(text)) ... This appears not to work, as it requires 2 arguments. If I remove the required 'event' argument it doesn't wait until the button has been pressed before going to 'buttonPressed'. Can you please help me, pass the string to the 'buttonPressed' function? I would appreciate a prompt response as I need to get this working ASAP. Regards, Neil. Junior Software Development Engineer Mentor Graphics Corp www.mentor.com Mobile: 07740 364402 |