I want to use HTMLLabel in one of my Tkinter projects', but I dislike that the font size is hardcoded to 14. I want it to be 10 instead.
Adding the font=("Calibri", 10) does nothing to render font family or size.
from tkinter import *
from tkhtmlview import HTMLLabel
html = "Some text! Always size 14 :("
root = Tk()
root.title('html')
root.geometry('300x300')
my_label = HTMLLabel(root, html=html, state="normal", font=("Calibri", 10))
my_label.pack(pady=20,
padx=20,
fill="both",
expand=True)
root.mainloop()
I have noticed there is a variable FONT_SIZE in the Defs method of the class module html_parser.py:
class Defs():
DEFAULT_TEXT_FONT_FAMILY = (
"Segoe ui", "Calibri", "Helvetica", "TkTextFont")
FONT_SIZE = 14
}
If I change FONT_SIZE = 14 to
FONT_SIZE = 10 in the sourced module, it works everywhere.
Does anyone know how to set my font size to 10 in my script without editing the imported html_parser.py module, as I would imagine it's not an appropriate practice to edit a module this way?

Check setting the font size by the style. See the result: