1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/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
|