Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main > by-pkgid > e2a5fef11a7f55d2dc803b8b7498c8e5 > files > 674

ruby-tcltk-1.8.5-31.el5_9.x86_64.rpm

#!/usr/bin/env ruby
require 'tk'
require 'tkextlib/iwidgets'

helpvar = TkVariable.new
viewmode = TkVariable.new

mb = Tk::Iwidgets::Menubar.new
mb.menubuttons = [
  [:menubutton, 'file', {
      :text=>'File', :menu=>[
        [:command,   'new',   {:label=>'New'}], 
        [:command,   'close', {:label=>'Close'}], 
        [:separator, 'sep1'], 
        [:command,   'quit',  {:label=>'Quit'}]
      ]
    }
  ], 
  [:menubutton, 'edit', {:text=>'Edit'}]
]

mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0)
mb.add(:separator, '.edit.sep2')
mb.add(:command, '.edit.cut',   :label=>'Cut',   :underline=>1)
mb.add(:command, '.edit.copy',  :label=>'Copy',  :underline=>1)
mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0)

mb.add(:menubutton, '.options', :text=>'Options', :menu=>[
         [:radiobutton, 'byName', {
             :variable=>viewmode, :value=>'NAME', :label=>'by Name'}
         ], 
         [:radiobutton, 'byDate', {
             :variable=>viewmode, :value=>'DATE', :label=>'by Date'}
         ]
       ])

mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[
         [:command, 'colors', {:label=>'Colors...'}], 
         [:command, 'fonts',  {:label=>'Fonts...'}]
       ])

mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true)

Tk.mainloop