[HOME][CONTENTS][DOWNLOAD][PREV][NEXT]


COMB WIDGET EXAMPLES

In following window eight widgets are packed in frm widgets with their names displayed as labels on the upleft frame. These widgets comply with the comb-widget specifications and can be used as modular components in various applications. These widgets are Frame Container (frm), Fold Container (fold), Grouped Buttons (gbtn), Multiple Entries (ment), Numeric Thumbs (num), Pulldown List (pdl), Palettes (pal), Poster Board (post), String Container (str) and Scrollbar List (slis). 

# Scripts: less than 90 lines 

global font
set font "-*-Helvetica-bold-r-normal-*-*-140-*-*-*-*-*-*" 

proc comb.demo {} { 
global gimgHome font
set pwd [pwd]
cd $gimgHome 

set w .comb
catch "destroy $w"
toplevel $w 

wm title $w "Combined Widgets"
set ment [ment.demo $w]
set str [str.demo $w] 
set gbtn [gbtn.demo $w]
set num [num.demo $w] 
set slis [slis.demo $w]
set pdl [pdl.demo $w] 
set pal [pal.demo $w]
set post [post.demo $w] 
set fold [fold.demo $w]

grid $str -row 0 -column 0 -padx 2 -pady 2 -sticky nswe 
grid $num -row 0 -column 1 -padx 2 -pady 2 -sticky nswe
grid $pdl -row 0 -column 2 -padx 2 -pady 2 -sticky nswe 
grid $fold -row 0 -column 3 -rowspan 3 -padx 2 -pady 2 -sticky nswe
grid $ment -row 1 -column 0 -rowspan 2 -columnspan 2 -padx 2 -pady 2 -sticky nswe
grid $gbtn -row 1 -column 2 -rowspan 2 -padx 2 -pady 2 -sticky nswe
grid $pal -row 3 -column 0 -rowspan 2 -columnspan 2 -padx 2 -pady 2 -sticky nswe 
grid $slis -row 3 -column 2 -rowspan 2 -padx 2 -pady 2 -sticky nswe
grid $post -row 3 -column 3 -rowspan 2 -padx 2 -pady 2 -sticky nswe 

cd $pwd 

proc ment.demo w { 
global font 
set ment [frm.create $w.ment -label {-text ment -font $font} -pad {-bd 10}]
set item [frm.add $ment -ment ment.create "-title Multi-Entries \ 
    -btns {{-text Ok} {-text Cancel} {-text Quit}} \
    -vars {name address phone} \ 
    -values {Yuchen Slidell (504)649-1388}"] 

pack $item -expand 1 -fill both 

ment.config $item -btn0 {-command "puts Ok; bell"} \
    -btn1 {-command "puts Cancel; bell"} \ 
    -btn2 [list -command "puts Quit; bell"] \
    -v0 {-width 24} -v1 {-width 24} -v2 {-width 24} 
return $ment 

proc str.demo w { 
global font 

set str [frm.create $w.str -label {-text str -font $font} -pad {-bd 10}]
pack [frm.add $str -str str.create "\ 
    -padx 4 -pady 4 -layout right \
    -btn {-text Entry -width 5 \ 
        -comm {puts \[str.get $str\]}} -ent {-width 8}"] \
    -expand 1 -fill both 

comb.config $str {-str -relief} sunken
return $str 

proc gbtn.demo w { 
global font 

set gbtn [frm.create $w.gbtn -label {-text gbtn -font $font} -pad {-bd 10}]
global radio b2 b3 b4 

set radio 1
set b2 1 

pack [frm.add $gbtn -gbtn gbtn.create "\
    -label {-text {Group}} -btns { \ 
    {radio -text Button0 -width 8 -val 0 -var radio -comm {puts radio0}} \
    {radio -text Button1 -val 1 -var radio -comm {puts radio1}} \ 
    {check -text Button2 -var b2 -comm {puts Button2:b2}} \
    {check -text Button3 -var b3 -comm {puts Button3:b3}} \ 
    {check -text Button4 -var b4 -comm {puts Button4:b4}} } \
    -layout vertical"] -expand 1 -fill both 
return $gbtn 

proc num.demo w { 
global font
set num [frm.create $w.num -label {-text num -font $font} -pad {-bd 10}] 

global entryVar
set entryVar 50 

pack [frm.add $num -num num.create "\
    -fmt %.2f -chck {-text check -width 5} \ 
    -ent {-width 4 -textv entryVar} \
    -init 50 -min 0 -max 100 -inc 1.532 -dec 1.532"] \ 
    -expand 1 -fill both 
comb.config [comb.id $num -num]
num.bindChange [comb.id $num -num] num.printChange 
return $num 

proc slis.demo w { 
global font
set slis [frm.create $w.slis -label {-text slis -font $font} -pad {-bd 10}] 

pack [frm.add $slis -slis slis.create "\
    -list {-width 8} -layout v -items \ 
    {item0 item1 item2 item3 item4 item5 \
     item6 item7 item8 item9 item10}"] \
    -expand 1 -fill both 
return $slis 

proc pdl.demo w { 
global font
set pdl [frm.create $w.pdl -label {-text pdl -font $font} -pad {-bd 10}] 

global pdtext
set pdtext text 

pack [frm.add $pdl -pdl pdl.create "\ 
    -label {-text File: } -ent {-width 6 -textv pdtext}"] \
    -expand 1 -fill both 

pdl.setList [comb.id $pdl -pdl] \ 
    {File1 File2 File3 File4 File5 File6 File7 File8 File9 File0}
pdl.bind [comb.id $pdl -pdl] <Return> {pdl.testv pdtext} -ent 
return $pdl 

proc pal.demo w { 
global font
set pal [frm.create $w.pal -label {-text pal -font $font} -pad {-bd 10}] 
pack [frm.add $pal -pal pal.create] -expand 1 -fill both
return $pal 

proc post.demo w { 
global font 

set post [frm.create $w.post -label {-text post -font $font} -pad {-bd 10}]
pack [frm.add $post -post post.create] -expand 1 -fill both 
set itemList {open prev next cfg in out fit lrotat rrotat xflip \
yflip len hist notool point line polyg rect circle text rgb red green blue bw} 

set items [list]
foreach item $itemList {
    lappend items "tool.$item $item"
    tool.$item setIndices RGB {{15 192 192 192}}

post.set [comb.id $post -post] $items 
return $post 

proc fold.demo w { 
global font
set fold [frm.create $w.fold -label {-text fold -font $font} -pad {-bd 10}] 
pack [frm.add $fold -fold fold.create "-foldHeight 128 -foldWidth 200" ] \
    -expand 1 -fill both 
return $fold 

[HOME][CONTENTS] [DOWNLOAD]