[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] resizable
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] resizable
- From: Rene Dudfield <renesd@xxxxxxxxx>
- Date: Mon, 14 Feb 2005 20:12:36 +1100
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Mon, 14 Feb 2005 04:13:21 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws;        s=beta; d=gmail.com;        h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references;        b=QLGGhHUR+OmCIkFWdUr8AsHmq4QF0CgBWlDgVWhvWrdo1Q4kVN4EsNp88Wj3PcJQqFOjpXq0o59sA7+oioLNe4Rdl5YNodesNDANtwKaAAfYveE6yE1LTnKMNHaNpek39SIaDaxkVvIdURYWaKKzvd8r0OubLmG8R5BmCT+jMWs=
- In-reply-to: <4210450D.7050308@seznam.cz>
- References: <420BB761.20710.2903B2D@localhost> <4210450D.7050308@seznam.cz>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hey.
Below is how it is done.  The resize event has a size attribute.
Print the events to see what attributes they have.  The size event is
also listed in the event documentation.
I have added w, h attributes to match the sdl resize event.  In case
people are googling for how to find the size of a window.
Not sure how to do it without looking at the resize event though...
Have fun!
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?
            print udalost
            velikost = udalost.size
            screen=pygame.display.set_mode(velikost, RESIZABLE)
       
pygame.quit()
On Mon, 14 Feb 2005 07:28:29 +0100, gen2n <gen2n@xxxxxxxxx> wrote:
>  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