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.

  1. Put the Model, View and, Controller classes in their own modules!
  2. Use the publish-subscribe API for communication from View to Controller. You can refer to the file hutgame_mvc_pubsub.py for a solution.
  3. 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.
  4. Add exception handling to the application.
  5. 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.