Ashok
Ashok

Reputation: 315

How to create a Label widget with a transparent background using tkinter?

I wanted to create an app which has an image as its background. But when I add a Label over the image, the label had a white background.

Is there a way to set the Label widget's background color to 'transparent'?

Upvotes: 10

Views: 14081

Answers (1)

Justin S Barrett
Justin S Barrett

Reputation: 646

I'm not aware of a way to make Label backgrounds transparent. One alternative is to use a Canvas widget as the base for the whole thing, then use the create_image method to add the background image, and create_text to make the text labels. It will be a bit more work, but the text should render without a background on top of the image. (Admittedly I have very little experience with the Canvas widget, so I'm speaking more from theory than experience, but it's worth a try.)

If you don't have a good Tkinter reference, I highly recommend this one made by New Mexico Tech. It's available as a downloadable PDF as well.

Upvotes: 11

Related Questions