this assignment carries 20% wight age . this assignment must be made according to the marking guide satisfying all the requirements. the python files must be made clear and executed

1 answer below »
this assignment carries 20% wight age . this assignment must be made according to the marking guide satisfying all the requirements. the python files must be made clear and executed
Answered Same DayMay 18, 2020ITECH1400

Answer To: this assignment carries 20% wight age . this assignment must be made according to the marking guide...

Abr Writing answered on May 25 2020
153 Votes
123456.txt
123456
7890
5000.0
0.33
Deposit
3000.0
Deposit
4000.0
Withdrawal
2000.0
main.py
import tkinter as tk
from tkinter import messagebox
from pylab import plot, show, xlabel, ylabel
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from bankaccount import BankAccount
win = tk.Tk()
# Set window size here to '440x640' pixels
win.geometry('440x640')
# Set window title here to 'FedUni Banking'
win.title('FedUni Banking')
# The account number entry and associated variable
account_number_var = tk.StringVar()
account_number_ent
ry = tk.Entry(win, textvariable=account_number_var)
account_number_entry.focus_set()
# The pin number entry and associated variable.
# Note: Modify this to 'show' PIN numbers as asterisks (i.e. **** not 1234)
pin_number_var = tk.StringVar()
account_pin_entry = tk.Entry(win, text='PIN Number', textvariable=pin_number_var, show='*')
# The balance label and associated variable
balance_var = tk.StringVar()
balance_var.set('Balance: $0.00')
balance_label = tk.Label(win, textvariable=balance_var)
# The Entry widget to accept a numerical value to deposit or withdraw
amount_entry = tk.Entry(win)
# The transaction text widget holds text of the accounts transactions
transaction_text_widget = tk.Text(win, height=10, width=48)
# The bank account object we will work with
account = BankAccount()
# ---------- Button Handlers for Login Screen ----------
def clear_pin_entry(event):
'''Function to clear the PIN number entry when the Clear / Cancel button is clicked.'''
# Clear the pin number entry here
pin_number_var.set('')
def handle_pin_button(event):
'''Function to add the number of the button clicked to the PIN number entry via its associated variable.'''
# Limit to 4 chars in length
pin = account_pin_entry.get()
# Set the new pin number on the pin_number_var
if len(pin) < 4:
pin_number_var.set(pin+str(event))
def log_in(event):
'''Function to log in to the banking system using a known account number and PIN.'''
global account
global pin_number_var
global account_number_entry
# Create the filename from the entered account number with '.txt' on the end
# Try to open the account file for reading
try:
with open(account_number_entry.get()+'.txt') as f:
# Open the account file for reading
idx = 0
# First line is account number
for line in f:
line = line.strip()
if idx == 0:
account.account_number = line
# Second line is PIN number, raise exceptionk if the PIN entered doesn't match account PIN read
elif idx == 1:
account.pin_number = line
if account.pin_number != pin_number_var.get():
raise Exception('Incorrect PIN number')
# Read third and fourth lines (balance and interest rate)
elif idx == 2:
account.balance = float(line)
elif idx == 3:
account.interest_rate = float(line)
# Section to read account transactions from file - start an infinite 'do-while' loop here
elif idx % 2 == 0:
temp = line
else:
account.transaction_list.append((temp, line))
# Attempt to read a line from the account file, break if we've hit the end of the file. If we
# read a line then it's the transaction type, so read the next line which will be the transaction amount.
# and then create a tuple from both lines and add it to the account's transaction_list
idx += 1
# Close the file now we're finished with it

# Catch exception if we couldn't open the file or PIN entered did not match account PIN
except:
# Show error messagebox and & reset BankAccount object to default...
raise Exception('Account Not Found')
# ...also clear PIN entry and change focus to account number entry
pin_number_var.set('')
# Got here without raising an exception? Then we can log in - so remove the widgets and display the account screen
# ---------- Button Handlers for Account Screen ----------
create_account_screen()
def save_and_log_out():
'''Function to overwrite the account file with the current state of
the account object (i.e. including any new transactions), remove
all widgets and display the login screen.'''
global account
# Save the account with any new transactions
account.save_to_file()
# Reset the bank acount object

# Reset the account number and pin to blank
account_number_var.set('')
pin_number_var.set('')
# Remove all widgets and display the login screen again
remove_all_widgets()
create_login_screen()
def perform_deposit():
'''Function to add a deposit for the amount in the amount entry to the
account's transaction list.'''
global account
global amount_entry
global balance_label
global balance_var
# Try to increase the account balance and append the deposit to the account file

# Get the cash amount to deposit. Note: We check legality inside account's deposit method
# Deposit funds
account.deposit_funds(amount_entry.get())
# Update the transaction widget with the new transaction by calling account.get_transaction_string()
# Note: Configure the text widget to be state='normal' first, then delete contents, then instert new
# contents, and finally configure back to state='disabled' so it cannot be user edited.
transaction_text_widget.configure(state='normal')
transaction_text_widget.delete(1.0, tk.END)
for transaction in account.get_transaction_string():
transaction_text_widget.insert(tk.END, transaction[0]+'\n')
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here