Reputation: 4490
Is there any way to hide the screen of 'pygame.display' and to make it visible afterwards without calling 'pygame.display.quit()'?
Upvotes: 8
Views: 11101
Reputation: 372
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)
Upvotes: 7
Reputation: 373
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
Upvotes: 8
Reputation: 21
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.
Upvotes: 2
Reputation: 117681
No there isn't. All you can do is minimize the window using pygame.display.iconify()
.
Upvotes: 6