icon.tcl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # icon.tcl --
  2. #
  3. # This demonstration script creates a toplevel window containing
  4. # buttons that display bitmaps instead of text.
  5. if {![info exists widgetDemo]} {
  6. error "This script should be run from the \"widget\" demo."
  7. }
  8. package require Tk
  9. set w .icon
  10. catch {destroy $w}
  11. toplevel $w
  12. wm title $w "Iconic Button Demonstration"
  13. wm iconname $w "icon"
  14. positionWindow $w
  15. label $w.msg -font $font -wraplength 5i -justify left -text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected."
  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. # Main widget program sets variable tk_demoDirectory
  21. image create bitmap flagup \
  22. -file [file join $tk_demoDirectory images flagup.xbm] \
  23. -maskfile [file join $tk_demoDirectory images flagup.xbm]
  24. image create bitmap flagdown \
  25. -file [file join $tk_demoDirectory images flagdown.xbm] \
  26. -maskfile [file join $tk_demoDirectory images flagdown.xbm]
  27. frame $w.frame -borderwidth 10
  28. pack $w.frame -side top
  29. checkbutton $w.frame.b1 -image flagdown -selectimage flagup \
  30. -indicatoron 0
  31. $w.frame.b1 configure -selectcolor [$w.frame.b1 cget -background]
  32. checkbutton $w.frame.b2 \
  33. -bitmap @[file join $tk_demoDirectory images letters.xbm] \
  34. -indicatoron 0 -selectcolor SeaGreen1
  35. frame $w.frame.left
  36. pack $w.frame.left $w.frame.b1 $w.frame.b2 -side left -expand yes -padx 5m
  37. radiobutton $w.frame.left.b3 \
  38. -bitmap @[file join $tk_demoDirectory images letters.xbm] \
  39. -variable letters -value full
  40. radiobutton $w.frame.left.b4 \
  41. -bitmap @[file join $tk_demoDirectory images noletter.xbm] \
  42. -variable letters -value empty
  43. pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes