[Tkinter-discuss] Transparent backgrounds in widgets?

Michael Lange klappnase at web.de
Wed Dec 22 11:44:40 CET 2010


Thus spoketh Wayne Werner <waynejwerner at gmail.com> 
unto us on Tue, 21 Dec 2010 15:04:49 -0600:

> Hi,
> Is it possible to create say, a checkbutton widget with a transparent
> background? I'm trying to take an image and put some checkbuttons on it
> so I can mark certain locations (like on a map). I'll be using the
> canvas widget and placing the checkbuttons on the canvas, but when I do
> they have the horrid background. I can change the color of the
> background, but I would much prefer having a transparent one.
> Is this possible to do with the standard widgets or do I have to roll my
> own?

I don't think there is support for background transparency in Tk.
The best bet is probably to try something like this:

from Tkinter import *
root = Tk()
img_off = PhotoImage(
img_on = PhotoImage(
c = Checkbutton(root, indicatoron=False, image=img_off,
selectimage=img_on, bd=0, selectcolor='', width=12, height=12)
c.pack(padx=100, pady=100)

If you need text next to the checkbutton, you can create a canvas text
element, instead of using the checkbutton's text option.



.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

You'll learn something about men and women -- the way they're supposed
to be.  Caring for each other, being happy with each other, being good
to each other.  That's what we call love.  You'll like that a lot.
		-- Kirk, "The Apple", stardate 3715.6

More information about the Tkinter-discuss mailing list