...

View Full Version : python calc



Jason
03-29-2004, 09:39 PM
I have this simple calc I got from a book but it doesn't work can someone help


from java import awt
from pawt import swing

labels = ['0','1','2','+',
'3','4','5','-',
'6','7','8','*',
'9','.','=','/']

keys = swing.JPanel(awt.GridLayout(4, 4))
display = swing.JTextField()

def push(event):
display.text = str(eval(display.text))
display.selectAll()

for label in labels:
key = swing.JButton(label)
if label == '=':
key.actionPerformed = enter
else:
key.actionPerformed = push
keys.add(key)

panel = swing.JPanel(awt.BorderLayout())
panel.add("North", display)
panel.add("Center", keys)
swing.test(panel)

but my error is from the line



key.actionPerformed = enter


and I don't understand why...the error says

Traceback (innermost last):
File "calc.py", line 19, in ?
NameError: enter

any help?


Jason

Jason
03-29-2004, 10:42 PM
never mind, I forgot to add the enter function among some other errors...thanks


Jason



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum