MVC in Python

MK MK at foo.com
Mon Aug 4 22:14:49 CEST 2003


In Java, I simply register many listeners with a data model.
Whenever the model changes, all the listeners are notified
and they change their GUI elements accordingly and
automatically.

How to achieve this feat in Python? Which techniques
do you guys use?

Say you have one data structure and two tree controls
in wxPython, displaying two perspectives of that same
data structure. How would you proceed, that is, implement
an equivalent, MVC-ish mechanism, in this case?
My first knee-jerk reaction would be: implement two functions,
update_tree_1() and update_tree_2() which "intelligently"
update only the critical parts of tree GUI control and
which are being called by the data structure whenever
it (data structure, that is) changes.

MK,
coming from a patterns-ridden Java world






More information about the Python-list mailing list