Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Adding the mute/unmute function

This is similar to coding the pause/unpause feature. We need an attribute that can toggle between the mute and unmute strings. Accordingly, add an attribute, as follows (see code 5.04view.py):

toggle_mute_unmute = itertools.cycle(["mute","unmute"]) 

Then, modify the command callback to call the mute or unmute functions from the player class, change the button icon to the mute or unmute image, and shift the volume scale accordingly, as follows (see code 5.04view.py):

def on_mute_unmute_button_clicked(self):  action = next(self.toggle_mute_unmute)  if action == 'mute':    self.volume_at_time_of_mute = self.player.volume    self.player.mute()    self.volume_scale.set(0) self.mute_unmute_button.config(image=self.mute_icon) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content