text("This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette.")
}.pack('side'=>'top')
# frame
TkFrame.new($menubu_demo){|frame|
TkButton.new(frame){
text'Dismiss'
commandproc{
tmppath=$menubu_demo
$menubu_demo=nil
tmppath.destroy
}
}.pack('side'=>'left','expand'=>'yes')
TkButton.new(frame){
text'Show Code'
commandproc{showCode'menu'}
}.pack('side'=>'left','expand'=>'yes')
}.pack('side'=>'bottom','fill'=>'x','pady'=>'2m')
else;# Tk8.x
body=TkFrame.new($menubu_demo)
body.pack('expand'=>'yes','fill'=>'both')
below=TkMenubutton.new(body){
text"Below"
underline0
direction'below'
relief'raised'
}
belowMenu=TkMenu.new(below){
tearoff0
add'command','label'=>"Below menu: first item",'command'=>proc{puts"\"You have selected the first item from the Below menu.\""}
add'command','label'=>"Below menu: second item",'command'=>proc{puts"\"You have selected the second item from the Below menu.\""}
}
below.menu(belowMenu)
below.grid('row'=>0,'column'=>1,'sticky'=>'n')
below=TkMenubutton.new(body){
text"Below"
underline0
direction'below'
relief'raised'
}
belowMenu=TkMenu.new(below){
tearoff0
add'command','label'=>"Below menu: first item",'command'=>proc{puts"\"You have selected the first item from the Below menu.\""}
add'command','label'=>"Below menu: second item",'command'=>proc{puts"\"You have selected the second item from the Below menu.\""}
}
below.menu(belowMenu)
below.grid('row'=>0,'column'=>1,'sticky'=>'n')
below=TkMenubutton.new(body){
text"Below"
underline0
direction'below'
relief'raised'
}
belowMenu=TkMenu.new(below){
tearoff0
add'command','label'=>"Below menu: first item",'command'=>proc{puts"\"You have selected the first item from the Below menu.\""}
add'command','label'=>"Below menu: second item",'command'=>proc{puts"\"You have selected the second item from the Below menu.\""}
}
below.menu(belowMenu)
below.grid('row'=>0,'column'=>1,'sticky'=>'n')
right=TkMenubutton.new(body){
text"Right"
underline0
direction'right'
relief'raised'
}
rightMenu=TkMenu.new(right){
tearoff0
add'command','label'=>"Right menu: first item",'command'=>proc{puts"\"You have selected the first item from the Left menu.\""}
add'command','label'=>"Right menu: second item",'command'=>proc{puts"\"You have selected the second item from the Right menu.\""}
}
right.menu(rightMenu)
right.grid('row'=>1,'column'=>0,'sticky'=>'w')
left=TkMenubutton.new(body){
text"Left"
underline0
direction'left'
relief'raised'
}
leftMenu=TkMenu.new(left){
tearoff0
add'command','label'=>"Left menu: first item",'command'=>proc{puts"\"You have selected the first item from the Left menu.\""}
add'command','label'=>"Left menu: second item",'command'=>proc{puts"\"You have selected the second item from the Left menu.\""}
}
left.menu(leftMenu)
left.grid('row'=>1,'column'=>2,'sticky'=>'e')
center=TkFrame.new(body){
grid('row'=>1,'column'=>1,'sticky'=>'news')
}
above=TkMenubutton.new(body){
text"Above"
underline0
direction'above'
relief'raised'
}
aboveMenu=TkMenu.new(above){
tearoff0
add'command','label'=>"Above menu: first item",'command'=>proc{puts"\"You have selected the first item from the Above menu.\""}
add'command','label'=>"Above menu: second item",'command'=>proc{puts"\"You have selected the second item from the Above menu.\""}
text"This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette."