Sunday, 21 April 2019

Pygame: Resizing a window

Pygame: Resizing a window

We already know how to create a game window using pygame. For creating a window, we use pygame.display. We set window size by setting the display mode in pygame. Now what if we want to make the window full screen? or we want to hide it, or resize it,
There are some meethods in pygame.display module

While setting the display mode, if we provide a third parameter, pygame.FULLSCREEN, we get a full screen window. For UNIX X11 driver there is one more function pygame.display.toggle_fullscreen() which works as switch between fullscreen mode and normal mode.

if you want to hide the window leaving only icon behind to get the access next time to the running window, use pygame.display.iconify() method.

A working example of all these functions, is in the following gist.

You might get confused that above script just gives an empty window that can be resizable but it works just the same as window with contents check out following gist