Page 275 -
P. 275
making connections
The code from the nongraphical version of the TVN program is on
this and the facing page. Take your pencil and mark the parts of
the code that you would extract and turn into functions so that
you can then connect the functions to the buttons in your GUI.
Mark the other parts of this program that also need to be added
to the GUI version.
The nature of the Note: Don’t worry about prompting the host to ask a question in
interface provided by the the GUI. But do worry about maintaining a count of the number
GUI means that some of of questions answered correctly and incorrectly. (The total count
is not important, either.)
the program’s requirements
have changed.
How many functions do you think you need? Write their names here:
import pygame.mixer
def wait_finish(channel):
while channel.get_busy():
pass
sounds = pygame.mixer
sounds.init()
correct_s = sounds.Sound("correct.wav")
wrong_s = sounds.Sound("wrong.wav")
prompt = "Press 1 for Correct, 2 for Wrong, or 0 to Quit: "
number_asked = 0
number_correct = 0
number_wrong = 0
240 Chapter 7