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

Re: [pygame] Starting Window Position



Testing shows that on Windows the window position environment variable is read with the call to pygame.display.set_mode() and ignored otherwise.

"""Try to move the pygame window"""

import pygame
from pygame.locals import *
import os

pygame.init()
font = pygame.font.Font(None, 48)
os.environ['SDL_VIDEO_WINDOW_POS'] = '20,100'
screen = pygame.display.set_mode((200, 100))

screen.fill(Color('white'))
screen.blit(font.render(os.environ['SDL_VIDEO_WINDOW_POS'],
                       True,
                       Color('black')),
           (10, 10))
pygame.display.flip()
os.environ['SDL_VIDEO_WINDOW_POS'] = '20,100'
pygame.time.wait(3000)

os.environ['SDL_VIDEO_WINDOW_POS'] = '%d,%d' % (120, 200)
screen.fill(Color('white'))
screen.blit(font.render(os.environ['SDL_VIDEO_WINDOW_POS'],
                       True,
                       Color('black')),
           (10, 10))
pygame.display.flip()
pygame.time.wait(3000)


Ian Mallett wrote:
It still doesn't work though- it works the first time, and subsequent changes to the placement fail.

On 6/28/07, *Lenard Lindstrom* < len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>> wrote:

    I admit it was a silly question. The positioning code works on my
    Windows system. I noticed the position is that of the client area.


    Ian Mallett wrote:
    > Yes...
    >
    > On 6/28/07, *Lenard Lindstrom* <len-l@xxxxxxxxx
    <mailto:len-l@xxxxxxxxx>
    > <mailto:len-l@xxxxxxxxx <mailto:len-l@xxxxxxxxx>>> wrote:
    >
    >     Ian Mallett wrote:
    >     > So I would have the original program start a new one that
    codes the
    >     > alternate window?
    >     >
    >     > The centering code, which is what I tested, works, but
    this doesn't:
    >     > os.environ ['SDL_VIDEO_WINDOW_POS'] = 'value,value'
    >     >
    >     > On 6/28/07, *Brian Fisher* < brian@xxxxxxxxxxxxxxxxxxx
    <mailto:brian@xxxxxxxxxxxxxxxxxxx>
    >     <mailto:brian@xxxxxxxxxxxxxxxxxxx
    <mailto:brian@xxxxxxxxxxxxxxxxxxx>>
    >     > <mailto: brian@xxxxxxxxxxxxxxxxxxx
    <mailto:brian@xxxxxxxxxxxxxxxxxxx>
    >     <mailto:brian@xxxxxxxxxxxxxxxxxxx
    <mailto:brian@xxxxxxxxxxxxxxxxxxx>>>> wrote:
    >     >
    >     >     You can only do that with multiple processes. It's one
    >     window per
    >     >     process for SDL.
    >     >
    >     >     On 6/28/07, Ian Mallett < geometrian@xxxxxxxxx
    <mailto:geometrian@xxxxxxxxx>
    >     <mailto: geometrian@xxxxxxxxx <mailto:geometrian@xxxxxxxxx>>
    >     >     <mailto:geometrian@xxxxxxxxx
    <mailto:geometrian@xxxxxxxxx> <mailto:geometrian@xxxxxxxxx
    <mailto:geometrian@xxxxxxxxx>>>>
    >     wrote:
    >     >     > Awesome!  That works!  Thanks!  Just one more question
    >     >     though...  I want to
    >     >     > have two or more pygame windows running at the same
    time.  Can
    >     >     you do that?
    >     >     > Ian
    >     >     >
    >     >
    >     >
    >
    >     Do you make the os.environ call before calling pygame.init   ?
    >



--
Lenard Lindstrom
<len-l@xxxxxxxxx>