我正在尝试在 pygame 中编写一个程序,如果在某个区域按下鼠标,它将打印一些内容。我尝试过使用 mouse.get_pos 和 mouse.get_pressed 但我不确定我是否正确使用它们。这是我的代码
while True:
DISPLAYSURF.fill(BLACK)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
mpos = pygame.mouse.get_pos()
mpress = pygame.mouse.get_pressed()
if mpos[0] >= 400 and mpos[1] <= 600 and mpress == True:
print "Switching Tab"
Run Code Online (Sandbox Code Playgroud)