Azure-ttk-theme icon indicating copy to clipboard operation
Azure-ttk-theme copied to clipboard

Unable to change the font of ttk.Entry and ttk.Label

Open MyGuyCai opened this issue 2 years ago • 1 comments

Using ttk.Style() there is no impact on the font for both Entry and Label. My code is as follows: ttk.Style().configure("TEntry", font=("Righteous", 13 * -1), foreground="red") ttk.Style().configure("TLabel", font=("Righteous", 13 * -1), foreground="red") It seems to work at changing the color but fails to update the font. There is also a slight naming inacuracy with
ttk.Style().configure("Label", font=("Righteous", (13 + size * 2) * -1), foreground="orange") According to the docs it should be 'TLabelFrame' rather than just 'Label'

I have attached an image of the issue, the font of TMenubutton changes correctly but the font of TEntry and TLabel do not change. font_changes

MyGuyCai avatar May 03 '22 17:05 MyGuyCai

I haven't tried it out, but according to this page, setting the font for ttk.Entry is not possible using a style. You have to use the config method.

Also, it looks like you have to use a named font (from the tkinter.font module to change the font of the Label.

rdbende avatar Jul 08 '22 23:07 rdbende

I agree you cannot change the font of TEntry using styles, but still, the other issue exists. You cannot change the font of TLabel at all.

TheEnderek0 avatar Feb 10 '23 21:02 TheEnderek0

On the default tkinter theme changing the font of TLabel works fine, butusing Azure it just refuses to work.

TheEnderek0 avatar Feb 10 '23 21:02 TheEnderek0

1.

This works for changing the font of the Label, unless it is explicitly set to something else:

ttk.Style().configure("TLabel", font=("Righteous", -13), foreground="red")

2.

according to this page, setting the font for ttk.Entry is not possible using a style. You have to use the config method.

As I said, it's not possible to configure the font of TEntry using a style. Even this theme can't do it.

3.

There is also a slight naming inaccuracy with ttk.Style().configure("Label", font=("Righteous", (13 + size * 2) * -1), foreground="orange") According to the docs it should be 'TLabelFrame' rather than just 'Label'

No, it should be simply Label, which is the actual label component of the labelframe, the LabelFrame style class will configure the frame itself.

rdbende avatar Apr 17 '23 15:04 rdbende