[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Resizing the window



Chris,

...

if event.type == VIDEORESIZE:
   width, height = event.size
...


I want to know how to get the new screen dimensions after a user resizes the window. I'll need those numbers to properly redraw the screen. Couldn't find the answer with google so please take a look at this basic script. The commented out parts are pseudo code of what I want to accomplish.

#!/usr/bin/env python
import pygame
from pygame.locals import *

pygame.init ()
pygame.display.init()
screen = pygame.display.set_mode ([140, 50], pygame.RESIZABLE)
MAXFPS = 2
clock = pygame.time.Clock()

running = True

while True:
    clock.tick(MAXFPS)
    for event in pygame.event.get ():
        if event.type == VIDEORESIZE:
            #width = pygame.display.height ()
            #height = pygame.display.width ()
#screen = pygame.display.set_mode ([width, height], pygame.RESIZABLE)
            pass
        if event.type == QUIT:
            running = False

pygame.quit ()