A
A
Anatoly Belousov2021-11-29 20:53:45
Python
Anatoly Belousov, 2021-11-29 20:53:45

How to make a Label from TKinter with the background of your image?

Hello, I create a Label with my background:

font = tk.PhotoImage(file='font.png') 
image_font = tk.Label(win, image=font, textvariable=text_value) 
image_font.place(x=10, y=70)

The Label is displayed with an image, but it overrides the text I pass in for the label. How can I fix this and what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Belousov, 2021-11-30
@no_name_774

I found the answer:
When I create a label, I also pass compound=tk.CENTER
It turns out like this:

font = tk.PhotoImage(file='font.png') 
image_font = tk.Label(win, image=font, textvariable=text_value, compound=tk.CENTER) 
image_font.place(x=10, y=70)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question