【发布时间】:2020-11-10 04:10:08
【问题描述】:
我想完全阻止用户关闭除键 x 之外的 Pygame 窗口。目前,我能够阻止用户关闭它,但我无法阻止用户打开另一个与其重叠的窗口(按 windows 键 -> 打开与 Pygame 窗口重叠的 chrome)。
import sys
import pygame
from pygame.locals import *
pygame.init()
infoObject = pygame.display.Info()
screen = pygame.display.set_mode((infoObject.current_w, infoObject.current_h), flags=pygame.NOFRAME)
while True:
screen.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_x:
pygame.quit()
sys.exit()
if event.type == QUIT:
pass
pygame.display.flip()
【问题讨论】:
-
我认为没有办法做到这一点,因为您可以使用 Overlay2 等软件绕过任何窗口覆盖,甚至只是第二个监视器。此外,某些防病毒软件(例如 AVG)有时会将不允许关闭的软件视为病毒。