A basic quiz app created in python, with questions supplied by the Open Trivia Database (opentdb.com).
Python has introduced me to the OOP(Object Oriented Programming) paradigm, which I've only briefly touched upon during my journey with JavaScript.
- Calling an API (opentdb.com)
- Class-based programming
- Separation of concerns - maintaing pure functionality
- Using Tk Interface to:
- Create a canvas
- Draw question text on it
- Use a grid layout
- Display images for true/false answers
- Update the display background to confirm whether the user answers correctly
- Once I had completed the quiz logic in main.py, it was a big challenge to then be able to abstract it, whilst still ensuring all the components talked to each other.
- Navigating the data received from the API
- Creating the layout in tkinter can be fiddly
Clone down the folder from GitHub into your IDE. Change directory in to the root folder. You will need to install the requests module as it does not come pre-bundled with python. For PyCharm, see here. In VS Code, enter this command at the root level of the project:
pip3 install requests
Then run main.py.