Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canvas Text update - Python3 Tkinter

I have a tkinter Canvas with a C.create_text, determined by a variable.

var = "Hello"
C = tk.Canvas(top, width = 1000, height = 500)
p = C.create_text(500, 80, text = var, font = "monaco")

and when I press a button it changes the variable, but I have no idea how to update the text in the canvas

def add():
    var = "Hello World"

b = tk.Button(text = "world", command = add)
like image 864
Campa Avatar asked Sep 15 '25 22:09

Campa


1 Answers

Use

C.itemconfigure(p, text=var)
like image 83
MarianD Avatar answered Sep 19 '25 14:09

MarianD