tkinter, Selecting multiple using arrows+shift (or ctrl)

3 weeks ago 30
ARTICLE AD BOX

I'm trying to be able to select multiple entries in a tkinter GUI, the same way you can in fileExplorer.

I can select multiple using shift+click, and ctrl+click, but either+arrows don't work.

I did use selectmode="extended"

I mimicked the code found in Select multiple entries in Tkinter treeview without pressing ctrl key and got the same issue;

# Source - https://stackoverflow.com/q/58446788 # Posted by Nirupam Kapoor # Retrieved 2026-01-01, License - CC BY-SA 4.0 import ttk import Tkinter as tk def select(): for i in tree.selection(): item_iid = i print "".join([str(tree.item(i)['text'])])# for i in curItems]) root = tk.Tk() tree = ttk.Treeview(root,show="tree")#, selectmode=EXTENDED) tree.config(columns=("col1")) #SUb treeview style = ttk.Style(root) style.configure("Treeview") tree.configure(style="Treeview") tree.insert("", "0", "item1", text="Branch1",) tree.insert("", "1", "item2", text="Branch2") #sub tree using item attribute to achieve that tree.insert("item1", "1", text="FRED") tree.insert("item1", "1", text="MAVIS") tree.insert("item1", "1", text="BRIGHT") tree.insert("item2", "2", text="SOME") tree.insert("item2", "2", text="NODES") tree.insert("item2", "2", text="HERE") tree.pack(fill=tk.BOTH, expand=True) tree.bind("<Return>", lambda e: select()) root.mainloop()

I'm struggling to figure out why its breaking.

(I am currently assuming its not something in my code breaking functionality, because this sample wouldn't multi-select with arrow keys either. I'm assuming I needed to add something that I didn't, and I can't figure out what that might be.)

Read Entire Article