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
pg.init()
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
break
For
ctypes.windllto work, you have to first configure the types of the function's arguments (IIRC you don't have to this if you're on a 32-bit machine).So your code should look like this:
I prefer to use the pywin32 package instead, because the functions just work and the constants you need are available.