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.

This is -the model hidden away in Y^

Computer's memory--^

Q Cambridge, MA

This is -the model hidden away in Y^

Computer's memory--^

Seattle, WA

0 Cambridge, UK

Seattle, WA

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 that appears on the screen.

TWlS MLUfc is the one that ^ 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?

Was this article helpful?

0 0

Post a comment