[Tutor] Newby Still Lost with GUI!!!
moore william
red_necks25 at yahoo.com
Fri Mar 5 20:19:16 EST 2004
I am trying inhance my program to create a GUI
interface instead of my current one. However I am
coming up with "amount" and "self" are not defined. I
thought I did this earlier. How would I go about
creating the GUI and where did I miss my defentition?
Thanks in advance for any guidence!
import shelve
s = shelve.open('d:/College/numberdata')
if s.has_key('numbers'):
numbers = s['numbers']
else:
numbers = {}
class AccountTransaction(object):
def __init__(self, amount, time):
self.amount = amount
self.time = time
def __repr__(self):
description = time.ctime(self.time) + ' '
if self.amount < 0:
description += '-'
description += '$' + str(abs(self.amount))
return description
def __self__(self, initial):
self.balance = amount
while 1:
print
print
print 'Welcome to the Bank"
print '1. Deposite'
print '2. Withdraw'
print '3. Getbalance'
print '9. Quit'
print
choice = int(raw_input('Enter your choice: '))
# I added the exception line so that negartive
numbers woudl not be added.
if choice == 1:
amount = raw_input ('Amount: ')
elif amount < 0:
raise ValueError, 'Deposites must be positive'
elif self.balance - amount < 0:
raise ValueError, 'The account only holds $' +
str(self.balance)
self._perform_transaction(-amount)
date = raw_input ('Date: ')
numbers[amount] = date
# I added the exception line so that only positive
numbers woudl eb entered for withdraws. line so that
elif choice == 2:
amount = raw_input ('Amount: ')
if amount < 0:
raise ValueError, 'Withdrawals must be
negative'
elif self.balance - amount < 0:
raise ValueError, 'The account only holds $' +
str(self.balance)
self._perform_transaction(-amount)
date = raw_input ('Date: ')
numbers[amount] = date
elif choice == 3:
print
for amount, date in numbers.items():
print '%-20s : %-14s' % (amount, date)
elif choice == 9:
break
else:
print_menu()
print "Goodbye"
##save numbers when done
s['numbers'] = numbers
s.close()
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
More information about the Tutor
mailing list