Answers for "how to change tkinter label text on button press"

1

Update label text after pressing a button in Tkinter

#tested and working on PYTHON 3.8 AND ADDED TO PATH
import tkinter as tk
win = tk.Tk()

def changetext():
	a.config(text="changed text!")
    
a = tk.Label(win, text="hello world")
a.pack()
tk.Button(win, text="Change Label Text", command=changetext).pack()

win.mainloop()
Posted by: Guest on February-28-2020
0

tkinter change button text

import tkinter as tk

root = tk.Tk()

def update_btn_text():
    btn_text.set("b")

btn_text = tk.StringVar()
btn = tk.Button(root, textvariable=btn_text, command=update_btn_text)
btn_text.set("a")

btn.pack()

root.mainloop()
Posted by: Guest on September-15-2021

Code answers related to "how to change tkinter label text on button press"

Python Answers by Framework

Browse Popular Code Answers by Language