且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改pygame图标?

更新时间:2023-01-05 18:20:01

首先将图标图像加载为表面,然后使用pygame.display.set_icon(surface)更改图标.

First load the icon image as a surface, then use pygame.display.set_icon(surface) to change the icon.

由于提问者不知道什么是表面

Since the asker doesn't know what a surface is

摘自 http://www.pygame.org/docs/ref/surface.html

"pygame Surface用于表示任何图像.该Surface具有固定的分辨率和像素格式.调用pygame.Surface()创建一个新的图像对象."

"A pygame Surface is used to represent any image. The Surface has a fixed resolution and pixel format. Call pygame.Surface() to create a new image object."

例如,如果使用screen = pygame.display.set_mode,则screen是表面.

For example, if you used screen = pygame.display.set_mode, screen is a surface.

因此,当使用pygame.display.set_icon(surface)时,必须首先将图像导入为pygame.使用a = pygame.image.load('image')进行表面处理,其中a是将存储表面的变量,而'image'是该图像的目录.然后,您可以使用pygame.display.set_icon(surface)将a设置为图标.您可以通过任何表面,但***是32x32.

So when using pygame.display.set_icon(surface) you must first import an image as a pygame.Surface by using a = pygame.image.load('image') where a is the variable the surface will be stored and 'image' is the directory to that image. Then you can set a to the icon by using pygame.display.set_icon(surface). You can pass any surface, but it is desirable that it is 32x32.

此处的更多信息: http://www.pygame. org/docs/ref/display.html#pygame.display.set_icon