UPDATE: The New Mexico Tech tkinter website has been archived on GitHub. Also effbot was also archived since 2021.

First the best reference for Tkinter is this New Mexico Tech website. In the toc you will find a section on fonts, and in the section on Button widgets you'll find the option font.

you must have a Tkinter object to create a font

Python-2

Support for Python-2 has officially ended as of Jan 1, 2020

from Tkinter import *  # Note: UPPER case "T" in Tkinter
import tkFont
root = Tk()

Python-3

Python-3 Tk wrappers differ from Python-2

from tkinter import *  # Note: lower case "t" in tkinter
from tkinter import font as tkFont  # for convenience
root = Tk()

create a font like the example from New Mexico Tech website

helv36 = tkFont.Font(family='Helvetica', size=36, weight='bold')
# you don't have to use Helvetica or bold, this is just an example

(Note: recall for Python-3 font was imported as tkFont for convenience)

now you can set the font for button created from Button in the original post

button['font'] = helv36

The size of the button will depend on your geometry manager, EG: grid or pack. Only the grid method is covered in the layouts section by New Mexico Tech site, but effbot.org is also a great reference and he covers pack pretty well.

try:  # Python-2
    from Tkinter import *
    import tkFont
except ImportError:  # Python-3
    from tkinter import *
    from tkinter import font as tkFont
# using grid
# +------+-------------+
# | btn1 |    btn2     |
# +------+------+------+
# | btn3 | btn3 | btn4 |
# +-------------+------+
root = Tk()
# tkFont.BOLD == 'bold'
helv36 = tkFont.Font(family='Helvetica', size=36, weight=tkFont.BOLD)
btn1 = Button(text='btn1', font=helv36)
btn2 = Button(text='btn2', font=helv36)
btn3 = Button(text='btn3', font=helv36)
btn4 = Button(text='btn4', font=helv36)
btn5 = Button(text='btn5', font=helv36)
root.rowconfigure((0,1), weight=1)  # make buttons stretch when
root.columnconfigure((0,2), weight=1)  # when window is resized
btn1.grid(row=0, column=0, columnspan=1, sticky='EWNS')
btn2.grid(row=0, column=1, columnspan=2, sticky='EWNS')
btn3.grid(row=1, column=0, columnspan=1, sticky='EWNS')
btn4.grid(row=1, column=1, columnspan=1, sticky='EWNS')
btn5.grid(row=1, column=2, columnspan=1, sticky='EWNS')

Also try ttk.

Answer from Mark Mikofski on Stack Overflow
Top answer
1 of 4
21

UPDATE: The New Mexico Tech tkinter website has been archived on GitHub. Also effbot was also archived since 2021.

First the best reference for Tkinter is this New Mexico Tech website. In the toc you will find a section on fonts, and in the section on Button widgets you'll find the option font.

you must have a Tkinter object to create a font

Python-2

Support for Python-2 has officially ended as of Jan 1, 2020

from Tkinter import *  # Note: UPPER case "T" in Tkinter
import tkFont
root = Tk()

Python-3

Python-3 Tk wrappers differ from Python-2

from tkinter import *  # Note: lower case "t" in tkinter
from tkinter import font as tkFont  # for convenience
root = Tk()

create a font like the example from New Mexico Tech website

helv36 = tkFont.Font(family='Helvetica', size=36, weight='bold')
# you don't have to use Helvetica or bold, this is just an example

(Note: recall for Python-3 font was imported as tkFont for convenience)

now you can set the font for button created from Button in the original post

button['font'] = helv36

The size of the button will depend on your geometry manager, EG: grid or pack. Only the grid method is covered in the layouts section by New Mexico Tech site, but effbot.org is also a great reference and he covers pack pretty well.

try:  # Python-2
    from Tkinter import *
    import tkFont
except ImportError:  # Python-3
    from tkinter import *
    from tkinter import font as tkFont
# using grid
# +------+-------------+
# | btn1 |    btn2     |
# +------+------+------+
# | btn3 | btn3 | btn4 |
# +-------------+------+
root = Tk()
# tkFont.BOLD == 'bold'
helv36 = tkFont.Font(family='Helvetica', size=36, weight=tkFont.BOLD)
btn1 = Button(text='btn1', font=helv36)
btn2 = Button(text='btn2', font=helv36)
btn3 = Button(text='btn3', font=helv36)
btn4 = Button(text='btn4', font=helv36)
btn5 = Button(text='btn5', font=helv36)
root.rowconfigure((0,1), weight=1)  # make buttons stretch when
root.columnconfigure((0,2), weight=1)  # when window is resized
btn1.grid(row=0, column=0, columnspan=1, sticky='EWNS')
btn2.grid(row=0, column=1, columnspan=2, sticky='EWNS')
btn3.grid(row=1, column=0, columnspan=1, sticky='EWNS')
btn4.grid(row=1, column=1, columnspan=1, sticky='EWNS')
btn5.grid(row=1, column=2, columnspan=1, sticky='EWNS')

