binding - How to bind an action to the heading of a tkinter treeview in python? -
i using tkinter treeview
widget show database. command when clicking on 1 of headings used sorting table based on clicked column.
additionally want tooltip box show hover (or right click) on 1 of headings. tooltips aren't problem other widgets heading of treeview isn't full widget of course.
how can bind action headings except usual command?
you can bind events treeview widget itself. widget has method named identify can used determine part of treeview event occurred over.
for example:
... self.tree = ttk.treeview(...) self.tree.bind("<double-1>", self.on_double_click) ... def on_double_click(self, event): region = self.tree.identify("region", event.x, event.y) if region == "heading": ...
Comments
Post a Comment