Page 311 -
P. 311

model update


          The radio buttons can share a model


           The text fields you originally created each stored a single data item. For every
           widget on the screen, there was a single piece of data. But that’s not true
           for your radio buttons. The three radio buttons will be used by the user to
           record just one thing: the depot that a delivery is sent to. The three radio
           buttons needs to share a single piece of  data. And that piece of data is called the
           model.
                                                              I‛ll keep my eye on
                                                              the model until I‛m
                                                              clicked...



                          This is the model
                          hidden away in your
                          computer's memory.                                 Click me, so I can
                                                                             update the model...




                        I‛ve just been clicked,
                        so I‛ll SET the model
                        to my value.





           So if the Seattle radio button is selected, it will update the model with
           a new value.
          You haven’t set values on the radio buttons yet; you’ve only set text
           descriptions. You could set the values to be whatever you want, but it is
           simplest to set them to the same thing used as the description of the field:

                     The text is the description                             This VALUE is the one that
                     that appears on the screen.                             will be used in the model.


                      RadioButton(app, text = "Cambridge, MA", value = "Cambridge, MA")
                                                                You can make the text different
                                                                from the value, but let's leave
                                                                them the same here.
           So what happens after the model is updated?



           276    Chapter 8
   306   307   308   309   310   311   312   313   314   315   316