Page 312 -
P. 312

guis and data


          The system tells the other widgets when

           the model changes


           The tkinter library code will keep a track of which widgets are using which
           models and, whenever a model changes, tkinter will let the widgets know
           about it. So if we select the Seattle, WA radio button, it will update
           the model, and the other radio buttons that share the model will deselect
           themselves.
                                                                                       Well, that‛s not my
                                                                                       value, so I'd better
                                                                                       deselect myself.

                       Hey, I‛m set
                       to “Seattle,
                       WA” now.


                                       Seattle, WA

                                                                                               Not mine
                                                                                               either.
                                                                                               Deselect.





           There’s a special name for the way this code works:



                                          Model  View  Controller






                          The model is the data stored.


                          The view is just a fancy name for the widget.


                          And the controller is the code in tkinter that lets all of the views know
                        when the model has changed.



           So much for the MVC theory. Time to fix the code.


                                                                                       you are here 4    277
   307   308   309   310   311   312   313   314   315   316   317