TCombobox
A themed dropdown — an entry combined with a list of choices. The user picks a value, and (unless read-only) may type one.
Live preview
Try the Theme switcher in the toolbar — this preview restyles live:
Live preview. In the Player's built-in docs viewer (
scriptweaver --help), this rendersTComboboxas a live, theme-aware widget you can interact with.
Example
const theme = app.TCombobox({ state: 'readonly' });
theme.setValues(['System', 'Light', 'Dark']);
theme.value = 'System';
theme.pack.configure({ padx: 16, pady: 8 });
theme.bind('<<ComboboxSelected>>', () => console.log('chose', theme.value));
Options
| Option | Type | Description |
|---|---|---|
state |
string | 'normal' (editable), 'readonly' (pick only), or 'disabled'. |
textVariable |
StringVar |
Bind the current value. |
width |
number | Width in characters. |
style |
string | A ttk style name. |
Set the list of choices with setValues() (below).
Methods
| Method | Description |
|---|---|
value |
Property: get or set the current text. |
setValues(list) |
Replace the dropdown choices with an array. |
current(index?) |
Get the selected index, or select by index. |
Plus the inherited widget methods — see Widget basics.
Events
Choosing from the dropdown fires the <<ComboboxSelected>> virtual event; bind
it to react:
combo.bind('<<ComboboxSelected>>', () => {
/* combo.value has changed */
});