Page 287 -
P. 287
label results
Based on what you now know about adding a label to a GUI, you
were asked to rework your GUI code so that it uses two labels.
One should display the number of correct answers and the other
should display the number of wrong answers. We left plenty
of room for you to write in all the code that your program now
needs.
Start by importing the from tkinter import *
library code you need.
import pygame.mixer
def play_correct_sound():
num_good.set(num_good.get() + 1)
correct_s.play()
Create the two
event handlers
that set the
IntVar and play def play_wrong_sound():
the appropriate num_bad.set(num_bad.get() + 1)
sound.
wrong_s.play()
app = Tk()
Create the GUI app.title(“TVN Game Show")
application window.
app.geometry(‘300x110+200+100')
Initialize the sounds = pygame.mixer
sound system. sounds.init()
252 Chapter 7