1#!/usr/bin/env ruby 2require 'tk' 3require 'tkextlib/iwidgets' 4 5helpvar = TkVariable.new 6viewmode = TkVariable.new 7 8mb = Tk::Iwidgets::Menubar.new 9mb.menubuttons = [ 10 [:menubutton, 'file', { 11 :text=>'File', :menu=>[ 12 [:command, 'new', {:label=>'New'}], 13 [:command, 'close', {:label=>'Close'}], 14 [:separator, 'sep1'], 15 [:command, 'quit', {:label=>'Quit'}] 16 ] 17 } 18 ], 19 [:menubutton, 'edit', {:text=>'Edit'}] 20] 21 22mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0) 23mb.add(:separator, '.edit.sep2') 24mb.add(:command, '.edit.cut', :label=>'Cut', :underline=>1) 25mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1) 26mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0) 27 28mb.add(:menubutton, '.options', :text=>'Options', :menu=>[ 29 [:radiobutton, 'byName', { 30 :variable=>viewmode, :value=>'NAME', :label=>'by Name'} 31 ], 32 [:radiobutton, 'byDate', { 33 :variable=>viewmode, :value=>'DATE', :label=>'by Date'} 34 ] 35 ]) 36 37mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[ 38 [:command, 'colors', {:label=>'Colors...'}], 39 [:command, 'fonts', {:label=>'Fonts...'}] 40 ]) 41 42mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true) 43 44Tk.mainloop 45