python - Pygame Logo 没有改变

标签 python pygame icons

所以我尝试更改 pygame 的图标,但它没有改变,只显示默认的蛇。我用另一个 Logo 尝试过,它有效,但我不明白为什么那个有效,而我想要的却无效。有人可以帮忙吗?

代码:

gameIcon = pygame.image.load('path\\icon.png')

pygame.display.set_icon(gameIcon)

谢谢!

顺便说一句,图像尺寸为 200x200,有效的尺寸为 512x512

最佳答案

参见pygame.display.set_icon() :

[...] Some systems do not allow the window icon to change after it has been shown. This function can be called before pygame.display.set_mode() to create the icon before the display mode is set.

设置pygame.display.set_mode()之前的图标:

gameIcon = pygame.image.load('path\\icon.png')
pygame.display.set_icon(gameIcon)

screen = pygame.display.set_mode((width, height))

关于python - Pygame Logo 没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66576606/

相关文章:

android - TabLayout 图标不显示

python - 使用 SWIG 生成 Python 类型提示

Python 字典未正确更新

Python 在使用 pgu 和 pygame 导入时抛出异常

python - 打开我的 Pygame 程序的 EXE 时出现导入错误

Python 游戏库

android - Android 中不显示应用程序图标

intellij-idea - 文件图标中的问号在 Intellij 中意味着什么?

python - 在类级容器初始化中调用静态方法

python - VSCode WxPython包intellisense "Module ' wx'没有 'Frame'成员”