ttk::combobox(3tk)
π ttk::combobox β the manual page, but make it cute π
okay so bestie, you're reading ttk::combobox(3tk) from the Tk Themed Widget family, and honestly? she's iconic. let's get into it π«Ά
β¨ NAME β¨
ttk::combobox β a text field with a popdown selection list. that's it, that's the vibe. text field + dropdown = the moment. π
πΈ SYNOPSIS πΈ
ttk::combobox pathName ?options?
π¦ DESCRIPTION π¦
So a ttk::combobox literally combines a text field with a pop-down list of values. the user can pick the value of the text field from among the values in that list. it's giving "type it yourself OR let me hand you a menu," and honestly, main character energy. π
β STANDARD OPTIONS β
these are the standard girlies, and they show up like:
-class-cursor-takefocus-style-placeholder-placeholderforeground
go check the ttk_widget manual entry for the deets on all these standard options, iykyk π
π WIDGET-SPECIFIC OPTIONS π
these are the ones that are hers specifically. slay. each one comes with a command-line name, a database name and a database class, so i'm giving you all three, no cap:
-exportselectionβ Database name:exportSelection, database class:ExportSelection. this one's a boolean value, and if it's set, the widget selection is linked to the X selection. π-justifyβ Database name:justify, database class:Justify. says how the text is aligned inside the widget. has to be one ofleft,center, orright. pick your fighter β¨-heightβ Database name:height, database class:Height. the height of the pop-down listbox, measured in rows. π-postcommandβ Database name:postCommand, database class:PostCommand. a Tcl script that gets evaluated immediately before displaying the listbox. fun fact: the-postcommandscript may specify the-valuesto display. sneaky but valid π-stateβ Database name:state, database class:State. one ofnormal,readonly, ordisabled. in thereadonlystate, the value may not be edited directly, and the user can only select one of the-valuesfrom the dropdown list. in thenormalstate, the text field is directly editable. in thedisabledstate, no interaction is possible. (disabled = she's not taking questions today π)-textvariableβ Database name:textVariable, database class:TextVariable. the name of a global variable whose value is linked to the widget value. whenever the variable changes value the widget value is updated, and vice versa. it's a two-way situationship fr fr π-valuesβ Database name:values, database class:Values. the list of values to display in the drop-down listbox. π-widthβ Database name:width, database class:Width. an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. π
π WIDGET COMMAND π
besides the standard cget, configure, identify element, instate, state and style commands (peep ttk::widget for those), combobox widgets support these extra commands:
pathName current ?newIndex?β ifnewIndexis supplied, sets the combobox value to the element at positionnewIndexin the list of-values. and bestie, in addition to integers, theendindex is supported and indicates the last element of the list β moreover the same simple interpretation as for the command stringindexis supported, with simple integer index arithmetic and indexing relative toend. otherwise, it returns the index of the current value in the list of-values, or{}if the current value does not appear in the list. πpathName getβ returns the current value of the combobox.pathName set valueβ sets the value of the combobox tovalue.
and the combobox widget also supports the following ttk::entry widget commands:
bboxdeleteicursorindexinsertselectionxview
π₯ VIRTUAL EVENTS π₯
the combobox widget generates a <<ComboboxSelected>> virtual event when the user selects an element from the list of values. and if the selection action unposts the listbox, this event is delivered after the listbox is unposted. timing is everything, periodt β°
π STYLING OPTIONS π
the class name for a ttk::combobox is TCombobox. the ttk::combobox uses the entry and listbox widgets internally, and the listbox frame has a class name of ComboboxPopdownFrame.
Dynamic states: disabled, focus, pressed, readonly.
TCombobox styling options configurable with ttk::style are:
-arrowcolor color-arrowsize amount-background color-bordercolor color-darkcolor color-focusfill color-foreground color-fieldbackground colorβ can only be changed when using non-native and non-graphical themes. (so like, read the room and check your theme first π)-insertcolor color-insertwidth amount-lightcolor color-padding padding-placeholderforeground color-postoffset padding-selectbackground colorβ text entry select background.-selectforeground colorβ text entry select foreground.
π§ the popdown listbox situation π§
the ttk::combobox popdown listbox cannot be configured using ttk::style nor via the widget configure command. instead, the listbox can be configured using the option database:
option add *TCombobox*Listbox.background color
option add *TCombobox*Listbox.font font
option add *TCombobox*Listbox.foreground color
option add *TCombobox*Listbox.selectBackground color
option add *TCombobox*Listbox.selectForeground color
to configure a specific listbox (subject to future change β lowkey a warning bestie, this could shift on you):
set popdown [ttk::combobox::PopdownWindow .mycombobox]
$popdown.f.l configure -font font
π« ComboboxPopdownFrame styling π«
ComboboxPopdownFrame styling options configurable with ttk::style are:
-borderwidth amount-relief relief
some options are only available for specific themes, so if something's not working, it might just be a theme thing, not a you thing π«Ά
see the ttk::style manual page for information on how to configure ttk styles. go read it, it's required reading bestie π
π SEE ALSO π
ttk::widget(3tk)ttk::entry(3tk)
π KEYWORDS π
choice, entry, list box, text box, widget
okay that's the whole page!! and for the sign-off: this lil masterpiece comes from Tk, version 8.5 β that's the source and the version and the date all rolled into one cute lil footer. stay hydrated, go configure your combobox, and remember: <rainbow>you ate</rainbow>. πβ¨ππ¦πΈπ
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 2004 Joe English
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms