lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
527 stars 191 forks source link

Pygame_zero windows open in the middle of the screen #314

Open bjazmoore opened 1 year ago

bjazmoore commented 1 year ago

by changing the first few lines of runner.py these windows can be comfortably opened in the upper right corner of the user's screen:

import pygame
import os
pygame.mixer.pre_init(frequency=22050, size=-16, channels=2)
# Add code before pygame.init() to position window that will be opened.
# This will cause any windows created to be opened at 40, 40
x = 60
y = 80
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y)
pygame.init()

Note that 'import os' must be moved (shifted) up several lines in the code to make this work.