In reference to In tkinter GUI what are pending events and idle callbacks? question, which asks what are pending events and idle callbacks in tkinter, I was wondering if there is a way to print the event/idle queue to console or a tracelog.
The only potential solution I could come up with is the code below, but I was wondering if there was an easier way.
import tkinter as tk
root = tk.Tk()
# Some widgets
for foo in range(5):
tk.Button(root, text="Press Me!").pack()
# Bind all widgets to print events
widgets = root.winfo_children()
def event_print(event):
print(event)
events = [
"<Button>",
"<Motion>",
"<ButtonRelease>",
"<Double-Button>",
"<Enter>",
"<Leave>",
"<FocusIn>",
"<FocusOut>",
"<Return>",
"<Key>",
"<Shift-Up>",
"<Configure>",
]
for widget in widgets:
for event in events:
widget.bind(event, event_print)
root.mainloop()