O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the volume change function

We have already defined the volume method in the Player class. Now, all that you need to do is simply get the value of the Volume Scale widget and set the volume in the Player class.

Also, ensure that in case the volume becomes zero, we change the volume button icon to the mute image (see code 5.04view.py):

def on_volume_scale_changed(self, value):  self.player.volume = self.volume_scale.get()  if self.volume_scale.get() == 0.0:    self.mute_unmute_button.config(image=self.mute_icon)  else:    self.mute_unmute_button.config(image=self.unmute_icon)

This concludes the iteration. The player is now functional enough to be called an audio player. Go ahead and add some music files to the player. Press the play button and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required