23

How do I make a Label in Tkinter Bold ?

This is my code

labelPryProt=Label(frame1,text="TEXTTEXT")
labelPryProt.pack(side=LEFT,fill=BOTH,expand=False)
labelPryProt.configure(font=("Helvetica",BOLD, 18))#this is not working not making the text as bold

What is the error ?

Jongware
  • 22,200
  • 8
  • 54
  • 100
zzz123
  • 341
  • 1
  • 2
  • 7

3 Answers3

40

You don't have to configure it separately, you can pass an argument when you are creating the widget:

labelPryProt = Label(frame1, text='TEXTTEXT', font='Helvetica 18 bold')
adder
  • 3,512
  • 1
  • 16
  • 28
  • What if I have to change it later ? – zzz123 Sep 29 '17 at 18:47
  • Let's say I allow user to change the text type so how to configure that ? how to change it without declaring the variable again labelPryProt = Label() – zzz123 Sep 29 '17 at 18:48
  • 4
    Sure, than you'll have to configure it. `labelPryProt.configure(font='Helvetica 18 bold')` – adder Sep 29 '17 at 18:48
  • 3
    @zzz123: the better solution is to use a font object, so you only have to change it in one place. See http://www.tkdocs.com/tutorial/fonts.html – Bryan Oakley Sep 29 '17 at 19:06
  • This answer is definitely wrong. The question explicitly asks about making a tk Label bold. The answer here is about something else involving the Helvetica font and the font size 18. => -1 – WhyWhat Apr 13 '20 at 19:46
14

You have to put bold in quotes, like this: label = Label(frame1, text='Hello', font=('Helvetica', 18, 'bold')) . This method works for me.

Community
  • 1
  • 1
Trooper Z
  • 1,617
  • 14
  • 31
6

Just put bold in the quotes, example : label = Label(frame1, text = "TEXTTEXT", font = ('Helvetica', 18, 'bold')) That work for me, configure also work but you have to make one more line of code. If you want, I can show you how to .configure: Just add this code : label.configure(font=("Helvetica","bold", 18))

Thanks. :)

Kirro Smith
  • 71
  • 1
  • 3