所以我尝试了这个,它最终会运行我的听众然后当我的听众完成我的tkinter主循环将运行。 parent是我的tkinter.Tk对象,鼠标和键都是pynput对象
with key.Listener(on_press=self.OnKeyPress) as lis:
with mouse.Listener(on_click=self.on_click) as self.listener:
with parent.mainloop() as self.p:
self.p.join()