Page 379 -
P. 379
volume controlled
You were to take the pygame and tkinter code and combine it to support a volume control,
then complete the next version of your program.
from tkinter import *
import pygame.mixer
app = Tk()
app.title("Head First Mix")
Things are starting to app.geometry('250x100+200+100')
get crowded on the GUI,
so let's have tkinter
automatically decide sound_file = "50459_M_RED_Nephlimizer.wav"
on the geometry for
us. Remove the “app..
geometry()” call from the mixer = pygame.mixer
code. mixer.init()
def track_toggle():
if track_playing.get() == 1:
track.play(loops = -1)
else:
track.stop()
Put the
pygame code
here. def change_volume(v):
track.set_volume(volume.get())
344 Chapter 9