【发布时间】:2021-04-17 09:14:15
【问题描述】:
我需要让一个 pygame 窗口保持在其他窗口之上。我在这个讨论中找到了这样做的方法:
How to make python window run as "Always On Top"?
但这在我的 python 代码中不起作用。
这是我的代码:
# 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
【问题讨论】:
标签: python python-3.x windows pygame always-on-top