Page 406 -
P. 406

custom widgets and classes


                       Code Magnets

                       We’ve started to create the initializer code for you, but there are still a few
                       parts missing. See if you can work out where the missing code fragments
                       fit. Here is the code that creates a SoundPanel() object. Position the
                       code magnets properly to complete the method:




                  def __init__(self, app, mixer, sound_file):
                      Frame.__init__(self, app)
                                                        Because SoundPanel() inherits from

                                                        tkinter’s Frame(), you need to be sure
                                                        to initialize the Frame() BEFORE you
                                                        initialize the SoundPanel().

                      track_button = Checkbutton(         , variable =                           ,

                                                    command = self.track_toggle, text = sound_file)
                      track_button.pack(side = LEFT)


                      self.volume.set(track.get_volume())
                      volume_scale = Scale(         , variable = self.volume, from_ = 0.0, to = 1.0,

                                             resolution = 0.1, command =                     ,


                                                label = "Volume", orient = HORIZONTAL)
                      volume_scale.pack(side = RIGHT)










               volume = DoubleVar()
                                                                                       self.
                                                                       self
                                              change_volume
                             self.
                  self.                                                 self.        track_playing
                                track = mixer.Sound(sound_file)
                                                                                     self.
                   track_playing = IntVar()                  self

                                                                                      you are here 4    371
   401   402   403   404   405   406   407   408   409   410   411