Exercises
Here is a list of a few things you could do to further improve the GUI application. With one exception, the solutions are not provided for these exercises.
- Put the
Model
,View
and,Controller
classes in their own modules! - Use the publish-subscribe API for communication from
View
toController
. You can refer to the filehutgame_mvc_pubsub.py
for a solution. - Add more widgets such as a menu bar and buttons. Implement the Restart Game button. When clicked, the game should restart. Do the following when this button is clicked:
- Randomly distribute the occupants again by calling
occupy_huts()
. - Clear the state of the radio buttons. All the buttons should be deselected.
- Randomly distribute the occupants again by calling
- Add exception handling to the application.
- Try to generalize the
View.add_callbacks ...
Get Learning Python Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.