Hi all,

I am currently replacing some Listbox() with ttk.Treeview() however the 
Treeview doesn't have the
"Shift-Up/Down" and "B1-Motion" capabilities to select with the keyboard 
multiple items and with the mouse by click and drag.

Looking the treeview.tcl I've managed to add a binding for the B1-Motion which 
seems to work,
however I failed to find a way to correctly replicate the Listbox behavior with 
the Shift-Up/Down
This is one of my failed tries

Any suggestion?

class MyTreeview(ttk.TreeView):
def __init__(self, master, *kw, **args):
super().__init__(master, *kw, **args)
self.bind("<B1-Motion>", self.b1motion)
self.bind("<Shift-Key-Up>", self.selectUp)
self.bind("<Shift-Key-Down>", self.selectDown)

def b1motion(self, event):
if self.identify_row(event.y) == self.focus(): return
self.tk.call("ttk::treeview::Select", self._w, event.x, event.y, "extend")

def selectDown(self, event):
self.tk.call("ttk::treeview::Keynav", self._w, "down")
item = self.focus()
self.tk.call("ttk::treeview::SelectOp", self._w, item, "extend")
return "break"
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to