Python Code[2]
Python Code[2]
# Validate fields
if not (full_name and dob and email and phone and address and account_type and
branch_location):
messagebox.showerror("Error", "All fields are required!")
return
# Clear form
full_name_entry.delete(0, tk.END)
dob_entry.delete(0, tk.END)
email_entry.delete(0, tk.END)
phone_entry.delete(0, tk.END)
address_entry.delete("1.0", tk.END)
account_type_var.set("")
branch_location_var.set("")
messagebox.showinfo("Success", "Account details saved successfully!")
# Full Name
tk.Label(root, text="Full Name").grid(row=0, column=0, padx=10, pady=5, sticky="w")
full_name_entry = tk.Entry(root, width=30)
full_name_entry.grid(row=0, column=1, padx=10, pady=5)
# Date of Birth
tk.Label(root, text="Date of Birth").grid(row=1, column=0, padx=10, pady=5, sticky="w")
dob_entry = tk.Entry(root, width=30)
dob_entry.grid(row=1, column=1, padx=10, pady=5)
# Email
tk.Label(root, text="Email Address").grid(row=2, column=0, padx=10, pady=5, sticky="w")
email_entry = tk.Entry(root, width=30)
email_entry.grid(row=2, column=1, padx=10, pady=5)
# Phone Number
tk.Label(root, text="Phone Number").grid(row=3, column=0, padx=10, pady=5, sticky="w")
phone_entry = tk.Entry(root, width=30)
phone_entry.grid(row=3, column=1, padx=10, pady=5)
# Address
tk.Label(root, text="Residential Address").grid(row=4, column=0, padx=10, pady=5, sticky="w")
address_entry = tk.Text(root, width=30, height=4)
address_entry.grid(row=4, column=1, padx=10, pady=5)
# Account Type
tk.Label(root, text="Account Type").grid(row=5, column=0, padx=10, pady=5, sticky="w")
account_type_var = tk.StringVar()
account_type_menu = tk.OptionMenu(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
tk.Label(root, text="Preferred Branch Location").grid(row=6, column=0, padx=10, pady=5,
sticky="w")
branch_location_var = tk.StringVar()
branch_location_menu = tk.OptionMenu(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 = tk.Button(root, text="Submit", command=save_data)
submit_button.grid(row=7, column=0, columnspan=2, pady=20)