문제

This is an example. size = 2 label = Label(tk, text=size) label.pack() size = 3 Can i update the label to say 3?

도움이 되었습니까?

해결책

Yes, just used the config method:

label = Label(root,text="this is text!")
label.pack()

label.config(text="that was text!")

Another way to do this would be to set the textvariable attribute of the label.

textvar = StringVar()
textvar.set("this is text!")
label = Label(root,textvariable=textvar)
label.pack()

textvar.set("that was text!")

In this case the label instance will automatically update its text when the textvar instance is updated.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top