'Hiding pygame display
Is there any way to hide the screen of 'pygame.display' and to make it visible afterwards without calling 'pygame.display.quit()'?
Solution 1:[1]
import os
os.environ["SDL_VIDEODRIVER"] = "dummy"
would be enough. See:
http://www.pygame.org/wiki/HeadlessNoWindowsNeeded
https://github.com/ntasfi/PyGame-Learning-Environment/issues/26#issuecomment-330440199
Solution 2:[2]
If you dont need to actually make the screen invisible how about:
I use this:
screen = pygame.display.set_mode((1280,1024), pygame.FULLSCREEN)
#Run my game
screen = pygame.display.set_mode((200,200))
pygame.display.flip()
call('I CALL AN EXTERNAL PROGRAM HERE')
screen = pygame.display.set_mode((1280,1024), pygame.FULLSCREEN)
pygame.display.flip()
to exit from fullscreen so that my second app can be seen. Its handy because it will wait for the second app to close before returning to fullscreen.
Solution 3:[3]
You can use pygame.SHOWN and pygame.HIDDEN in set_mode
Hiding the display:
screen = pygame.display.set_mode((800, 600), flags=pygame.HIDDEN)
Showing the display:
screen = pygame.display.set_mode((800, 600), flags=pygame.SHOWN)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chris Jeong |
| Solution 2 | Ben |
| Solution 3 | OmarShadowSpike |
