+ 3
How to show transparent image in Tkinter.
I was showing a transparent image like logo, but the image transparent area were covered with grey colour. Anything to solve this.
18 Réponses
+ 1
I also have same problem.
What I did is just edited the image and changed image background to match with tkinter background.
(In my case i didn't used any special graphical background for tkinter window, its just only a simple plain color)
+ 3
You should use canvas widget in tkinter. That explains it very well:
https://stackoverflow.com/questions/56554692/unable-to-put-transparent-png-over-a-normal-image-JUMP_LINK__&&__python__&&__JUMP_LINK-tkinter/56555164
+ 3
Aleksei Radchenkov thanks.
I tried that method, though I have label and text box in the middle of screen. If I use canvas it would not show image itself.
+ 3
Thanks 👍, Yes it is Aleksei Radchenkov
+ 3
My project is incomplete so colors are not used much AKSHAY🇮🇳
+ 2
element.attribute('-alpha', 0.7)
+ 2
Charan Leo25 ,
It's Same As Opacity In CSS!
Opacity Is Transparency Effect...
Opacity Is Always From 0-1
Also, Please Upvote(+1) If This Helped You...
+ 1
Charan Leo25 , oh ok. But I don't think there is any other way to do that on tkinter. Then maybe use some other library that supports transparent images like wxpython...
+ 1
Aleksei Radchenkov you know I have wrote 1000 line of code with single class program.
I can't change it through other library in limited time. So I have to scrap the features.
+ 1
Charan Leo25 , sad....
+ 1
AKSHAY🇮🇳 yeah true that.
but in my case, I still didn't figure it out which color to use for background so it's a pending task Till the end.
+ 1
Charan Leo25
I have only single color. So I used color picker.
BTW what type of background you have?
+ 1
Okay
+ 1
Can you explain? Sancho Godinho
+ 1
Sancho Godinho not theory part.
can you explain via code?
+ 1
# Charan Leo25 See This Python3 Code:
from tkinter import *
root=Tk()
root.attributes('-alpha', 0.7)
root.mainloop()
+ 1
Sancho Godinho I want the image to be transparent not the window.
+ 1
Charan Leo25 ,
Then, Replace The Root Variable With Your Image Variable...
If You Still Didn't Understand, Just Reply Me The Image Variable...