How to pin a pygame window on top?

  always-on-top, pygame, python, python-3.x, windows

I need to make a pygame window stay on top of other windows. I found a way to do so on this discussion:

How to make python window run as "Always On Top"?

But this doesn’t work in my python code.

Here is my code:

# Imports
import pygame as pg
from ctypes import windll

SetWindowPos = windll.user32.SetWindowPos

win = pg.display.set_mode((200, 30))

x, y = 100, 100
# Pin Window to the top
SetWindowPos(pygame.display.get_wm_info()['window'], -1, x, y, 0, 0, 0x0001)

#Main Loop
run = True
while run:
    for event in pg.event.get():
        if event.type == pg.QUIT:
            run = False

Source: Windows Questions