Also try ttk.

2 of 4
8

tkdocs tutorial recommends using named fonts and styles if you want to tweak the appearences:

import random
try:
    import tkinter as Tk
    import tkinter.ttk as ttk
    import tkinter.font as font
except ImportError: # Python 2
    import Tkinter as Tk
    import ttk
    import tkFont as font

def change_font_family(query, named_font):
    named_font.configure(family=random.choice(font.families()))

root = parent = Tk.Tk()
root.title("Change font demo")

# standard named font (everything that uses it will change)
font.nametofont('TkDefaultFont').configure(size=5) # tiny

# you can use your own font
MyFont = font.Font(weight='bold')

query = Tk.StringVar()
ttk.Entry(parent, textvariable=query, font=MyFont).grid() # set font directly
ttk.Button(parent, text='Change Font Family',  style='TButton', # or use style
           command=lambda: change_font_family(query, MyFont)).grid()
query.set("The quick brown fox...")

# change font that widgets with 'TButton' style use
root.after(3000, lambda: ttk.Style().configure('TButton', font=MyFont))
# change font size for everything that uses MyFont
root.after(5000, lambda: MyFont.configure(size=48)) # in 5 seconds
root.mainloop()
🌐
GitHub
github.com › TomSchimansky › CustomTkinter › discussions › 104
Font Size of Button text · TomSchimansky/CustomTkinter · Discussion #104
custom_font =("Times",30,'bold') btn = customtkinter.CTkButton(master=root, text="something", text_font=custom_font , command=func()) btn .pack()
Author   TomSchimansky
Discussions

