Posted to tcl by patthoyts at Sat Apr 30 15:06:26 GMT 2011view raw

  1. package require Tk
  2. . configure -menu [menu .menu -tearoff 1]
  3. .menu add cascade -label Cascade -menu [menu .menu.file -tearoff 1]
  4. .menu add cascade -label Another -menu [menu .menu.edit -tearoff 1]
  5.  
  6. .menu.file add command -label One
  7. .menu.file add command -label Two
  8. .menu.file add cascade -label Three -menu [menu .menu.file.three -tearoff 1]
  9. .menu.file add separator
  10. .menu.file add command -label Exit -command exit
  11.  
  12. .menu.file.three add command -label Four
  13. .menu.file.three add command -label Five
  14.  
  15. foreach name {one two three four} {
  16. .menu.edit add command -label [string totitle $name] -command {}
  17. }
  18.  
  19. tkwait window .