tkinter listbox get(ACTIVE) method

前端 未结 5 1096
耶瑟儿~
耶瑟儿~ 2020-12-15 05:19

I was trying to make the currently selected Listbox item to be printed out. For example, when I select item "one", it should print out "one"

5条回答
  •  Happy的楠姐
    2020-12-15 05:56

    as stated by user1576772 the correct answer should be :

    mylistbox.get(ANCHOR)
    

    The Problem with curselection() is it returns the whole list currently selected each time.

    consider a situation where you scroll through a Listbox and want always to get the last selected item forward or backward (not the last item in highlighted list , the last item pressed on by user )! curselection() will give you all the currently selected items which is helpful but you will never know which item was selected last !

提交回复
热议问题