如何更改pygame图标? [英] How do I change the pygame icon?
问题描述
有人知道如何更改pygame图标吗? 我在pygame网站上发现了一个可以让您执行此操作的东西,但是当我尝试使用它时,它只会使pygame窗口很小.
Does anyone know how to change the pygame icon? I found a thing on the pygame website that lets you do this, but when I try it, it just makes the pygame window very small.
推荐答案
首先将图标图像加载为表面,然后使用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
这篇关于如何更改pygame图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!