Page 308 -
P. 308

guis and data


           Creating radio buttons in tkinter


          You need to create three radio buttons in the interface, one for each of the
           depots. This is how you might do that in tkinter:





           You don't need the
           Entry field anymore.




                  Label(app, text = "Depot:").pack()
                   depot=Entry(app)
                                                                                 This is the text
                   depot.pack()                                                  that will appear
                                                                                 next to the radio
                   Radiobutton(app, text = "Cambridge, MA").pack()
                                                                                button.
                   Radiobutton(app, text = "Cambridge, UK").pack()
                   Radiobutton(app, text = "Seattle, WA").pack()
                  Label(app, text = "Description:").pack()











           You need to remove the depot Entry widget and replace it with three
           Radiobutton widgets, one for each of the valid depots. The text given to
           each widget will be the text that appears alongside the radio button in the
           interface.
           What about reading which radio button has been selected? For now, you just
           need to create a prototype of the interface, so there’s no need to change any
           of the code that saves records. That’s something we can deal with later.


           Let’s demo the new interface to the guys at Head-Ex.










                                                                                       you are here 4    273
   303   304   305   306   307   308   309   310   311   312   313