#!/bin/sh
# chk_btnn.tcl \
exec tclsh "$0" ${1+"$@"}
# Graphical User Interface :ListBox
proc insert_to_list {} {
#take the input of the entry
set input [ .ent get ]
#if { $input =""} {return}
#put input on the end of all listbox items
.lst insert end "$input"
}
proc delete_from_list {} {
#to delete the current selection
set selected_index [ .lst curselection]
if { $selected_index ==""} { return }
.lst delete $selected_index
.lst activate 0
}
listbox .lst -selectmode single ; # select mode can be single browse multiple or extend; the default value is browse
.lst insert end "student " "Teacher" "clerk" "Business Man" "Common Man" "Computer Expert" "Others"
.lst configure -activestyle underline
.lst activate 1
entry .ent -textvariable text_ent
button .but1 -text "insert to list" -command "insert_to_list"
button .but2 -text "delete from list" -command "delete_from_list"
pack .lst
pack .ent
pack .but1
pack .but2
# chk_btnn.tcl \
exec tclsh "$0" ${1+"$@"}
# Graphical User Interface :ListBox
proc insert_to_list {} {
#take the input of the entry
set input [ .ent get ]
#if { $input =""} {return}
#put input on the end of all listbox items
.lst insert end "$input"
}
proc delete_from_list {} {
#to delete the current selection
set selected_index [ .lst curselection]
if { $selected_index ==""} { return }
.lst delete $selected_index
.lst activate 0
}
listbox .lst -selectmode single ; # select mode can be single browse multiple or extend; the default value is browse
.lst insert end "student " "Teacher" "clerk" "Business Man" "Common Man" "Computer Expert" "Others"
.lst configure -activestyle underline
.lst activate 1
entry .ent -textvariable text_ent
button .but1 -text "insert to list" -command "insert_to_list"
button .but2 -text "delete from list" -command "delete_from_list"
pack .lst
pack .ent
pack .but1
pack .but2
The listbox widget supports several options. Three
ReplyDeleteuseful options are
-selectmode style
style: single /or/ multiple /or/ browse /or/ extended
Note that the listbox curselection subcommand returns a list of the
indices of selected items, whereas this selection returns a list of the content