title: Changing image in tkinter canvas in while loop
body: <p>Entirety of my code is <a href="https://gist.github.com/ItsBerry/de245ba70376cb07f4dbe2d25c223f5f" rel="noreferrer">here</a>.</p>
  
  <p>Using tkinter's canvas, I am trying to create a small game that allows people to practice learning the notes on the treble clef.</p>
  
  <p>A random note is initially displayed and the user must select the correct note. I am unable to edit the canvas to display a new note's image if the student got the correct answer.</p>
  
  <p>Can somebody please explain what the problem is with my code?</p>
  
  <pre><code>while True:
      randomNote = randint(0, 11)
      path = noteFiles[randomNote]
      correctNote = notes[randomNote]
      img = Image.open(path)
      tk_img = ImageTk.PhotoImage(img)
      canvas.create_image(505, 200, image=tk_img)
  
      root.mainloop()
      if correctNote == noteChosen:
          ''' User got last note right '''
          canvas.delete("all")
  </code></pre>