[Tkinter-discuss] Listbox selection issue

Batista, Facundo FBatista at uniFON.com.ar
Thu Apr 15 13:14:20 EDT 2004


Hi,

I set up a ListBox. When it appears, it gets the first item selected. With
selected I mean that its line is colored.

I want the user to have to double click to change the selection. So I binded
double-click to a function. That's ok.

But I want that if the user just click in other item, that item don't get
selected/colored. 

I implemented something this:

        self.listbox.bind("<Button-1>", self.noIr)
        self.listbox.select_set(0)
        ...

    def noIr(self, evento):
        print self.listbox.curselection()
        sel = self.listbox.curselection()
        sel = int(sel[0])
        self.listbox.select_set(sel)
        print self.listbox.curselection()
        return


The prints are for debug only. With the second one, I see that the selection
didn't change. but another item is colored!!

I think I'm have a terminology problem, please explain it to me if I'm
wrong.

Thank you!

.	Facundo



More information about the Tkinter-discuss mailing list