Reputation: 65
How do i change the opacity/transparency of a black rectangle in python tkinter.
canvas.create_rectangle (200, 200, 600, 600, fill="black")
Above is what i used to create the box. I looked at attributes i could use but could not find any. I also played with .setOpacity(0.5)
as i saw this being used somewhere else but it did not work.
I have looked at different examples and they either change the opacity for images using the PIL module or change the opacity in different languages which i am unfamiliar with.
Upvotes: 0
Views: 2354
Reputation: 3447
I don't think you can change alpha(Transparency) on a canvas. But you can use stipple
on it to cover it with a bitmap, so you kinda get the same effect but not exact.
Try this line.
canvas.create_rectangle (200, 200, 600, 600, fill="black",stipple='gray50')
Upvotes: 4