Skip to content
Snippets Groups Projects
Commit 8e41f43c authored by Bui2.Huan@live.uwe.ac.uk's avatar Bui2.Huan@live.uwe.ac.uk
Browse files

Upload New File

parent 5361c24b
No related branches found
No related tags found
No related merge requests found
from tkinter import Tk, ttk
# Create main window
wndw = Tk()
wndw.title("Coursework GUI")
wndw.geometry("500x500")
# Create a Notebook (tabbed interface)
notebook = ttk.Notebook(wndw)
notebook.pack(expand=True, fill='both')
# Home tab
home_frame = ttk.Frame(notebook)
ttk.Label(home_frame, text="Welcome to the Coursework GUI!", font=("Helvetica", 14)).pack(pady=20)
notebook.add(home_frame, text="Home")
# Registration tab
registration_frame = ttk.Frame(notebook)
ttk.Label(registration_frame, text="User Registration", font=("Helvetica", 14)).pack(pady=20)
notebook.add(registration_frame, text="Registration")
# About tab
about_frame = ttk.Frame(notebook)
ttk.Label(about_frame, text="About this application", font=("Helvetica", 14)).pack(pady=20)
notebook.add(about_frame, text="About")
# Registration form elements
ttk.Label(registration_frame, text="First Name:").pack(pady=5)
first_name_entry = ttk.Entry(registration_frame, width=30)
first_name_entry.pack(pady=5)
ttk.Label(registration_frame, text="Surname:").pack(pady=5)
surname_entry = ttk.Entry(registration_frame, width=30)
surname_entry.pack(pady=5)
ttk.Label(registration_frame, text="Gender:").pack(pady=5)
gender_var = ttk.Combobox(registration_frame, values=["Male", "Female", "Other"], width=27)
gender_var.pack(pady=5)
gender_var.set("Select")
ttk.Label(registration_frame, text="Date of Birth (DD/MM/YYYY):").pack(pady=5)
dob_entry = ttk.Entry(registration_frame, width=30)
dob_entry.pack(pady=5)
# Register button
def register_user():
first_name = first_name_entry.get()
surname = surname_entry.get()
gender = gender_var.get()
dob = dob_entry.get()
if not first_name or not surname or gender == "Select" or not dob:
ttk.Label(registration_frame, text="Please fill out all fields!", foreground='red').pack(pady=5)
return
ttk.Label(registration_frame, text=f"Registered: {first_name} {surname}").pack(pady=5)
ttk.Button(registration_frame, text="Register", command=register_user).pack(pady=10)
# About content
ttk.Label(about_frame, text="This is a sample coursework GUI.\nBuilt using Python Tkinter.", justify='center').pack(pady=20)
# Start the Tkinter event loop
wndw.mainloop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment