+ 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.

28th Sep 2021, 4:25 PM
Charan Leo25
Charan Leo25 - avatar
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)
29th Sep 2021, 6:59 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
28th Sep 2021, 4:28 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 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.
28th Sep 2021, 4:32 PM
Charan Leo25
Charan Leo25 - avatar
+ 3
Thanks 👍, Yes it is Aleksei Radchenkov
28th Sep 2021, 4:40 PM
Charan Leo25
Charan Leo25 - avatar
+ 3
My project is incomplete so colors are not used much AKSHAY🇮🇳
29th Sep 2021, 4:00 PM
Charan Leo25
Charan Leo25 - avatar
+ 2
element.attribute('-alpha', 0.7)
11th Oct 2021, 10:28 AM
Sancho Godinho
Sancho Godinho - avatar
+ 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...
11th Oct 2021, 11:05 AM
Sancho Godinho
Sancho Godinho - avatar
+ 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...
28th Sep 2021, 4:37 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 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.
28th Sep 2021, 4:39 PM
Charan Leo25
Charan Leo25 - avatar
+ 1
Charan Leo25 , sad....
28th Sep 2021, 4:40 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 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.
29th Sep 2021, 9:38 AM
Charan Leo25
Charan Leo25 - avatar
+ 1
Charan Leo25 I have only single color. So I used color picker. BTW what type of background you have?
29th Sep 2021, 10:11 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
Okay
30th Sep 2021, 10:20 AM
akinpelu abiodun
akinpelu abiodun - avatar
+ 1
Can you explain? Sancho Godinho
11th Oct 2021, 11:03 AM
Charan Leo25
Charan Leo25 - avatar
+ 1
Sancho Godinho not theory part. can you explain via code?
11th Oct 2021, 11:07 AM
Charan Leo25
Charan Leo25 - avatar
+ 1
# Charan Leo25 See This Python3 Code: from tkinter import * root=Tk() root.attributes('-alpha', 0.7) root.mainloop()
11th Oct 2021, 11:09 AM
Sancho Godinho
Sancho Godinho - avatar
+ 1
Sancho Godinho I want the image to be transparent not the window.
11th Oct 2021, 11:12 AM
Charan Leo25
Charan Leo25 - avatar
+ 1
Charan Leo25 , Then, Replace The Root Variable With Your Image Variable... If You Still Didn't Understand, Just Reply Me The Image Variable...
11th Oct 2021, 11:20 AM
Sancho Godinho
Sancho Godinho - avatar