listboxes are straightforward to usebut they are populated and processed in somewhat unique ways compared to the widgets we've seen so far many listbox calls accept passed-in index to refer to an entry in the list indexes start at integer and grow higherbut tkinter also accepts special name strings in place of integer offsetsend to refer to the end of the listactive to denote the line selectedand more this generally yields more than one way to code listbox calls for instancethis script adds items to the listbox in this window by calling its insert methodwith successive offsets (starting at zero--something the enumerate built-in could automate for us)list insert(poslabelpos + but you can also fill list by simply adding items at the end without keeping position counter at allwith either of these statementslist insert('end'labellist insert(endlabeladd at endno need to count positions end is preset to 'endinside tkinter the listbox widget doesn' have anything like the command option we use to register callback handlers for button pressesso you either need to fetch listbox selections while processing other widgetsevents ( button press elsewhere in the guior tap into other event protocols to process user selections to fetch selected valuethis script binds the left mouse button double-click event to callback handler method with bind (seen earlier on this tourin the double-click handlerthis script grabs the selected item out of the listbox with this pair of listbox method callsindex self listbox curselection(label self listbox get(indexget selection index fetch text by its index heretooyou can code this differently either of the following lines has the same effectthey get the contents of the line at index 'active'--the one selectedlabel self listbox get('active'label self listbox get(activefetch from active index active='activein tkinter for illustration purposesthe class' default runcommand method prints the value selected each time you double-click an entry in the list--as fetched by this scriptit comes back as string reflecting the text in the selected entryc:\pp \gui\tourpython scrolledlist py you selectedlumberjack- you selectedlumberjack- you selectedlumberjack- you selectedlumberjack- listboxes can also be useful input devices even without attached scroll barsthey accept colorfontand relief configuration options they also support both single and multiple tkinter tourpart