Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 如何在pygame gui中向按钮添加背景图像?_User Interface_Button_Background_Pygame - Fatal编程技术网

User interface 如何在pygame gui中向按钮添加背景图像?

User interface 如何在pygame gui中向按钮添加背景图像?,user-interface,button,background,pygame,User Interface,Button,Background,Pygame,我试图在pygame gui中添加一个图像作为按钮的背景。我现在已经创建了按钮,我只需要添加图像。如何将图像添加到按钮 这是我的密码 game1 = pygame.Rect(150 , 100, 200, 150) # creates a rect object pygame.draw.rect(screen, [255, 100, 0], game1) # draw objects down here 它工作正常您可能正在寻找pygame.Surface.blit() 加载你的背

我试图在pygame gui中添加一个图像作为按钮的背景。我现在已经创建了按钮,我只需要添加图像。如何将图像添加到按钮

这是我的密码

   game1 = pygame.Rect(150 , 100, 200, 150) # creates a rect object
   pygame.draw.rect(screen, [255, 100, 0], game1) # draw objects down here

它工作正常

您可能正在寻找
pygame.Surface.blit
()

加载你的背景图像,并在任何你想要的地方进行blit

img = pygame.image.load('thisisanimage.png')
WhateverYourDisplayNameIs.blit(img,(x,y))

为了防止您感到困惑,您似乎正在使用
屏幕
作为显示界面。

您能帮我一个忙并给我看一个代码示例吗?@larry别忘了给您的按钮图像命名
按钮\u img
非常感谢,这帮了大忙