Alex Weinstein Alex Weinstein - 1 year ago 104
Python Question

Python tkinter lisbox bold

I am trying to bold all of the entries for my python tkinter listbox.

I have a list and it enters it into a listbox:

listbox4.insert(END, Words)

Does anyone know the code to bold these entries?

Answer Source

you can configure the Font used by the listbox object for all of the text

assuming you are using python 3 and tkinter the code would be like follows (replace the import line with import tkFont on python 2)

from tkinter import font

listbox4.insert(END, Words)
bolded = font.Font(weight='bold') # will use the default font
listbox4.config(font=bolded)

see here for some more tkFont documentation in case you want to change the font-family, size, etc.