Python Forum
Bouncing Ball - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Bouncing Ball (/thread-36263.html)



Bouncing Ball - Fell - Feb-03-2022

Hi,

New(ish) Python user here. I'm trying to create a (Windows) program that places a sprite (a small bouncing ball) directly on the screen, on top of any other display windows. It needs to not receive user input/keyclicks/mouse message/etc. Is there a way to do without creating it as a transparent, non-rectangular window? If I need to take the windowed route, are there any particular UI libraries that might be best for it? Thanks for any help.


RE: Bouncing Ball - BashBedlam - Feb-03-2022

Apparently.attributes('-alpha', 0.0)works on some systems but not all. It didn't work on mine but I though you might want to give it a try. This will stay on screen until you press enter.
from tkinter import Tk, Label, Canvas

box = Tk ()
box.geometry ('50x50+700+400')
box.attributes('-alpha', 0.0)
box.overrideredirect (1)
canvas = Canvas (box)
canvas.pack ()
canvas.create_oval (1, 1, 48, 48, fill = 'red')

input ()
box.destroy ()
box.mainloop()