MVC Tutorial


Model-View-Controller Example

If you are stuggling to conceptualize how different classes and objects are interacting with each other, this example runs through a more simple demo of how to implment MVC using concepts you are familiar with like the turtle and input functions!

The project still requires you to use tkinter but running though this tutorial should give you a better handle on objects and classes communicating information between each other.

Diagram

Below is a visualization of a basic Model-View-Controller Implementation

Application

The following files are fully finished and should be ready to run if they are all in the correct place with the correct file names. Once you have finished setting up the application you can run it using python -m comp110.demos.mvc_tutorial. We recommend you run the project and then read through the commented files to understand how it is built. Start with Controller.py, then Model.py, then View.py and finally take a look at __main__.py

Build the project by creating a directory in comp110/demos named mvc_tutorial and then add the following code as specified.

Controller Class

Add a file in the mvc_tutorial directory named Controller.py

Model Class

Add a file in the mvc_tutorial directory named Model.py

View Class

Add a file in the mvc_tutorial directory named View.py

Main File

Add a file in the mvc_tutorial directory named __main__.py