Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of Sequences Available for Each TKinter Widget

Is there a reference site that contains, for each Tkinter widget, a list of all available sequences for binding?

For example, I can bind a callback to a TreeView with this code:

tree.bind("<<TreeviewSelect>>", selection_changed)

However, I can't seem to find a good resource that will list all possible events to which a callback can be assigned.

like image 448
frr171 Avatar asked Oct 24 '25 06:10

frr171


1 Answers

You can use this code to get events for some widget (except virtual events):

from itertools import chain
def get_events(widget):
    return set(chain.from_iterable(widget.bind_class(cls) for cls in widget.bindtags()))

root = Tk()
a = get_events(Button())
print(a)
root.destroy()

>>> {'<KeyRelease-Alt_R>', '<Enter>', '<Key-space>', '<Button-1>', '<Key-Alt_R>', '<KeyRelease-F10>', '<<PrevWindow>>', '<Alt-Key>', '<Alt-KeyRelease>', '<ButtonRelease-1>', '<Leave>', '<KeyRelease-Alt_L>', '<Key-Alt_L>', '<Key-F10>', '<Key-Tab>'}

And links: Master list of all Tkinter Events?

like image 67
kalgasnik Avatar answered Oct 26 '25 19:10

kalgasnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!