Combobox#
Combobox is the native ttk drop-down list combined with an editable text
field (ttk.Combobox), themed by ttkbootstrap. This page is the
complete reference for its options, methods, and styling.
Options#
Each option can be set in the constructor and changed later with configure().
Option |
Type |
Description |
|---|---|---|
|
|
Constructor keyword. An accent color, optionally with a variant. See Styling options for the available styles. |
|
|
A |
|
|
The list of choices shown in the drop-down. |
|
|
A callback run just before the drop-down list is posted. |
|
|
The maximum number of rows shown in the drop-down before it scrolls. |
|
|
A character to display instead of the real text (e.g. |
|
|
Text alignment: |
|
|
The font for the text. |
|
|
The text color. |
|
|
When validation runs: |
|
|
The callback that validates a proposed value; returns a boolean. |
|
|
The callback run when |
|
|
|
|
|
Whether the selection is exported to the clipboard/X selection. |
|
|
The mouse cursor over the field (see Cursors). |
|
|
Whether the field accepts keyboard focus during traversal. |
|
|
The requested width in characters. |
|
|
A callback connecting the field to a horizontal scrollbar. |
Methods#
- current(newindex=None)
Return the index of the selected value in
values, or set it whennewindexis given.- Return type:
- set(value)
Set the field’s contents to
value.- Returns:
None.
- get()
Return the current text.
- Return type:
- insert(index, string)
Insert
stringbefore the character atindex("end"appends).- Returns:
None.
- delete(first, last=None)
Delete the characters from
firstthroughlast(or a single one).- Returns:
None.
- index(index)
Resolve an index expression (
"insert","end", …) to an integer.- Return type:
- icursor(index)
Move the insert cursor to
index.- Returns:
None.
- selection_range(start, end)
Select the characters from
starttoend. Aliased asselect_range; theselection_*/select_*family also hasclear,present,adjust,from, andto.- Returns:
None.
- xview(*args)
Query or set the horizontal view; usually wired to a scrollbar. Has
xview_moveto(fraction)andxview_scroll(number, what)variants.
- scan_mark(x)
Record a starting point for a fast drag-scroll (paired with
scan_dragto(x), which scrolls the view relative to that point).- Returns:
None.
Styling options#
This section is for changing how the combobox looks. Define a style with
style.configure(...) (and style.map(...) for per-state colors), then
apply it with Combobox(style=...).
Bootstyle mapping#
Any of the accent colors – primary, secondary, success, info, warning, danger, light, dark – substitutes for primary below. neutral does not apply to this family.
|
ttk style name |
|---|---|
|
|
Layout (elements)#
The widget is drawn from these nested parts. Each is an element you can target by name in a custom layout:
combo.Spinbox.field
Combobox.padding
Combobox.downarrow
Combobox.textarea
Configurable style options#
Options you can set with style.configure(...) / style.map(...):
arrowcolor, arrowsize, background, bordercolor, darkcolor, fieldbackground, font, foreground, gripcount, lightcolor, orient, padding, relief, shiftrelief, sliderlength, troughcolor, width
Supported states#
The states you can target with style.map(...) to vary appearance by interaction:
!disabled, disabled, focus, invalid, pressed, readonly
Hand-styling example#
import ttkbootstrap as ttk
app = ttk.App()
style = app.style
style.configure("my.TCombobox", background="#3498db", foreground="white")
ttk.Combobox(app, style="my.TCombobox").pack(padx=8, pady=8)
app.mainloop()
See also#
Combobox catalog page — usage, screenshots, and examples.
Tk ttk::combobox manual page — the canonical upstream reference (Tcl 8.6).