Page 392 -
P. 392

custom widgets and classes


          Your new function needs to create widgets

           and event handlers                                                 Each widget


           When you’re wiring up the widgets in the interface, you need event handlers   needs its own
           to respond to changes in the state of the widgets. If someone clicks the
           checkbox to play the track, the track_toggle() event handler gets called   event handler.
           and switches the track on or off.
           But if you are creating several checkoxes, you are going to need a separate event
           handler for each of them.
           That’s why you have local functions inside create_gui(). As well as creating
           new widgets for the interface, it also uses the local functions to create new
           event handlers.



                    track_toggle()                                           change_volume()



            This is a new checkbox                                                This is a new slider
             event handler.                                                       event handler.














                  This is a new                                                  This is a new Scale.
                  Checkbutton.




                              create_gui()










           Now, let’s update the program to use this new function.


                                                                                      you are here 4    357
   387   388   389   390   391   392   393   394   395   396   397