from Tkinter import * global listbox # A list of all the items that will be in the listbox itemlist = ["one", "two", "three", "four"] # This is called when the user double-clicks an item def buttonPushedEvent(event): buttonPushed() # This is called when the user clicks the button def buttonPushed(): items = listbox.curselection() items = map(int, items) print items print "The item selected was ", itemlist[items[0]] # Add a listbox to the root window def addListBox(root): global listbox listbox = Listbox(root) # Create the box for item in itemlist: # Add all the items from global itemlist listbox.insert(END, item) listbox.pack() # Pack it listbox.bind("", buttonPushedEvent) # Allow user to doubleclick # Add a button to the window also def addButton(root): myBtn = Button(root, text="Print Selection", command=buttonPushed) myBtn.pack() def main(): root = Tk() addListBox(root) addButton(root) root.mainloop() main()