**Documentation for ttk::combobox** [Ttk]'s [combobox] [widget]. : http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_combobox.htm ---- **Ideas for combobox autocompletion** [TR] - I saw that the [combobox] of the [Tile] package didn't support autocompletion, so I added it using the code from [BWidget]: proc ComboBoxAutoComplete {path key} { # # autocomplete a string in the ttk::combobox from the list of values # # Any key string with more than one character and is not entirely # lower-case is considered a function key and is thus ignored. # # path -> path to the combobox # if {[string length $key] > 1 && [string tolower $key] != $key} {return} set text [string map [list {[} {\[} {]} {\]}] [$path get]] if {[string equal $text ""]} {return} set values [$path cget -values] set x [lsearch $values $text*] if {$x < 0} {return} set index [$path index insert] $path set [lindex $values $x] $path icursor $index $path selection range insert end } All you need to do now, is binding to this procedure: package require Tk 8.5 package require tile ttk::combobox .c -values [list one two three four five six seven] pack .c -padx 5 -pady 5 bind .c [list ComboBoxAutoComplete .c %K] [CLN] 2006-04-20 - Shouldn't this be in a namespace or at least be named ttkComboBoxAutoComplete? For that matter, why not submit a patch to get this into the Tile distribution. (Not that I wouldn't be grateful to have it available here in the mean time if I was using Tile.) [TR] 2006-04-21 - I just read the tile paper [http://www.t-ide.com/tcl2005e/2_tile-eurotcl2005.pdf.gz] by [Rolf Ade]. It mentions autocompletion code in the demos directory of the tile distribution. I haven't used that code yet, but it seems to do the same job as the code above, just in the correct namespace and as a command like tile::combobox::enableAutocomplete So, the above code is not needed, really ... ---- [jnc] Feb 5, 2010 - Here is complete auto-complete code. This code completes while in an editable or readonly combobox. It also completes the with a key press when in the drop down list from the combobox. At the bottom is a simple example. [jnc] Sep 15, 2010 - Updated coded... In a read only widget pressing S will match "Six" and pressing S again will match the next "S" entry which is "Seven" in my example. When no more matches are found, it will start back at the beginning "Six". This is behavior as found in Windows and suggested by [MHo]. Also bug fixes to some keys such as ' and ". The code is getting large enough it does not belong mixed in which a lot of other code on the page. Please see my Misc Tcl Repository http://jeremy.cowgar.com/misctcl/index.cgi/index and the combobox code is specifically located at: http://jeremy.cowgar.com/misctcl/index.cgi/doc/tip/combobox/combobox.tcl ---- **Questions and Suggestions concerning ttk::combobox** [RLH] It would be nice if a widget is involved to see a graphic showing the widget. Not necessary...but nice. ---- [D. McC] 2008 Dec 8: OK, after rummaging through the ttk::style man page and trying things out in vain, I give up. Can somebody tell me how to specify the background color for the entry portion of the ttk::combobox? And can somebody tell me why there is not even an ''option'' to specify colors of Ttk widgets in the same ultra-simple way as for Tk widgets, e.g., "-bg AntiqueWhite"? [Bryan Oakley] 2008 Dec 8: To solve your immediate problem, try this: ttk::combobox .cb -style mycombobox.TCombobox ttk::style configure mycombobox.TCombobox -fieldbackground bisque (using "ttk::style map" may be a better choice, but I'll leave that as an exercise for the reader) As to why there is no option, that's the design philosophy of the themed widgets -- you lose some amount of control over individual widgets but gain the ability to create unified themes. ---- [D. McC] 2008 Dec 9: Thanks--it works! Now I'll see about incorporating that into my color-scheme files. What I still don't understand is why the programmer isn't given a choice about how much control over individual widgets (and ease of configuring them) to trade off for how much ability to create unified themes. ---- [Tim Tomkinson%|%TLT%|%] 2009-11-28 - I was annoyed that the ttk::combobox does not change the cursor to an ibeam when it is inside the text entry widget. The following binding fixes that: bind TCombobox { if {[%W cget -state] eq "normal" && [%W identify %x %y] eq "textarea"} { %W configure -cursor xterm } else { %W configure -cursor "" } } pack [ttk::combobox .cb] ---- [MHo]: In the read-only-editfield, how is it possible, e.g. to get the entry ''Seven''? Pressing '''S''' always leads to ''Six'' (prior in the list), pressing '''S''' again does not help, pressing '''E''' right after S leads to ''Eight''. This is true for the listbox, too. [jnc]: Feb 24, 2010: In my misc-tcl code project, there is updated combo box code. I have not updated it here yet as I don't want to make daily updates here. The code on the misc-tcl project page allows properly for the Up/Down use of arrow keys to select items when in the readonly edit field. So, to get to Seven, you would press '''S''' and then use your up/down arrow key to navigate to Seven. This is how Windows works. I would actually prefer it to allow allow typing of '''SE''' which would go to Seven, but this would be non-standard. I am sure you can modify the above code for that type of action if you so desired. [MHo]: At least within list boxes/tables (like explorer windows) windows navigates to the next matching entry which each keypress. So, the first '''S''' would go to ''Seven'', the next '''S''' to ''Six'' etc. My miscellaneous Tcl code is located at: http://jeremy.cowgar.com/misctcl/index.cgi/index and the combobox code is specifically located at: http://jeremy.cowgar.com/misctcl/index.cgi/doc/tip/combobox/combobox.tcl .. That will always be my latest source. The source (as of Feb 24, 2010) has been submitted to Tcl/Tk as the default behavior. No action has been taken on it as of this time. ---- [LV] 2010-06-09 In the iwidgets combobox, one had the ability to specified a command to execute when one of the menu items in the dropdown list is selected. How does one do that with the ttk version of the combobox? [hae] 2010-06-09 The ttk::combobox does not have this. However here is a basic example to have a callback, when an item is selected. ====== package require tk package require Tk package require Ttk set values [list Orange Apple Peas] set c [ttk::combobox .cbx -values $values] pack $c proc OnComboSelected { w } { puts [info level 0] } bind $c <> [list OnComboSelected %W] ====== Okay, so I attempted to use the above code. However, I do not get the item selected displayed when I click on an entry. Instead, I get the text: "OnComboSelected .cbx" output. So, when I change OnComboSelected to read ====== proc OnComboSelected { w } { puts [$w get] } ====== I get the selected item output. What a pain for people trying to use ttk from iwidgets! ---- !!!!!! %| [Category Widget] |% !!!!!!