I am creating a visualization in PYGAME, but the window appears on some random position of my monitor and sometimes some part of the window is obstructed by my taskbar.
Above is a screenshot of where the window appeared. As you can see the bottom of the window is obstructed by my taskbar.
How can I have the pygame window appear on the top left of my monitor? I checked the pygame documentation, but couldn't find any answers.
Below is how I have set up my pygame window.
# pygame config
pygame.init()
WIN_WIDTH = 700
WIN_HEIGHT = 700
window = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
pygame.display.set_caption("A* Pathfinding Algorithm")
window.fill(colors['white'])
pygame.display.flip()
You can set the position of the pygame window by:
import os
os.environ['SDL_VIDEO_WINDOW_POS'] = "%d, %d" %(100, 100)
You have to set the position before initializing the window by pygame.display.set_mode