【发布时间】:2021-05-31 11:58:29
【问题描述】:
我有一个简单的 Pygame 显示:
pygame.init()
screen = pygame.display.set_mode((1024, 576))
clock = pygame.time.Clock()
while True:
for event in pygame.event.get(): # to handle clicks on the screen (prevent crash)
if event.type == pygame.QUIT:
pygame.display.quit()
if event.type == pygame.DROPFILE:
path = event.file
print(path)
pygame.display.update()
我目前正在测试“放置文件”事件,以便在我正在处理的项目中使用它。不幸的是,当我将文件拖到屏幕上时,光标变成“不允许”标志,当我放下文件时没有任何反应。为什么会这样?
【问题讨论】:
-
代码对我有用。你在什么操作系统上? (我在windows10)
-
我也在windows10。很奇怪,它可以在某些计算机上运行,但在其他计算机上却不行......
-
你是什么pygame版本?
-
pygame 版本 1.9.6
标签: python pygame drag-and-drop