Using IDLE, I have written an interactive python program using pygame and saved it as file Songboard01.py. I use IDLE's run command or f5 to run the script. The user responds initially to the IDLE shell, which asks a startup question, after which all the responses are mouse clicks on the pygame screen. In addition to game play, the screen allows the user to click on alternatives such as (1) 'Quit', (2) 'Instructions', (3) 'Credits', (4) 'Solutions', and (5) 'Play again'. The first three work fine, and the game is able to pick up without a problem after (2) or (3). It is 'Play again' that has me stumped.
This function:
def new_game():
done = True # closes pygame while-loop
pygame.quit()
import Songboard01.py
will start the game over with the startup question in the IDLE shell, but it only works once. If the user tries to get a new game a second time, the error message ends:
File "/Users/anobium/Desktop/SongBoard/Songboard01.py", line 314, in new_game import Songboard01.py ModuleNotFoundError: No module named 'Songboard01.py'; 'Songboard01' is not a package