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

Re: [pygame] resizable



Here is the snippet:

import pygame
from pygame.locals import *

velikost = 320, 240
screen =  pygame.display.set_mode(velikost, RESIZABLE)

.....

znovu=1
while znovu:
    for udalost in  pygame.event.get():
        if udalost.type == QUIT:
            znovu=0
        if udalost.type== VIDEORESIZE:
            # velikost=xxxxxxx  # how to get the new size of my window?
            screen=pygame.display.set_mode(velikost, RESIZABLE)
       
        ..........   


pygame.quit()
   

gen2n  
ICQ 176015287
Pavel

BTW: Yeah, Kosice are quite near here in Europe. I was there once, long time ago. Nice city. 


Ben Friman napsal(a):
Pavel,

I would be interested to know how you do that. Perhaps you could show a snippet of 
code.

One thing which doesn't answer your question but might still be helpful, is the method 
for detecting the current display resolution. I spent more hours than you could 
imagine trying to figure out how to do it (under Windows only):

List_Modes can give modes higher than the current resolution! If you try to change 
display mode to a resolution which is too high for the display device, the user doesn't 
get to see a lot! So it's much safer to detect the current display resolution and work 
within that.

import win32api
SM_CXSCREEN = 0  # I didn't find any include file which defines these contstants
SM_CYSCREEN = 1


x = win32api.GetSystemMetrics(SM_CXSCREEN)
y = win32api.GetSystemMetrics(SM_CYSCREEN)

Incidentally, my father was called Pavel and he came from Kosice. I guess that's 
somewhere near to you!

  
I have tried to make my window resizable. It works just a half. I was even able to catch that event 
but no idea how to get a size of a new window, so I can resetÿ atributes of a window with 
pygame.display.set_mode(size).

Thanks a lot
Pavel

-- 
gen2n  
ICQ 176015287