From 507c1423985dc1b77c651f05b9b73c34b332f5b8 Mon Sep 17 00:00:00 2001 From: Lucas Mathews Date: Tue, 28 May 2024 11:44:38 +0200 Subject: [PATCH] Account information added to account window. --- application/account.py | 36 +++++++++++++++++++++++++++++++---- application/dashboard.py | 3 +-- application/session_data.json | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/application/account.py b/application/account.py index e459b93..a9cfba7 100644 --- a/application/account.py +++ b/application/account.py @@ -38,10 +38,33 @@ def populate_transactions_table(transactions_table, account_id): transaction['recipient_account_id'] )) +def display_account_info(account_id): + """Display the account information for the given account ID.""" + account_info = get_account(account_id) # Fetch the account details + if account_info is None or 'data' not in account_info: + messagebox.showerror("Error", "Could not fetch account details.") + return + account = account_info['data'] + print(account) + if 'description' not in account: + messagebox.showerror("Error", "Account description not found.") + return + account_description = account['description'] + fields = {'Account ID': account_id, 'Description': account_description, 'Balance': format_balance(account['balance']), 'Account Type': account['account_type']} + for i, (key, value) in enumerate(fields.items()): + label_key = customtkinter.CTkLabel(info_frame, text=f"{key}:", font=("Helvetica", 14)) + label_value = customtkinter.CTkLabel(info_frame, text=value, font=("Helvetica", 14)) + label_key.grid(row=0, column=i*2, sticky='w', padx=10) + label_value.grid(row=0, column=i*2+1, sticky='w', padx=10) + + + + ############## ### Layout ### ############## +# Initialise the main window root = customtkinter.CTk() root.title(f"Transactions for: {account_description}") root.iconbitmap("application/luxbank.ico") @@ -52,19 +75,24 @@ if CONFIG["preferences"]["dark_theme"] == "dark": # Check if dark mode is enabl else: customtkinter.set_appearance_mode("light") # Set the style for light mode +# Display main window title welcome_label = customtkinter.CTkLabel(root, text=f"Transactions for: {account_description}", font=("Helvetica", 24)) -welcome_label.pack(pady=20) +welcome_label.pack(pady=10) + +# Display account information +info_frame = customtkinter.CTkFrame(root) +info_frame.pack(fill=tk.X) +display_account_info(account_id) table_frame = customtkinter.CTkFrame(root) table_frame.pack(fill=tk.BOTH, expand=True) +# Create the transactions table transactions_table = ttk.Treeview(table_frame, columns=("Transaction ID", "Transaction Type", "Amount", "Timestamp", "Description", "Account ID", "Recipient Account ID"), show="headings") transactions_table.pack(fill=tk.BOTH, expand=True) - for col in transactions_table["columns"]: transactions_table.heading(col, text=col) - -# Directly populate transactions table for the given account populate_transactions_table(transactions_table, account_id) +# Start the main event loop root.mainloop() diff --git a/application/dashboard.py b/application/dashboard.py index 01bd90a..7d1217f 100644 --- a/application/dashboard.py +++ b/application/dashboard.py @@ -18,7 +18,7 @@ frame = None def go_to_login(): """Closes the current window and opens the login page.""" root.destroy() - login_page() # Replace with your function or class that opens the login page + os.system("python application/login.py") def logout(): """Logs out the client and redirects to the login page.""" @@ -97,7 +97,6 @@ def save_details(): new_email = email_entry.get() if email_entry.get() != '' else None new_phone = phone_entry.get() if phone_entry.get() != '' else None new_address = address_entry.get() if address_entry.get() != '' else None - try: with open('application\\session_data.json', 'r') as f: session_data = json.load(f) diff --git a/application/session_data.json b/application/session_data.json index a72e368..9087467 100644 --- a/application/session_data.json +++ b/application/session_data.json @@ -1 +1 @@ -{"session_cookie": {"session": "G1SQpUTHsed2pPeVe4-1vtqwOXzE5-HMGZKWxvNqzTs"}, "client_id": "31d90aad"} \ No newline at end of file +{"session_cookie": {"session": "UHtXXDwzE9iVXmMpFHD9BYA-ztYORiBP-xfRImGQDJQ"}, "client_id": "31d90aad"} \ No newline at end of file