r/learnpython • • 7h ago

Can you render sprites on your desktop?

What I mean is not rendering pngs in a window, but on your desktop with the app shortcuts (Not literally changing the shortcut icons).

0 Upvotes

3 comments sorted by

1

u/ConsiderationNo9044 7h ago

Can't you just replace the icons with whatever image you want?

1

u/ForenHays 7h ago

I can, but that's too boring. I'm asking for pngs to move on the desktop outside da window.

1

u/kverke 4h ago

Yes, that's actually how "desktop pets" work! Under the hood, you still use a window, you just make it frameless, transparent, and always-on-top so only your PNG sprite is visible moving across the screen.

The easiest ways to do this in Python:

  1. PyQt6 / PySide6: Create a QWidget with Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint and set setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground). Then just render your PNGs inside a QLabel and move the window coordinates with a QTimer.
  2. Tkinter (built-in): Set root.overrideredirect(True) (removes borders), root.wm_attributes("-topmost", True), and root.wm_attributes("-transparentcolor", "white") (on Windows) to key out the background color.

Once you move the window's (x, y) position in a loop, it looks like the sprite is walking right over your desktop shortcuts!