Skip to content

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

🧠 TrueFalse Quiz App

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.


📸 Preview

Dark-themed quiz window with animated progress bar, color-coded answer feedback, and a results screen with score breakdown.


🗂️ Project Structure

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)

🚀 Getting Started

Prerequisites

  • Python 3.x (Tkinter is included — no installs needed)

Run the app

python gui.py

Want the plain terminal version instead? Run python main.py


➕ Adding Questions

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.


🌐 Adding Questions from Open Trivia DB

Open Trivia DB is a free API with thousands of True/False questions across many categories.

Step 1 — Go to the API

Visit: https://opentdb.com/api_config.php

Step 2 — Configure your query

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

Step 3 — Copy the generated API URL

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"]
    }
  ]
}

Step 4 — Paste into data.py

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.


🏗️ OOP Design

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

📦 Built With


📄 License

MIT License — free to use, modify, and share.

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages