4

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)
0

1 Answer 1

7

Use

C.itemconfigure(p, text=var)
Sign up to request clarification or add additional context in comments.

1 Comment

Worked. Thank you very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.