質問

In Python, is there a way to bind every event generated by an object (perhaps a tkinter widget) to a single function, without explicitly naming them? The motivation here is for learning, debugging and development purposes.

(This question has arisen whilst trying to find a solution to this.)

役に立ちましたか?

解決

You can bind to all of the keys like this:

def callback(event):
    print(event.char, event.keysym, event.keycode)

root = Tk()
root.bind('<Key>', callback)
root.mainloop()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top