1import tkinter as tk
2
3root = tk.Tk()
4
5def update_btn_text():
6 btn_text.set("b")
7
8btn_text = tk.StringVar()
9btn = tk.Button(root, textvariable=btn_text, command=update_btn_text)
10btn_text.set("a")
11
12btn.pack()
13
14root.mainloop()
15
1from tkinter import *
2import tkinter.font as font
3
4gui = Tk(className='Python Examples - Button')
5gui.geometry("500x200")
6
7# define font
8myFont = font.Font(size=30)
9
10# create button
11button = Button(gui, text='My Button', bg='#0052cc', fg='#ffffff')
12# apply font to the button label
13button['font'] = myFont
14# add button to gui window
15button.pack()
16
17gui.mainloop()