A True / False quiz game built with Python and Tkinter featuring a sleek dark-themed GUI. Test your knowledge on Computer Science — and easily expand the question bank using the free Open Trivia Database.
Dark-themed quiz window with animated progress bar, color-coded answer feedback, and a results screen with score breakdown.
trivia-quiz-app/
│
├── data.py # ← All questions live here
├── question_model.py # Question class (OOP)
├── quiz_brain.py # Quiz logic (OOP)
├── main.py # Terminal version (no GUI)
└── gui.py # Graphical version (run this)
- Python 3.x (Tkinter is included — no installs needed)
python gui.pyWant the plain terminal version instead? Run
python main.py
You never need to edit gui.py to add questions. All questions live in data.py. Just append a new dictionary to the question_data list:
{"type": "boolean",
"difficulty": "medium",
"category": "Science: Computers",
"question": "Your question here.",
"correct_answer": "True",
"incorrect_answers": ["False"]}The GUI automatically adjusts the question counter and progress bar to however many questions you have.
Open Trivia DB is a free API with thousands of True/False questions across many categories.
Visit: https://opentdb.com/api_config.php
| Setting | Value |
|---|---|
| Number of Questions | However many you want (e.g. 10) |
| Category | Any (e.g. Science: Computers) |
| Difficulty | Easy / Medium / Hard |
| Type | Boolean ← important, select this |
It will look something like this:
https://opentdb.com/api.php?amount=10&category=18&difficulty=medium&type=boolean
Open it in your browser — you'll get a JSON response like this:
{
"results": [
{
"type": "boolean",
"difficulty": "medium",
"category": "Science: Computers",
"question": "Linux was first created as an alternative to Windows XP.",
"correct_answer": "False",
"incorrect_answers": ["True"]
}
]
}Copy the objects from "results" and paste them into the question_data list in data.py:
# data.py
question_data = [
# --- existing questions ---
{"type": "boolean", "difficulty": "medium", "category": "Science: Computers",
"question": "Linux was first created as an alternative to Windows XP.",
"correct_answer": "False", "incorrect_answers": ["True"]},
# --- paste more here ---
]That's it — save and run gui.py again. ✅
Tip: The API returns HTML entities like
"and'in question text — the app handles these automatically, so paste them as-is.
| Class | File | Responsibility |
|---|---|---|
Question |
question_model.py |
Stores question text and correct answer |
QuizBrain |
quiz_brain.py |
Tracks score, question number, and answer checking |
QuizUI |
gui.py |
Renders the Tkinter window and handles all user interaction |
- Python 3
- Tkinter — standard GUI library
- Open Trivia DB — free trivia API
MIT License — free to use, modify, and share.