Student registration form template for tkinter
Open this design in the browser-based designer, rearrange it, and download the Python. Nothing to install, and you don't need an account to try it.
Open in designer →What this template shows you
- Reading four different input types in one handler — Entry, Combobox, Radiobutton and Checkbutton
- Grouping radiobuttons with a shared variable so only one can be chosen
- Validating before acting, and reporting the result in a label
The Python it generates
This is the actual main.py you get when you download it: standard-library
tkinter, no framework, yours to edit:
import tkinter as tk
from tkinter import ttk
class Application:
def __init__(self, root):
self.root = root
root.title("Student registration")
root.geometry("460x440")
self.year_var = tk.StringVar()
self.checkbutton1_var = tk.IntVar()
self.label1 = tk.Label(root, text="Student registration")
self.label1.place(x=30, y=20, width=260, height=28)
self.label2 = tk.Label(root, text="Full name")
self.label2.place(x=30, y=70, width=90, height=26)
self.entry1 = tk.Entry(root)
self.entry1.place(x=140, y=68, width=280, height=28)
self.label3 = tk.Label(root, text="Email")
self.label3.place(x=30, y=110, width=90, height=26)
self.entry2 = tk.Entry(root)
self.entry2.place(x=140, y=108, width=280, height=28)
self.label4 = tk.Label(root, text="Course")
self.label4.place(x=30, y=150, width=90, height=26)
self.combobox1 = ttk.Combobox(root, values=["Computer Science", "Mathematics", "Physics", "Design"])
self.combobox1.place(x=140, y=148, width=280, height=28)
self.label5 = tk.Label(root, text="Year")
self.label5.place(x=30, y=190, width=90, height=26)
self.radiobutton1 = tk.Radiobutton(root, text="Year 1", variable=self.year_var, value="Year 1")
self.radiobutton1.place(x=140, y=188, width=90, height=26)
self.radiobutton2 = tk.Radiobutton(root, text="Year 2", variable=self.year_var, value="Year 2")
self.radiobutton2.place(x=240, y=188, width=90, height=26)
self.radiobutton3 = tk.Radiobutton(root, text="Year 3", variable=self.year_var, value="Year 3")
self.radiobutton3.place(x=340, y=188, width=90, height=26)
self.checkbutton1 = tk.Checkbutton(root, text="I agree to the terms", variable=self.checkbutton1_var)
self.checkbutton1.place(x=140, y=228, width=280, height=26)
self.button1 = tk.Button(root, text="Register", command=self.on_button1)
self.button1.place(x=140, y=272, width=130, height=34)
self.label6 = tk.Label(root, text="")
self.label6.place(x=30, y=330, width=400, height=60)
def on_button1(self):
name = self.entry1.get().strip()
email = self.entry2.get().strip()
course = self.combobox1.get()
year = self.year_var.get()
agreed = self.checkbutton1_var.get()
if not name or not email:
self.label6.configure(text="Enter a name and an email address.")
elif not course or not year:
self.label6.configure(text="Choose a course and a year.")
elif not agreed:
self.label6.configure(text="Please agree to the terms first.")
else:
self.label6.configure(text=name + " registered for " + course + ", " + year)
if __name__ == "__main__":
root = tk.Tk()
app = Application(root)
root.mainloop()
Save it and run it the usual way:
python main.py Make it your own. Edit the layout visually, then download the code.
Open the student registration form template →Other templates
- Login form: Username + password entries with a working submit handler.
- Calculator: Display plus a 4×4 keypad with working press/clear/equals code.
- To-do list: Entry, listbox, and add/remove buttons, all wired up.
- Temperature converter: The classic beginner project: Celsius in, Fahrenheit out.