设置窗口的无边框模式。
pygame.display.set_mode((width, height), pygame.NOFRAME) # (width, height) 窗口大小
无边框窗口实例:
实例代码:
import pygame
pygame.init()
display = pygame.display.set_mode((800, 600), pygame.NOFRAME)
Run = True
def font(text, position, color=(255, 255, 255)):
Font = pygame.font.Font("fonts\\Deng.ttf", 30).render(text, True, color)
FontRect = Font.get_rect()
FontRect.center = position
display.blit(Font, FontRect)
return FontRect
if __name__ == '__main__':
while Run:
font("无边框窗体实例", [400, 300])
exit = font("退出", [550, 50], (255, 0, 0))
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
if exit.collidepoint(pygame.mouse.get_pos()):
Run = not Run
pygame.display.update()