r/learnpython • u/ForenHays • 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
1
u/ConsiderationNo9044 7h ago
Can't you just replace the icons with whatever image you want?
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:
QWidgetwithQt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHintand setsetAttribute(Qt.WidgetAttribute.WA_TranslucentBackground). Then just render your PNGs inside aQLabeland move the window coordinates with aQTimer.root.overrideredirect(True)(removes borders),root.wm_attributes("-topmost", True), androot.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!