Display/Update score on python using tkinter Display/Update score on python using tkinter tkinter tkinter

Display/Update score on python using tkinter


You should use Label for this purpose. You can use variable text to change its value whenever you want.

Let's take a small example:

var = StringVar()label = Label( root, textvariable=var)var.set("Hey!? How are you doing?")label.pack()

Now you can set it to anything you like anytime you want. You just need to do var.set("my text").

For reference you can look here

Edit:

If you wanna do it using canvas only then you can refer to this Bryan Oakley answer.


You can use the itemconfig to change the text in the canvas item:

canvas.itemconfig(J, text=Score)

As far as creating a global variable named J... this isn't an issue related to tkinter. The best solution is to switch to an object-oriented approach, where J is an attribute of some class.