title: Display/Update score on python using tkinter
body: <p>I'm making an arcade game using tkinter GUI, that as most arcades, needs a score display on screen that updates every time the user kills an enemy (obviously).</p>
  <p>I am doing it by creating a text on a canvas, and calling a function that creates another one, but this time with the score value (Which is a global variable) updated.</p>
  <p>So, to do that in the right way, I must delete the text that has been created before and then create the new one in order for it to be displayed correctly, because otherwise (Which is my case) It'll be like a stack of text one over the other, and other, etc...</p>
  <p>So here's the code:</p>
  <pre><code>from tkinter import *
  
  Root= Tk()
  canvas= Canvas(Root,width=500, height=500, bg=&quot;white&quot;)
  canvas.pack()
  
  Score= 0 #This is the global with the score value
  
  J=canvas.create_text(100,100, text=(&quot;Score&quot;, Score), font=(&quot;Comic Sans&quot;, 50)) #This is the first appearance of the score on screen, or the first creation.
  
  def change(): #Here's where I change the score value and create the new text
      global Score
      Score+=1
      J=canvas.create_text(100,100, text=(&quot;Score&quot;, Score), font=(&quot;Comic Sans&quot;, 50))
  
  def changee(): #And this one, is supposed to work deleting the &quot;J&quot; every time it is called, but it only works the first time it is called with the first text
      canvas.delete(J)
      print(&quot;del&quot;)
  
  def do(): #This one calls the other two in a button (Because I need to call them like this on the actual game code
      change()
      changee()
  
  B= Button(canvas, text= &quot;change it&quot;, command=do) 
  B.place(x=300,y=300)
  </code></pre>
  <p>So I know I just could put the <code>J</code> as a global variable, but I can't do that, because on the game code the function is inside another function which is the one that calls a <code>Toplevel()</code> and does a <code>withdraw()</code> of the main window, and that means I cant define a global <code>J=canvas.create_text(100,100, text=(&quot;Score&quot;, Score), font=(&quot;Comic Sans&quot;, 50))</code> because if I do, it'll tell me that canvas its not yet created.</p>
  <p>So is there any way to do what I am trying to do, without having to use a <code>global J</code>? or any other easier way to do it?</p>
  <p>PD: Using python 3.3.5 rc1</p>