Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python tkinter change label text

from tkinter import *

root = Tk()
root.title('Test')


def change_text():
    print(my_label)
    my_label.config(text='new text')
    my_label.grid(row=0, column=0)


# create
my_label = Label(root, text='Hello World')
my_button = Button(root, text='click me', command=change_text, bg='#FFFF00')

# draw
my_label.grid()
my_button.grid()

# run
root.mainloop()
 
PREVIOUS NEXT
Tagged: #python #tkinter #change #label #text
ADD COMMENT
Topic
Name
3+3 =