Reputation:
I'm learning to program, and figured out how to use the NOFRAME flag in pygame.display.set_mode()
which I really like, but I can't drag the window now. I can't find any mention of window position in Pygame documentation or on this site.
I just checked my version of Pygame, it's 1.9.1 but my documentation is for 1.9.2 (strange, since I got them at the same time). Not sure if this matters, trying to be thorough. Thanks in advance.
Upvotes: 1
Views: 2273
Reputation: 142641
pygame
(which use SDL 1.2
) doesn't have method to move window.
It has variable which you can use to set position before you use set_mode()
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = '50, 500'
but if you what change position then you have to use set it again and use set_mode()
again.
import os
import pygame
import time
pygame.init()
print('pos: 50, 500')
os.environ['SDL_VIDEO_WINDOW_POS'] = '50, 500'
screen = pygame.display.set_mode((300,300), 32, pygame.NOFRAME)
time.sleep(2)
print('pos: 500, 50')
os.environ['SDL_VIDEO_WINDOW_POS'] = '500, 50'
screen = pygame.display.set_mode((300,300), 32, pygame.NOFRAME)
time.sleep(2)
pygame.quit()
BTW:
PySDL
uses SDL 2.0
which has SetWindowPosition
pyglet
has pyglet.window.Window.set_location
Upvotes: 1