Page 396 -
P. 396

custom widgets and classes


                        Test Drive




           With the code typed into IDLE, take this latest version of the DJ’s program
           for a quick spin by pressing F5.







                         These check buttons
                         start and stop each
                         of the tracks.









                                                                                    These scales control
                                                                                     the volume.








           The program has created a checkbox and a volume slider for each track.
           The program called the create_gui() function twice, creating two sets
           of widgets. Of course, you can call it as many times as you like and the
           create_gui() function will create the two widgets for each track.
           When you click on the two checkboxes, the two tracks both play at the
           same time! You can start and stop each of them independently by selecting
           and deselecting the checkboxes. But more than that, the volume sliders
           independently change the volume of the tracks, allowing you to mix them
           together.
           This is a big deal. The create_gui() function is not only creating the
           separate widgets and adding them to the interface, but it is also creating the
           event handlers that allow each pair of widgets to control each separate track.
           Here the program is controlling just two tracks, but if you added more calls
           to create_gui() in the code, there’s no reason why you couldn’t get the
           interface to work with as many tracks as you like.

           Let’s see what the DJ thinks.

                                                                                      you are here 4    361
   391   392   393   394   395   396   397   398   399   400   401