Btc Sources
Btc Sources

Reputation: 2041

How to disable multiselection on Treeview in tkinter

I've a Treeview widget, and I need only one row/item to be selected at a time. I've been reading the doc, but I can't find any property or method to do so, nor I've found something useful on SO.

Is it posible? How to?

Upvotes: 9

Views: 4361

Answers (1)

fhdrsdg
fhdrsdg

Reputation: 10532

The answer is a bit higher up the page:

selectmode

Controls how the built-in class bindings manage the selection. One of “extended”, “browse” or “none”. If set to “extended” (the default), multiple items may be selected. If “browse”, only a single item will be selected at a time. If “none”, the selection will not be changed.

Note that the application code and tag bindings can set the selection however they wish, regardless of the value of this option.

Setting selectmode="browse" should give the behavior you're asking for.

Upvotes: 16

Related Questions