Tkinter - what's the Index of selected value in spinbox? Tkinter - what's the Index of selected value in spinbox? tkinter tkinter

Tkinter - what's the Index of selected value in spinbox?


There's no way to directly get the value from the widget, but it's just one line of python code:

index = i_fiendlist.index(self.root.friend.get())

Using your code, you need to save the value of the list:

class TestSpin():    def __init__(self, i_root,i_friendlist):        self._list = i_list        ...    def ack(self):        value = self.root.friend.get()        index = self._list.index(value)        print "Index of " + value + " is " + str(index)        self.root.destroy()