Skip to content

Combobox

Prefer SelectBox

SelectBox provides all the functionality of Combobox plus additional features: keyboard navigation, hover states, search/filtering, form integration (labels, messages, validation), and standardized events. Use Combobox only when you need direct access to the underlying bs.Combobox API.

Combobox is a primitive selection widget that wraps bs.Combobox with bootstack styling and reactive text support.

It provides a familiar dropdown list with optional typing. Use Combobox when you need low-level ttk behavior or direct access to bs.Combobox methods. Use SelectBox for most selection use cases.


Quick start

import bootstack as bs

app = bs.App()

combo = bs.Combobox(
    app,
    values=["Low", "Medium", "High"],
    state="readonly",
)
combo.pack(padx=20, pady=20)

app.mainloop()

When to use

Use Combobox when:

  • you need direct access to bs.Combobox methods (e.g., current(), postcommand)

  • you're integrating with existing code that expects a bs.Combobox

Consider a different control when...

  • for most selection use cases - prefer SelectBox, which provides keyboard navigation, hover states, search/filtering, and form integration

  • you want the simplest menu-style single selection picker - prefer OptionMenu


Appearance

A Combobox is a hybrid control:

  • dropdown list of values (values=...)

  • optional typing (editable mode)

  • selection is represented as text (string)

It is best for compact, low-complexity pickers.

accent

Applies bootstack theme styling.

bs.Combobox(app, values=["A", "B"], accent="primary")
bs.Combobox(app, values=["A", "B"], accent="secondary")

Colors and styling

Use accent tokens to match the active theme. The entry field and the dropdown list are styled consistently and respond to theme changes.


Examples and patterns

Variants

Readonly (pick only)

Users must pick from the list.

bs.Combobox(app, values=["One", "Two", "Three"], state="readonly")

Editable (type + suggestions)

Users can type any text, or pick from the list.

bs.Combobox(app, values=["Apple", "Banana", "Cherry"], state="normal")

How the value works

Combobox stores a string:

  • get() returns the current text

  • set(value) sets the current text

  • textvariable= binds to a Tk variable

  • textsignal= binds to a reactive signal

value = combo.get()
combo.set("Medium")

The meaning of the text depends on state:

  • state="readonly" - text should always be one of values

  • state="normal" - text may be arbitrary

Binding to signals or variables

Tk variables

choice = bs.StringVar(value="Medium")

combo = bs.Combobox(app, textvariable=choice, values=["Low", "Medium", "High"], state="readonly")

Reactive signals

combo = bs.Combobox(app, textsignal=my_signal, values=["Low", "Medium", "High"], state="readonly")

Common options

values

Defines the list shown in the dropdown.

combo.configure(values=["One", "Two", "Three"])

state

  • "readonly" for strict selection

  • "normal" for editable mode

  • "disabled" to disable interaction

combo.configure(state="readonly")

Events

Combobox emits standard ttk events (no field-style on_changed helpers).

Most commonly used:

  • <<ComboboxSelected>> - when the user selects an item from the dropdown
combo.bind("<<ComboboxSelected>>", lambda e: print(combo.get()))

If you need to react to typing, bind key events:

combo.bind("<KeyRelease>", lambda e: print(combo.get()))

Behavior

  • Clicking the arrow opens the dropdown list.

  • In readonly mode, selection is made from the list only.

  • In editable mode, typing changes the text immediately.

Validation and constraints

Combobox is a primitive widget and does not provide built-in validation semantics.

Use state="readonly" to constrain values to the list, or apply your own validation rules externally.

If you want validation messages, required behavior, and commit semantics, prefer SelectBox.


Localization

Combobox does not automatically localize values. If you supply localized strings, they will be displayed as-is.

If you need localization-aware field labels and messaging, prefer SelectBox.


Additional resources

  • SelectBox - form-ready selection control with validation and optional search

  • OptionMenu - simple menu-based picker

  • DropdownButton - action menu (not value selection)

Framework concepts

API reference