Python Forum
[PyGame] How to get the size of resizable window? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: [PyGame] How to get the size of resizable window? (/thread-32606.html)



How to get the size of resizable window? - michael1789 - Feb-21-2021

I want to center things in a resizable window.

.get_rect() and pygame.display.get_surface().get_size() both always return the size of a maximized window. What else might work?

Thanks


RE: How to get the size of resizable window? - BashBedlam - Feb-21-2021

This is what works on my system :

import pygame
pygame.init ()
screen = pygame.display.set_mode ((200, 200), pygame.RESIZABLE, 32)

while True :
	for event in pygame.event.get () :
		if event.type == pygame.VIDEORESIZE :
			print (event.size)
		if event.type == pygame.QUIT :
			quit ()



RE: How to get the size of resizable window? - michael1789 - Feb-21-2021

Works like a dream! Many Thanks.