Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label in Tkinter: change the text

I'm trying to change the value of the text of a label in tkinter, I'm using label.config() but it seems that the previous value still appears on the screen with the new value.

This is the code that I'm using:

This is the code that I'm using

This is the result, the previous and the new text are together:

This is the result, the previous and the new text are together

like image 960
Khalil Avatar asked Oct 21 '25 13:10

Khalil


1 Answers

Whenever select_description() is executed, new label is created and put in same cell. That is why there are overlapped text.

You need to create the label once outside the function:

description_label = Label(frame1)
description_label.grid(row=4, column=0, columnspan=4)

def select_description(event):
    choice = list_profiles.get(ANCHOR)
    if choice == 1:
        description_label.config(text=...)
    elif choice == 2:
        description_label.config(text=...)
like image 100
acw1668 Avatar answered Oct 23 '25 03:10

acw1668



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!