【发布时间】:2019-03-18 03:36:31
【问题描述】:
我正在尝试从 pygame 转换为 tkinter,因为它似乎更适合我想做的事情,尽管我遇到了一些障碍。当同时按下某个键和鼠标按钮时,我需要能够调用一个函数。在 pygame 中它就像下面这样简单。
while not done:
for event in pygame.event.get():
keys = pygame.key.get_pressed()
mouse = pygame.mouse.get_pressed()
if event.type == pygame.QUIT:
done = True
if mouse[0]:
if keys[pygame.K_s]:
pos = pygame.mouse.get_pos()
// function
我知道在 tkinter 中您可以使用 c.bind("<Button-1>", function) 注册鼠标点击和 c.bind("e", function) 注册按键,但我不确定如何同时获取两者,因为按钮事件不会通过按键
【问题讨论】: