0

How do you set a buttons background colour to transparent, using tkinter on Ubuntu?

Or windows, I am able to set the -transparentcolor attribute, but on Ubuntu it fails.

        try:
            self.wm_attributes("-transparentcolor", "grey")
            self.wm_attributes("-topmost", 'true')
        except Exception as e:
            logger.error(e)

And then later when I defined my button, I set the background colour to be grey. When it renders, the buttons image is well defined and the entire background is transparent.

This works on Windows and the background of the button is transparent, but on Ubuntu it gives the error:

bad attribute "-transparentcolor": must be -alpha, -topmost, -fullscreen, or -type

And then i try and use alpha like other answers have suggested, it does not change the button at all.

How would I set the buttons background image to be transparent?

DjangoBlockchain
  • 534
  • 2
  • 17
  • I don't think you can, "-transparentcolor" is not supported in Linux. You can make your whole window partially transparent with '-alpha' but for me it only works if I add `self.attributes('-type', 'normal')` (you can change 'normal' to the kind of window you want, e.g. splash, dock, ... ([full list here](https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm#M19)) – j_4321 Aug 07 '20 at 16:33
  • Is there any way to make only the background completely transparent? I want to show an image on the button still :/ – DjangoBlockchain Aug 07 '20 at 18:52
  • No; not in Linux – j_4321 Aug 07 '20 at 19:06

0 Answers0