python - Change font size without messing with Tkinter button size - Stack Overflow
I am having trouble changing the font size of a button in Tkinter, when I attempt to do it the button also expands/contracts based on the size of the text. Is there a way I can alter the text size ... More on stackoverflow.com
🌐 stackoverflow.com
Font size on buttons
Can it be changed More on github.com
🌐 github.com
4
May 3, 2017
How do I make the buttons be square in Tkinter?
By default, width and height of Tkinter buttons is set in text units. A text unit is either the width or the height of the character 0 (zero) in the font you're currently using. So you can see the problem. 10 text units high is more distance than 10 text units wide, and the difference depends on which font you're using. You can set the size of the button in pixels using a bit of a trick. If you add an image to the button, the size values will be interpreted as pixels. So, you can just create a blank 1x1 image and add it to the button. You also need to set the button's "compound" parameter so that it shows both the text and image. Here's a sample: import tkinter as tk root = tk.Tkinter() i = tk.PhotoImage(width=1, height=1) # this button will be tall and rectangular, because it's using text units b1 = tk.Button(root, text='text units', width=20, height=20) b1.pack # this button will be square, because it's using pixels b2 = tk.Button(root, text='Pixels', image=i, compound='c', width=100, height=100) b2.pack root.mainloop() More on reddit.com
🌐 r/learnpython
2
9
March 18, 2022
Widgets don't fill available space and don't resize
When I resize the window, there is no change in the size of the text box: Set expand to True expand= Specifies whether the widgets should be expanded to fill any extra space in the geometry master. If false (default), the widget is not expanded. In the future, look at grid(). Pack is easier, but grid is more flexible IMHO. More on reddit.com
🌐 r/Tkinter
5
1
October 15, 2023
🌐
TutorialsPoint
tutorialspoint.com › how-to-change-the-font-and-size-of-buttons-and-frame-in-tkinter
How to change the font and size of buttons and frame in tkinter?
April 15, 2021 - #Import tkinter library from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the Geometry win.geometry("750x250") def click_to_close(): win.destroy() #Create a Button button= Button(win, text= "Click to Close", font= ('Helvetica 20 bold italic'), command=click_to_close) ...
🌐
Python Examples
pythonexamples.org › python-tkinter-button-change-font
How to change Tkinter Button font style? Examples
Font size of the button is 30. You can change font weight of the text in tkinter Button, by passing named argument weight to font.Font().
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-dynamically-resize-button-text-in-tkinter
How To Dynamically Resize Button Text in Tkinter? | GeeksforGeeks
October 16, 2021 - Set bind, what bind will do, whenever button size change it will call resize function that we will create later. Inside the resize function, we will have a different condition, depends on the main window geometry/size. ... Step 1: Creates a normal Tkinter window.
🌐
Python Forum
python-forum.io › thread-36193.html
how to change font size
January 26, 2022 - I have a button defined below. What does 40 mean? Is there a 40 font? How do I change the font size. i.e. maker it larger or smaller? buttonGetAzEl=tk.Button(frame, text="GetAzEl", font = 40, command
Top answer
1 of 3
7

Typically, when you give a button a width, that width is measured in characters (ie: width=1 means the width of one average sized character). However, if the button has an image then the width specifies a size in pixels.  

A button can contain both an image and text, so one strategy is to put a 1x1 pixel as an image so that you can specify the button size in pixels. When you do that and you change the font size, the button will not grow since it was given an absolute size.

Here is an example that illustrates the technique. Run the code, then click on "bigger" or "smaller" to see that the text changes size but the button does not.

import Tkinter as tk
import tkFont

def bigger():
    size = font.cget("size")
    font.configure(size=size+2)

def smaller():
    size = font.cget("size")
    size = max(2, size-2)
    font.configure(size=size)

root = tk.Tk()
font = tkFont.Font(family="Helvetica", size=12)

toolbar = tk.Frame(root)
container = tk.Frame(root)

toolbar.pack(side="top", fill="x")
container.pack(side="top", fill="both", expand=True)

bigger = tk.Button(toolbar, text="Bigger", command=bigger)
smaller = tk.Button(toolbar, text="Smaller", command=smaller)

bigger.pack(side="left")
smaller.pack(side="left")

pixel = tk.PhotoImage(width=1, height=1)
for row in range(3):
    container.grid_rowconfigure(row, weight=1)
    for column in range(3):
        container.grid_columnconfigure(column, weight=1)
        button = tk.Button(container, font=font, text="x",
            image=pixel, compound="center", width=20, height=20)
        button.grid(row=row, column=column)

root.mainloop()

All of that being said, there is almost never a time when this is a good idea. If the user wants a larger font, the whole UI should adapt. Tkinter is really good at making that happen, to the point where it all mostly works by default.

2 of 3
2

The width of the button is defined in units of character width. In your case the button is defined to be 17 characters wide. So changing the character width by (ie changing the font size) changes the width of the button. AFAIK, the only way around that is to put the button into a Frame, because a Frame can define it's size in pixels. Here's a new kind of Button that does exactly that:

import Tkinter as tk

class Warspyking(tk.Frame):
    '''A button that has it's width and height set in pixels'''
    def __init__(self, master=None, **kwargs):
        tk.Frame.__init__(self, master)
        self.rowconfigure(0, minsize=kwargs.pop('height', None))
        self.columnconfigure(0, minsize=kwargs.pop('width', None))
        self.btn = tk.Button(self, **kwargs)
        self.btn.grid(row=0, column=0, sticky="nsew")
        self.config = self.btn.config

#example usage:
MyWindow = tk.Tk()
MyWindow.geometry("500x550")

from itertools import cycle
fonts = cycle((('Helvetica', '11'),('Helvetica', '15'),('Helvetica', '20')))
def chg():
    button.config(font=next(fonts))

button = Warspyking(MyWindow,text="Click me!",width=200,height=100 ,font=next(fonts), command=chg)
button.grid(row=1, column=1)

MyWindow.mainloop()

EDIT: Based on what I learned from Bryan Oakley, here's a much neater implementation:

class Warspyking(tk.Button):
    def __init__(self, master=None, **kwargs):
        self.img = tk.PhotoImage()
        tk.Button.__init__(self, master, image=self.img, compound='center', **kwargs)

I should also add that I very much agree with Bryan: Using this is probably a sign that you are doing something wrong. You should let tkinter handle sizing.

Find elsewhere
🌐
TutorialKart
tutorialkart.com › python › tkinter › button › font
Tkinter Button font Option - Font Family, Size, Weight, Underline, Strikethrough, Slant
November 30, 2020 - Tkinter Button font option sets the font family, font size, font weight, slant, underline and overstrike properties of text in button. In other words, the font style of Button's text label.
🌐
Tkinter
tkinter.com › how-to-resize-buttons-in-ttkbootstrap-tkinter-ttkbootstrap-4
How To Resize Buttons in TTKBootstrap – Tkinter TTKBootstrap 4 – TKinter.com
January 3, 2023 - To resize a button and it’s font with ttkbootstrap, you need to use a Style() widget. And you need to name that style a very specific way to get the outcome that you want. ... from tkinter import * import ttkbootstrap as tb root = tb.Window(themename="superhero") #root = Tk() root.title("TTK ...
🌐
Sololearn
sololearn.com › en › Discuss › 3229529 › python-adjusting-text-size-in-a-button
Python: Adjusting Text Size in a Button | Sololearn: Learn to code for FREE!
Following the suggestion from ChatGBT, I tried using the font() function to change the text size of the button. However, this approach not only changed the text size but also affected the button's size, which was not the desired outcome. ... You could try setting the width and height properties of the button, if you want it to have a specific size. https://pythonexamples.org/JUMP_LINK__&&__python__&&__JUMP_LINK-button-tkinter-example/ https://pythonexamples.org/python-tkinter-button-change-font/
🌐
StackHowTo
stackhowto.com › home › python › tkinter › how to change font and size of buttons in tkinter python
How to change font and size of buttons in Tkinter Python - StackHowTo
January 12, 2022 - In this tutorial, we are going to see how to change the font and size of buttons in Tkinter Python. You can change the font and size of the Tkinter buttons, using the tkinter.font package.
🌐
YouTube
youtube.com › codemy.com
How To Dynamically Resize Button Text - Python Tkinter GUI Tutorial #146 - YouTube
In this video I'll show you how to dynamically resize your button text when you resize your app with Tkinter and Python.In the last video I showed you how to...
Published   November 19, 2020
Views   14K
🌐
GitHub
github.com › lawsie › guizero › issues › 21
Font size on buttons · Issue #21 · lawsie/guizero
May 3, 2017 - Font size on buttons#21 · Copy link · lawsie · opened · on May 3, 2017 · Issue body actions · Can it be changed? Reactions are currently unavailable · No one assigned · No labels · No labels · No projects · No milestone · None yet · No branches or pull requests ·
Author   lawsie
🌐
AskPython
askpython.com › home › how to set the font size in tkinter?
How to set the font size in Tkinter? - AskPython
October 19, 2022 - If not mentioned explicitly, the parameters will have their default values. In the above code, we have only used the size property and set the size to 15. ... import tkinter as tk from tkinter import * import tkinter.font as tkFont #main window ...
🌐
Tkinter
tkinter.com › change-font-size-and-font-style-python-tkinter-gui-tutorial-193
Change Font Size and Font Style – Python Tkinter GUI Tutorial 193 – TKinter.com
September 28, 2021 - We’ll add whatever font sizes you want, and we’ll also add these styles: regular (normal), bold, italic, underline, and strikethrough. ... from tkinter import * from tkinter import font root = Tk() root.title('Codemy.com - Font Dialog Box') root.iconbitmap('c:/gui/codemy.ico') ...
🌐
Delft Stack
delftstack.com › home › howto › python tkinter › how to change the tkinter button size
How to Change the Tkinter Button Size | Delft Stack
February 5, 2025 - If compound is not configured, the text will not show in the button. import tkinter as tk import tkinter.font as tkFont app = tk.Tk() app.geometry("300x100") fontStyle = tkFont.Font(family="Lucida Grande", size=20) labelExample = tk.Label(app, ...
🌐
Dafarry
dafarry.github.io › tkinterbook › button.htm
The Tkinter Button Widget
The default is system specific. (font/Font) ... The color to use for text and bitmap content. The default is system specific. (foreground/Foreground) ... Same as foreground. ... The height of the button. If the button displays text, the size is given in text units.
🌐
GitHub
github.com › TomSchimansky › CustomTkinter › discussions › 121
Changing font size of a button · TomSchimansky/CustomTkinter · Discussion #121
# this method was added to CTkButton, I won't repeat all the code for simplify it def set_text_size(self, size): # this is needed because the text can be None or "" # it happens if the bt has an image if type(self.text_label).__name__ == "Label": # default is -13 # get saved font family font_family = ThemeManager.theme["text"]["font"] # pass a newly created tuple with the current font family and new font size self.text_font = (font_family, str(size)) # destroy previous self.text.label self.text_label.destroy() # create a new text label with the new font size self.text_label = tkinter.Label(mas
Author   TomSchimansky
🌐
CSDN
devpress.csdn.net › python › 630459e27e6682346619a5a5.html
How to change font and size of buttons and frame in tkinter using python?_python_Mangs-Python
In the toc you will find a section on fonts, and in the section on Button widgets you'll find the option font. ... from tkinter import * # Note: lower case "t" in tkinter from tkinter import font as tkFont # for convenience root = Tk() create a font like the example from New Mexico Tech website ...
🌐
Reddit
reddit.com › r/learnpython › how do i make the buttons be square in tkinter?
r/learnpython on Reddit: How do I make the buttons be square in Tkinter?
March 18, 2022 -

I tried to do it with padx and pady by setting them to the same value, not square.

I tried to do it with width and height parameters also setting them to the same value, it's still not square.

I am stuck, does anyone know why these methods are not working and which ones do?