Tkinter入门
前页 | Chapter 31. The Listbox Widget | 后页

# Options

The `Listbox` widget supports the following options:

Table 31-1. Listbox Options

Option | Type | Description
--- | --- | ---
`background (bg), foreground (fg)` | color | The listbox color. The default is platform specific.
`cursor` | cursor | The cursor to show when the mouse is placed over the listbox.
`exportselection` | bool | If set, the list selection is automatically exported via the X selection mechanism. The default is on. If you have more than one list in the same dialog, it is probably best to disable this mechanism.
`font` | font | The font to use in the listbox. The listbox can only contain text in a single font.
`relief` | constant | Border decoration. The default is `SUNKEN`. Other possible values are `FLAT`, `RAISED`, `GROOVE`, and `RIDGE`.
`borderwidth (bd)` | distance | The width of the listbox border. The default is platform specific, but is usually 1 or 2 pixels.
`selectbackground, selectforeground` | color | Selection color settings.
`selectborderwidth` | dimension | Selection border width. The selection is always raised.
`selectmode` | constant | Selection mode. One of `SINGLE`, `BROWSE`, `MULTIPLE`, or `EXTENDED`. Default is `BROWSE`. Use `MULTIPLE` to get checklist behavior, `EXTENDED` if the user usually selects one item, but sometimes would like to select one or more ranges of items. See the patterns section for more information.
`setgrid` | bool |
`takefocus` | bool | Indicates that the user can use the Tab key to move to this widget. Default is an empty string, which means that the listbox accepts focus only if it has any keyboard bindings (default is on, in other words).
`width, height` | distance | The size of the listbox, in text units.
`xscrollcommand, yscrollcommand` | command | Used to connect a listbox to a scrollbar. These options should be set to the `set` methods of the corresponding scrollbars.

前页 | Home | 后页
Methods | Up | The Menu Widget