import tkinter as tk
from tkinter import messagebox
import os
# File path to store data
file_path = r"C:\Users\veeresh_h9\Videos\mini project\account_data.txt"
# Function to save form data
def save_data():
full_name = full_name_entry.get()
dob = dob_entry.get()
email = email_entry.get()
phone = phone_entry.get()
address = address_entry.get("1.0", [Link]).strip()
account_type = account_type_var.get()
branch_location = branch_location_var.get()
# Validate fields
if not (full_name and dob and email and phone and address and account_type and
branch_location):
[Link]("Error", "All fields are required!")
return
# Prepare data to save
data = (
f"Full Name: {full_name}\n"
f"Date of Birth: {dob}\n"
f"Email: {email}\n"
f"Phone: {phone}\n"
f"Address: {address}\n"
f"Account Type: {account_type}\n"
f"Branch Location: {branch_location}\n"
f"-----------------------------\n"
)
# Ensure directory exists
[Link]([Link](file_path), exist_ok=True)
# Save data to file
with open(file_path, "a") as file:
[Link](data)
# Clear form
full_name_entry.delete(0, [Link])
dob_entry.delete(0, [Link])
email_entry.delete(0, [Link])
phone_entry.delete(0, [Link])
address_entry.delete("1.0", [Link])
account_type_var.set("")
branch_location_var.set("")
[Link]("Success", "Account details saved successfully!")
# Create GUI window
root = [Link]()
[Link]("Bank Account Opening Form")
# Full Name
[Link](root, text="Full Name").grid(row=0, column=0, padx=10, pady=5, sticky="w")
full_name_entry = [Link](root, width=30)
full_name_entry.grid(row=0, column=1, padx=10, pady=5)
# Date of Birth
[Link](root, text="Date of Birth").grid(row=1, column=0, padx=10, pady=5, sticky="w")
dob_entry = [Link](root, width=30)
dob_entry.grid(row=1, column=1, padx=10, pady=5)
# Email
[Link](root, text="Email Address").grid(row=2, column=0, padx=10, pady=5, sticky="w")
email_entry = [Link](root, width=30)
email_entry.grid(row=2, column=1, padx=10, pady=5)
# Phone Number
[Link](root, text="Phone Number").grid(row=3, column=0, padx=10, pady=5, sticky="w")
phone_entry = [Link](root, width=30)
phone_entry.grid(row=3, column=1, padx=10, pady=5)
# Address
[Link](root, text="Residential Address").grid(row=4, column=0, padx=10, pady=5, sticky="w")
address_entry = [Link](root, width=30, height=4)
address_entry.grid(row=4, column=1, padx=10, pady=5)
# Account Type
[Link](root, text="Account Type").grid(row=5, column=0, padx=10, pady=5, sticky="w")
account_type_var = [Link]()
account_type_menu = [Link](root, account_type_var, "Savings Account", "Current
Account", "Fixed Deposit")
account_type_menu.grid(row=5, column=1, padx=10, pady=5, sticky="w")
# Branch Location
[Link](root, text="Preferred Branch Location").grid(row=6, column=0, padx=10, pady=5,
sticky="w")
branch_location_var = [Link]()
branch_location_menu = [Link](root, branch_location_var, "New York", "Los Angeles",
"Chicago", "Houston", "Miami")
branch_location_menu.grid(row=6, column=1, padx=10, pady=5, sticky="w")
# Submit Button
submit_button = [Link](root, text="Submit", command=save_data)
submit_button.grid(row=7, column=0, columnspan=2, pady=20)
# Run the GUI event loop
[Link]()