Tkinter how to change color of text

Asked

Viewed 1,885 times

0

How do I change the color of a label to make the background black and the letters white ?

I researched and what I found was the option to change the background to black however beyond the label background also changed the color of the letters.

The code I’m currently using is:

text1 = tk.Label(text='texto teste', background='black')

But this way everything turns black and consequently does not appear since my application has black background.

Here the shape that stays using red as an example:

inserir a descrição da imagem aqui

1 answer

1


Just add the parameter foreground in the creation of label which is used for bitmap text and Labels.

Therefore you just change from:

text1 = tk.Label(text='texto teste', background='black')

To:

text1 = tk.Label(text='texto teste', background='black', foreground='white')

Working example

Browser other questions tagged

You are not signed in. Login or sign up in order to post.