next up previous
Next: The glade-based view Up: The implementation glade-based Previous: The implementation glade-based

The model

The model is represented by class MyModel, derived from class Model, that in turn is provided by the framework.

The class MyModel contains a field called counter to hold the value of a numeric counter. Since we are interested in monitoring and show any change of this counter, we declare it as an observable property.

  
from gtkmvc.model import Model

class MyModel (Model):
# observable properties:
__properties__ = { 'counter' : 0 }

def __init__(self):
Model.__init__(self)
return

pass # end of class

All that it is required to do, is calling class Model's constructor from within the derived class' constructor, and defining a class variable __properties__ containing the name of the observable properties, and the associated initial values. The class Model will do all the boring work automatically.



Roberto Cavada 2004-06-11