Model, View, Controller

The Model-View-Controller (MVC) pattern is often used when designing more sophisticated widgets. In this pattern, each widget consists of three parts:

Model. This is the data displayed by the widget, and the code used to handle that data.

View. This is what’s actually drawn on the screen, and the code responsible for drawing things on the screen.

Controller. This is user actions (usually mouse or keyboard events) that modify either the view or the model. And again, the code that implements that functionality.

In Tkinter, the standard widgets all use tight coupling between the model and the view; the model data is managed by the actual widget instance. Unfortunately, this means that you cannot display data from the same model in two different widgets (for example, two independent views into a text editor buffer). It also means that you have to convert your data to a form suitable for Tk.


A Django site. rendered by a django application. hosted by webfaction.