Saturday, 5 December 2020

Tkinter Python transparent background with (not transparent ) visible shape?

I would like to create a non-visible, transparent background with visible shapes inside that window. I wrote the following code, however as you can see the objects are also transparent, How can I solve this?

#!/usr/bin/env python3

from tkinter import *

window = Tk()
window.wait_visibility(window)
window.wm_attributes('-alpha',0.1)


def drag(event):
    event.widget.place(x=event.x_root, y=event.y_root,anchor=CENTER)

card = Canvas(window, width=74, height=97, bg='blue')
card.place(x=300, y=600,anchor=CENTER)
card.bind("<B1-Motion>", drag)

another_card = Canvas(window, width=74, height=97, bg='red')
another_card.place(x=600, y=600,anchor=CENTER)
another_card.bind("<B1-Motion>", drag)

window.mainloop()

In other words I don't want my objects to be transparent. I only want screen to be transparent. In future I might add pictures rectangles etc to the window. But I want all of them to visible with a transparent background. Any Help?

My OS: Ubuntu



from Tkinter Python transparent background with (not transparent ) visible shape?

No comments:

Post a Comment