开发者

how to disable the window close button in pygame?

In a pygame application window, the minimize, resize and close buttons are present. Is there a wa开发者_如何学Pythony to disable the close(X) button?


I don't think there is, because some window managers don't give you the ability to remove the close button. But you can write an event handler such that the close button does whatever you want, including nothing.

Why do you want to prevent the user from closing? If it's just a matter that you would rather provide an in-game "quit" button that confirms and/or saves before quitting, you can perform the same task when the user hits the close button.


Just for the record, another option would be to pass the following argument to the set_mode() method call:

pygame.display.set_mode(..., flags = pygame.NOFRAME)

This however makes the whole frame go away, including the top strip to move the window around and the other buttons, such as minimize, so it's rather overkill for just getting rid of the X button.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