selectmode argument supports four settingssinglebrowsemultipleand extended (the default is browseof thesethe first two are single selection modesand the last two allow multiple items to be selected these modes vary in subtle ways for instancebrowse is like singlebut it also allows the selection to be dragged clicking an item in multiple mode toggles its state without affecting other selected items and the extended mode allows for multiple selections and works like the windows file explorer gui--you select one item with simple clickmultiple items with ctrl-click combinationand ranges of items with shift-clicks multiple selections can be programmed with code of this sortlistbox listbox(windowbg='white'font=('courier'fontsz)listbox config(selectmode=extendedlistbox bind(''(lambda eventondoubleclick())ondoubeclickget messages selected in listbox selections listbox curselection(tuple of digit strs - selections [int( )+ for in selectionsconvert to intsmake when multiple selections are enabledthe curselection method returns list of digit strings giving the relative numbers of the items selectedor it returns an empty tuple if none is selected reallythis method always returns tuple of digit stringseven in single selection mode (we don' care in example - because the get method does the right thing for one-item tuplewhen fetching value out of the listboxyou can experiment with the selection alternatives on your own by uncommenting the selectmode setting in example - and changing its value you may get an error on double-clicks in multiple selection modesthoughbecause the get method will be passed tuple of more than one selection index (print it out to see for yourselfwe'll see multiple selections in action in the pymailgui example later in this book ()so 'll pass on further examples here programming scroll bars perhaps the deepest magic in the example - scriptthoughboils down to two lines of codesbar config(command=list yviewlist config(yscrollcommand=sbar setcall list yview when move call sbar set when move the scroll bar and listbox are effectively cross-linked to each other through these configuration optionstheir values simply refer to bound widget methods of the other by linking like thistkinter automatically keeps the two widgets in sync with each other as they move here' how this worksmoving scroll bar invokes the callback handler registered with its command option herelist yview refers to built-in listbox method that adjusts the listbox display proportionallybased on arguments passed to the handler listboxes and scrollbars