Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a Label Bold Tkinter

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 ?

like image 741
zzz123 Avatar asked Sep 29 '17 18:09

zzz123


People also ask

How do you bold a label in Python?

The command fontweight='bold' can be used to make a textbox or label in figure bold.

How do I change text font in Python?

In your Python program, import tkinter. font as font, create font. Font() object with required options and assign the Font object to font option of Button.

What is the default font tkinter?

Output. Running the above code will set the default font as "lucida 20 bold italic" for all the widgets that uses textual information.


3 Answers

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')
like image 154
adder Avatar answered Oct 16 '22 03:10

adder


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

like image 43
Trooper Z Avatar answered Oct 16 '22 04:10

Trooper Z


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. :)

like image 30
Kirro Smith Avatar answered Oct 16 '22 04:10

Kirro Smith