home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / demos / BWidgets / select.tcl < prev    next >
Encoding:
Text File  |  2001-10-22  |  2.8 KB  |  60 lines

  1. namespace eval DemoSelect {
  2.     variable var
  3. }
  4.  
  5.  
  6. proc DemoSelect::create { nb } {
  7.     set frame [$nb insert end demoSelect -text "Spin & Combo"]
  8.  
  9.     set titf1 [TitleFrame $frame.titf1 -text SpinBox]
  10.     set subf  [$titf1 getframe]
  11.     set spin  [SpinBox $subf.spin \
  12.                    -range {1 100 1} -textvariable DemoSelect::var(spin,var) \
  13.                    -helptext "This is the SpinBox"]
  14.     set ent   [LabelEntry $subf.ent -label "Linked var" -labelwidth 10 -labelanchor w \
  15.                    -textvariable DemoSelect::var(spin,var) -editable 0 \
  16.                    -helptext "This is an Entry reflecting\nthe linked var of SpinBox"]
  17.     set labf  [LabelFrame $subf.options -text "Options" -side top -anchor w \
  18.                    -relief sunken -borderwidth 1 \
  19.                    -helptext "Modify some options of SpinBox"]
  20.     set subf  [$labf getframe]
  21.     set chk1  [checkbutton $subf.chk1 -text "Non editable" \
  22.                    -variable DemoSelect::var(spin,editable) -onvalue false -offvalue true \
  23.                    -command "$spin configure -editable \$DemoSelect::var(spin,editable)"]
  24.     set chk2  [checkbutton $subf.chk2 -text "Disabled" \
  25.                    -variable DemoSelect::var(spin,state) -onvalue disabled -offvalue normal \
  26.                    -command "$spin configure -state \$DemoSelect::var(spin,state)"]
  27.  
  28.     pack $chk1 $chk2 -side left -anchor w
  29.     pack $spin $ent $labf -pady 4 -fill x
  30.     pack $titf1
  31.  
  32.     set titf2 [TitleFrame $frame.titf2 -text ComboBox]
  33.     set subf  [$titf2 getframe]
  34.     set combo [ComboBox $subf.combo \
  35.                    -textvariable DemoSelect::var(combo,var) \
  36.                    -values {"first value" "second value" "third value" "fourth value" "fifth value"} \
  37.                    -helptext "This is the ComboBox"]
  38.     set ent   [LabelEntry $subf.ent -label "Linked var" -labelwidth 10 -labelanchor w \
  39.                    -textvariable DemoSelect::var(combo,var) -editable 0 \
  40.                    -helptext "This is an Entry reflecting\nthe linked var of ComboBox"]
  41.     set labf  [LabelFrame $subf.options -text "Options" -side top -anchor w \
  42.                    -relief sunken -borderwidth 1 \
  43.                    -helptext "Modify some options of SpinBox"]
  44.     set subf  [$labf getframe]
  45.     set chk1  [checkbutton $subf.chk1 -text "Non editable" \
  46.                    -variable DemoSelect::var(combo,editable) -onvalue false -offvalue true \
  47.                    -command  "$combo configure -editable \$DemoSelect::var(combo,editable)"]
  48.     set chk2  [checkbutton $subf.chk2 -text "Disabled" \
  49.                    -variable DemoSelect::var(combo,state) -onvalue disabled -offvalue normal \
  50.                    -command  "$combo configure -state \$DemoSelect::var(combo,state)"]
  51.  
  52.     pack $chk1 $chk2 -side left -anchor w
  53.     pack $combo $ent $labf -pady 4 -fill x
  54.  
  55.     pack $titf1 $titf2 -pady 4
  56.  
  57.     return $frame
  58. }
  59.  
  60.