Answers for "tkinter change button text"

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
-2

how to change text of Button in tkinter

from tkinter import *
import tkinter.font as font

gui = Tk(className='Python Examples - Button')
gui.geometry("500x200")

# define font
myFont = font.Font(size=30)

# create button
button = Button(gui, text='My Button', bg='#0052cc', fg='#ffffff')
# apply font to the button label
button['font'] = myFont
# add button to gui window
button.pack()

gui.mainloop()
Posted by: Guest on July-06-2020

Code answers related to "tkinter change button text"

Python Answers by Framework

Browse Popular Code Answers by Language