Style().configure don't works for all widgets

Peter Otten __peter__ at web.de
Fri Nov 18 11:51:59 EST 2016


Luis Marzulli wrote:

> ttk.Style().configure(".", font=('Courier New', 30, "bold"))
> 
> works for Button and Label widgets (and maybe others) and don't works for
> Entry widget?
> 
> Example in Python 3:
> from tkinter import *
> from tkinter import ttk
> from tkinter import font
> 
> root = Tk()
> ttk.Style().configure(".", font=('Courier New', 30, "bold"))
> 
> ttk.Entry(root).grid() # don't works
> ttk.Label(root, text="my text").grid() # works OK
> ttk.Button(root, text="some text").grid() # works OK
> 
> root.mainloop()

I can confirm this, but I have no idea why this is so.
As a workaround you can set the font directly:

FONT = ("Courier New", 30, "bold")
ttk.Style().configure(".", font=FONT)
...
ttk.Entry(root, font=FONT)




More information about the Python-list mailing list