Search code examples
python-3.xtkintertkinter-canvas

Transparency problemfor widgets in Tkinter


I designed a form having an image as its background using a Canvas, then I want to put other widgets with transparent background over the Canvas. To do that I used root.wm_attributes('-transparentcolor', '#2a1863') and then the widgets having that colour as background color assune a transparent background but I do not see, as I would expect, the canvas background image, instead I see what is on my LCD screen. I modified my code to display a text on the canvas using canvas.create_text(text="Welcome!") just to show what I want to have putting a Label over the Canvas. The problem is not limited only to Label widget. Below there is the image as produced by my code: enter image description here


Solution

  • Use the pywinstyles package pip install pywinstyles

    pywinstyles.set_opacity(widget, color='#2a1863')
    

    Make sure that the bg color of label is set to '#2a1863'