Listbox
Live: the Lists card of the gallery, and the layer list of the vector tool.
listbox
listbox .files -height 6 -selectmode extended -yscrollcommand {.sb set} -emptytext "No files"
scrollbar .sb -command {.files yview}
.files insert end report.pdf notes.txt photo.png budget.xlsx
bind .files <<ListboxSelect>> {puts [.files curselection]}
pack .files -side left -fill both -expand 1
pack .sb -side right -fill y
listbox .side -height 4 -activestyle none
.side insert end Inbox Drafts Sent Archive
ztk::class .side add sidebar


The details of listbox
- The listbox has the options, the subcommands, and the four selection modes of Tk 8.6:
single,browse,multiple, andextended. The pointer and the keys select rows as inwish, and a change by the user sends<<ListboxSelect>>. -listvariablelinks the rows to a list variable in both directions.- When the selection moves from one row to another row, its background eases between the rows in 180 ms.
- A scroll eases, and a touchpad scrolls by pixels with momentum. A whole step of
yview scrolloryview movetoputs a row at the top, as in Tk. - The additions:
-emptytextshows a text in an empty listbox, and the style classsidebargives a list with no field and round accent rows. - The parts
::item,::selection,::active, and::emptyaccept CSS rules.