home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / tcl / tk8.4 / demos / labelframe.tcl < prev    next >
Text File  |  2001-10-30  |  2KB  |  81 lines

  1. # labelframe.tcl --
  2. #
  3. # This demonstration script creates a toplevel window containing
  4. # several labelframe widgets.
  5. #
  6. # RCS: @(#) $Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp $
  7.  
  8. if {![info exists widgetDemo]} {
  9.     error "This script should be run from the \"widget\" demo."
  10. }
  11.  
  12. set w .labelframe
  13. catch {destroy $w}
  14. toplevel $w
  15. wm title $w "Labelframe Demonstration"
  16. wm iconname $w "labelframe"
  17. positionWindow $w
  18.  
  19. # Some information
  20.  
  21. label $w.msg -font $font -wraplength 4i -justify left -text "Labelframes are\
  22.     used to group related widgets together.  The label may be either \
  23.     plain text or another widget."
  24. pack $w.msg -side top
  25.  
  26. # The bottom buttons
  27.  
  28. frame $w.buttons
  29. pack $w.buttons -side bottom -fill x -pady 2m
  30. button $w.buttons.dismiss -text Dismiss -command "destroy $w" -width 15
  31. button $w.buttons.code -text "See Code" -command "showCode $w" -width 15
  32. pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
  33.  
  34. # Demo area
  35.  
  36. frame $w.f
  37. pack $w.f -side bottom -fill both -expand 1
  38. set w $w.f
  39.  
  40. # A group of radiobuttons in a labelframe
  41.  
  42. labelframe $w.f -text "Value" -padx 2 -pady 2
  43. grid $w.f -row 0 -column 0 -pady 2m -padx 2m
  44.  
  45. foreach value {1 2 3 4} {
  46.     radiobutton $w.f.b$value -text "This is value $value" \
  47.             -variable lfdummy -value $value
  48.     pack $w.f.b$value -side top -fill x -pady 2
  49. }
  50.  
  51.  
  52. # Using a label window to control a group of options.
  53.  
  54. proc lfEnableButtons {w} {
  55.     foreach child [winfo children $w] {
  56.         if {$child == "$w.cb"} continue
  57.         if {$::lfdummy2} {
  58.             $child configure -state normal
  59.         } else {
  60.             $child configure -state disabled
  61.         }
  62.     }
  63. }
  64.  
  65. labelframe $w.f2 -pady 2 -padx 2
  66. checkbutton $w.f2.cb -text "Use this option." -variable lfdummy2 \
  67.         -command "lfEnableButtons $w.f2" -padx 0
  68. $w.f2 configure -labelwidget $w.f2.cb
  69. grid $w.f2 -row 0 -column 1 -pady 2m -padx 2m
  70.  
  71. set t 0
  72. foreach str {Option1 Option2 Option3} {
  73.     checkbutton $w.f2.b$t -text $str
  74.     pack $w.f2.b$t -side top -fill x -pady 2
  75.     incr t
  76. }
  77. lfEnableButtons $w.f2
  78.  
  79.  
  80. grid columnconfigure $w {0 1} -weight 1
  81.