label.tcl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # label.tcl --
  2. #
  3. # This demonstration script creates a toplevel window containing
  4. # several label widgets.
  5. if {![info exists widgetDemo]} {
  6. error "This script should be run from the \"widget\" demo."
  7. }
  8. package require Tk
  9. set w .label
  10. catch {destroy $w}
  11. toplevel $w
  12. wm title $w "Label Demonstration"
  13. wm iconname $w "label"
  14. positionWindow $w
  15. label $w.msg -font $font -wraplength 4i -justify left -text "Five labels are displayed below: three textual ones on the left, and an image label and a text label on the right. Labels are pretty boring because you can't do anything with them."
  16. pack $w.msg -side top
  17. ## See Code / Dismiss buttons
  18. set btns [addSeeDismiss $w.buttons $w]
  19. pack $btns -side bottom -fill x
  20. frame $w.left
  21. frame $w.right
  22. pack $w.left $w.right -side left -expand yes -padx 10 -pady 10 -fill both
  23. label $w.left.l1 -text "First label"
  24. label $w.left.l2 -text "Second label, raised" -relief raised
  25. label $w.left.l3 -text "Third label, sunken" -relief sunken
  26. pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -pady 2 -anchor w
  27. # Main widget program sets variable tk_demoDirectory
  28. image create photo label.ousterhout \
  29. -file [file join $tk_demoDirectory images ouster.png]
  30. label $w.right.picture -borderwidth 2 -relief sunken -image label.ousterhout
  31. label $w.right.caption -text "Tcl/Tk Creator"
  32. pack $w.right.picture $w.right.caption -side top