'How To Set The Window Icon PySDL2
I want to set the window icon in PySDL2. I tried doing this
self.icon = sdl2.ext.load_image("./assets/icon.png")
sdl2.SDL_SetWindowIcon(self.window, self.icon)
But since I'm using sdl2.ext.Window
it doesn't work.
Any ideas on how I can go about doing this?
Solution 1:[1]
There might be a limit to the quality of the image you place as an Icon.
window being sdl2.ext.Window
image = sdl2.ext.image.load_img(path_to_image)
sdl2.SDL_SetWindowIcon(
window.window,
image,
)
This code was taken from rubato a pysdl2 wrapper Game Engine for python. Check it out here: https://rubato.app/.
Edit due to comments:
For your code it would look something like this:
self.icon = sdl2.ext.load_image("./assets/icon.png")
sdl2.SDL_SetWindowIcon(self.window.window, self.icon)
You only needed the actual object, stored at self.window.window. self.window is a pointer?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |