Is there any way to hide the screen of 'pygame.display' and to make it visible afterwards without calling 'pygame.display.quit()'?
Asked
Active
Viewed 9,521 times
7
-
https://stackoverflow.com/questions/51627603/opengl-render-view-without-a-visible-window-in-python – user972014 Aug 10 '18 at 13:49
4 Answers
7
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

Chris Jeong
- 363
- 3
- 10
5
No there isn't. All you can do is minimize the window using pygame.display.iconify()
.

orlp
- 112,504
- 36
- 218
- 315
4
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)

Zenthm
- 104
- 1
- 8
1
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.

Ben
- 11
- 1