| Itcl  | Itk  | Itcl @ Wiki  | Itcl @ SF  | Tcl  | Tcl @ Wiki |
  home || iwidgets || man pages cross ref distribution docs faq  
buttonbox
calendar
canvasprintbox
canvasprintdialog
checkbox
combobox
dateentry
datefield
dialog
dialogshell
disjointlistbox
entryfield
extbutton
extfileselectionbox
extfileselectiondialog
feedback
fileselectionbox
fileselectiondialog
finddialog
hierarchy
hyperhelp
labeledframe
labeledwidget
mainwindow
menubar
messagebox
messagedialog
notebook
optionmenu
panedwindow
promptdialog
pushbutton
radiobox
regexpfield
scrolledcanvas
scrolledframe
scrolledhtml
scrolledlistbox
scrolledtext
scrolledwidget
selectionbox
selectiondialog
shell
spindate
spinint
spinner
spintime
tabnotebook
tabset
timeentry
timefield
toolbar
watch

man page | options | methods

Combobox

The combobox class is an enhanced entry field widget with an optional associated label and a scrollable list. When an item is selected in the list area of a combobox it's value is then displayed in the entry field text area. Functionally similar to an optionmenu, the combobox adds list scrolling, item editing and inserting capabilities. For further information, see the Combobox manpage

Components: arrowBtn entry hull label list popup
				

wm title . "Combobox Example"

##
##	supporting proc to dynamically
##	change the second list
##
proc updateList2 {} {

	global lst

	set sel [.cb1 get]

	##
	##	Clear the lists and entries
	##	for the second and third comboboxes
	##	Note that the combobox needs to have
	##	-editable set to true in order
	##	to clear the entry widget
	##
	.cb2 delete list 0 end
	.cb2 delete entry 0 end
	.cb3 delete list 0 end
	.cb3 delete entry 0 end

	eval .cb2 insert list end $lst($sel)

	return

}; # end proc updateList2


##
##	supporting proc to dynamically
##	change the third list
##
proc updateList3 {} {

	global lst

	set sel [.cb2 get]

	.cb3 delete list 0 end
	.cb3 delete entry 0 end

	eval .cb3 insert list end $lst($sel)

	return
}; # end proc updateList3

##
##	Some lists to populate the
##	comboboxes
##
set lst(1) [list Linux Windows]
set lst(Linux) [list RedHat SuSE]
set lst(Windows) [list Microsoft]
set lst(RedHat) [list 6.0 6.1 6.2 7.0 7.1]
set lst(SuSE) [list 6.0 6.1 6.2 6.3 6.4 7.0 7.1]
set lst(Microsoft) [list Win95 Win98 WinNT Win2000 WinME]



##=========================================================
##	Create several Combobox iwidgets
##=========================================================
##
	## Non-editable Dropdown Combobox
iwidgets::combobox .cb1 \
	-labeltext OS: \
	-editable false \
	-arrowrelief ridge \
	-popupcursor hand2 \
	-selectioncommand updateList2


	## Editable Dropdown Combobox
iwidgets::combobox .cb2 \
	-labeltext "Vendor:" \
	-arrowrelief ridge \
	-completion false \
	-popupcursor hand2 \
	-selectioncommand updateList3

	## Simple Combobox
iwidgets::combobox .cb3 \
	-labeltext Version: \
	-arrowrelief ridge \
	-popupcursor hand2 \
	-dropdown false

##
##	Add the first combox list
##
eval .cb1 insert list 0 $lst(1)

pack .cb1 .cb2 .cb3 \
	-padx 10 \
	-pady 10 \
	-fill x

iwidgets::Labeledwidget::alignlabels .cb1 .cb2 .cb3

Download this sample code
man page | options | methods
 
  home || iwidgets || man pages cross ref distribution docs faq  
Copyright | Contributions | Development Team | Credits
Bugs/Comments/Suggestions about this web site