Tkinter Designer

← All templates

Quiz app 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

  • Grouping Radiobuttons and reading the selected value
  • Giving feedback by updating a Label
  • A pattern you can extend to many questions

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("Quiz")
        root.geometry("400x300")

        self.answer_var = tk.StringVar()

        self.label1 = tk.Label(root, text="Which module creates GUIs in standard Python?", font=("Helvetica", 10, "bold"))
        self.label1.place(x=30, y=26, width=340, height=28)

        self.radiobutton1 = tk.Radiobutton(root, text="tkinter", variable=self.answer_var, value="tkinter")
        self.radiobutton1.place(x=50, y=72, width=200, height=26)

        self.radiobutton2 = tk.Radiobutton(root, text="numpy", variable=self.answer_var, value="numpy")
        self.radiobutton2.place(x=50, y=106, width=200, height=26)

        self.radiobutton3 = tk.Radiobutton(root, text="requests", variable=self.answer_var, value="requests")
        self.radiobutton3.place(x=50, y=140, width=200, height=26)

        self.button1 = tk.Button(root, text="Submit", command=self.on_button1)
        self.button1.place(x=50, y=190, width=120, height=34)

        self.label2 = tk.Label(root, text="")
        self.label2.place(x=50, y=240, width=300, height=26)

    def on_button1(self):
        answer = self.answer_var.get()
        if answer == "tkinter":
            self.label2.configure(text="Correct!")
        elif answer:
            self.label2.configure(text="Not quite - try again.")
        else:
            self.label2.configure(text="Pick an answer first.")


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 quiz app 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.