Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

python - Why does a Pygame display with the pygame.FULLSCREEN flag affect other windows?

I just started learning how to use Pygame earlier this week. While messing around with it I discovered that if I make a fullscreen window and leave it open for about 10 seconds and close it, all the other windows I have open will shrink in size and my screen is at a lower resolution for a few seconds.

These things happen with this chunk of code:

import pygame

pygame.init()
pygame.display.set_mode((500, 500),
                        pygame.FULLSCREEN)

running = True
while running is True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

pygame.quit()

Why would this code change the state of my other windows and change my screen resolution temporarily?

I am working with Pygame 2.0.1 with Python 3.9.1 using PyCharm 2020.3.1 on macOS Big Sur 11.1.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Change

pygame.display.set_mode((500, 500), pygame.FULLSCREEN)

to

pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

Pygame will automatically detect the screen size.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...