I don't know why it shows the wrong coordinates, but it seems to happen only if there's another window (in this case the IDLE window) in front of the pygame window. If the pygame window is selected/focussed and you set the mouse pos, pygame.mouse.get_pos()
will return the correct coordinates. Try to set the mouse pos in an event loop (press the s key):
import pygame
pygame.init()
size = (800, 500)
screen = pygame.display.set_mode(size)
pygame.mouse.set_pos([100,100])
WHITE = (255,255,255)
clock = pygame.time.Clock()
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_s:
pygame.mouse.set_pos([100,100])
print(pygame.mouse.get_pos())
screen.fill(WHITE)
pygame.display.flip()
clock.tick(30)
pygame.quit()
Or run the program in the command-line/terminal.