Page 368 -
P. 368
graphical interface elements
1 Here’s your code from earlier. Use your pencil to put a line
through the code you don’t need anymore:
from tkinter import *
import pygame.mixer
app = Tk()
app.title("Head First Mix")
app.geometry('250x100+200+100')
sound_file = "50459_M_RED_Nephlimizer.wav"
mixer = pygame.mixer
mixer.init()
def track_start():
track.play(loops = -1)
def track_stop():
track.stop()
def shutdown():
track.stop()
app.destroy()
track = mixer.Sound(sound_file)
start_button = Button(app, command = track_start, text = "Start")
start_button.pack(side = LEFT)
stop_button = Button(app, command = track_stop, text = "Stop")
stop_button.pack(side = RIGHT)
app.protocol("WM_DELETE_WINDOW", shutdown)
app.mainloop()
Write the code you need to implement the checkbox here, based on the sample code from the previous
2
page. Give your IntVar the name track_playing. Use track_toggle as your function name,
and call the checkbox track_button:
you are here 4 333