Is it possible to remove background on tkinter image - python

Here is my code.
png image without background
Here is a result. Is it even possible to remove image background in tkinter or I have to make same color as on image?

Looks like you have the basic grey background to you're added picture by tkinter.
So try if it is possible to change you're backround from grey to for example red with:
tag: bg="red", if that is possible, you can just change the color to the blue background.
Label(root,image=self.img, bg="blue")
I tested it and it worked out for me.
Its not possible as far as i know to use rgb() or the hexadezimal with the transperancy option.
Gave me back errors.
Its not really transperent but kind of a solution !
Good Luck !

Related

How to import video in Python tranparency without use set_colorkey

My problem seems a bit special and none of my friends have an answer for me.
Indeed, I have animations made on after effect with a transparent background that I recorded in .mov and I tried to put it on python.
However, the transparent background automatically becomes black when i launch my program even if the background is transparent in the video. Also, I can't use the set_colorkey command because my animations have lights that change the outline color (so I can't figure out which colors to remove).
Would you have any solutions for me to directly import my video with its transparent background please?
Thanks in advance !

Window not fully filled with specific background color - tkinter

Recently i've been trying to make a simple GUI with tkinter in python
but for some reason the background color doesn't fully fill the window with the specific color
eg:
How do i fill all the sides?
Any replies are greatly appreciated ;-)
First of all, you need to also attach a minimal reproducible example. Nevertheless, I think you have put a canvas with the colour you want and expanded it to 1.
Canvases in Tkinter always have a border like thing. Rather you can use a frame with the same colour (instead of the canvas) and the border will disappear. The other option is to configure your root to have its own colour like such:
root.config(bg='red')
Either way, you will have to then delete your canvas and place its widgets into either the frame or the root itself.
If this works, please accept this answer. Hope it was helpful. Thank you!

Make a background transparent in Tkinter

while developing my app I finally succeeded in making everything I want to, the latest being attaching a background image to the app window. My only issue now is with the background of the labels, they are covering the background making the app ugly.
I tried using:
window.wm_attributes('-transparentcolor',color)
but something weird happened, the whole thing became transparent and It's not my desired outcome as you can see :
Picture here
anyone knows how to get around this or how to fix it?
been looking everywhere but can't really find a solution to my issue
I had tried this but I think you had already done this before,
from tkinter import *
from PIL import Image,ImageTk
main=Tk()
photo=Image.open("Eujbx.png")
photo = ImageTk.PhotoImage(photo)
aa=Label(main,image=photo)
aa.pack(expand=True,fill=BOTH)
title=Label(aa,text="This app is to look for homework",bg='#9e87b9')
title.pack(pady=10)
new=Entry(aa,bg="#9e87b9")
new.pack()
Button(aa,bg="#9e87b9",text="Hlw").pack()
main.mainloop()
If you had not tried this yet then try it. It could help you.
Steps(Explanation):
Using PIL to get the image,
Then change image to ImageTk which we can use,
Make Label which store the image and show in the background,
pack that with expandable form and fill Both side(X and Y),
Create the label and other stuff,
put all of them inside the main Label which contain background image,
give them background color of color of background image.

tkinter making background image as semi-transparent under all widgets

First image:
Second image:
The first image shows what I'm getting at this moment.
But I just want to make it as the 2nd image which is looking transparent for all widgets. Apparently tkinter widgets does not support transparency. How can I make my GUI like second image?
Any help would be appreciated.
I know question is asked long ago, but I(and probably still many beginners like myself) was bothered with same thing and I came up with some kind of solution.
I've just cut part of background of exact place where button is placed with exact measurements and I achieved something similar to transparency by placing that cropped image as background of a button, label....
Not a "coded" solution but worked for me.

wxPython TextCtrl Transparent Background

How can I make a TextCtrl have a transparent background? By this I mean see the desktop behind it.
Current Code:
self.control.SetBackgroundColour(wx.Color(0,0,0,0))
But that just makes the background colour black.
I am using Python 2.7 on Windows 7
To my knowledge textCtrt can't be transparent or use a background image, but you can change the background color.
TIP:
You can use the exact color as your background image by finding out the exact HEX color value.
Example code:
self.SetBackgroundColour('#232321')

Categories