7

Is there any way to hide the screen of 'pygame.display' and to make it visible afterwards without calling 'pygame.display.quit()'?

Serban Razvan
  • 4,250
  • 3
  • 21
  • 22

4 Answers4

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