Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

python - How to create transparent widgets using Tkinter?

I'm new to Python. I wanted to create an app which has an image as its background. But when I add a 'Label' over the image, I could see a white background to the label. Do we have a solution to make the 'Label' widgets color set to 'transparent' ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...