Can't change button font size in tkinter Can't change button font size in tkinter tkinter tkinter

Can't change button font size in tkinter


You do not need to import font. ttk style has its own font argument.Just put the style in the first option and the font size in the 2nd option.

I would also use the variable name to edit the style. Instead of calling:

ttk.Style().configure()

Do this:

style.configure()

Take a look at the below.

import tkinterimport tkinter.ttk as ttkroot = tkinter.Tk()frame = ttk.Frame(root)frame.grid(column=0, row=0)style = ttk.Style(root)style.configure("TButton", font=('wasy10', 80))ttk.Button(frame, text="Open file", command=None, style="TButton").grid(column=0, row=1)root.mainloop()

On the advice of Bryan Oakley in the comments here is a 2nd option that is close to what you are trying to do with fort.

This option saves a referent to the font object and then uses it to update the style.

import tkinterimport tkinter.ttk as ttkfrom tkinter import fontroot = tkinter.Tk()frame = ttk.Frame(root)frame.grid(column=0, row=0)style = ttk.Style(root)font = font.Font(family="wasy10", size=80)style.configure("TButton", font=font)ttk.Button(frame, text="Open file", command=None, style="TButton").grid(column=0, row=1)root.mainloop()