7
7
TkLabel.new(:text=>'Sample of TkMenubutton').pack(:side=>:top)
13
TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
13
TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
14
14
:direction=>:right, :relief=>:raised){|mb|
15
15
menu TkMenu.new(:parent=>mb, :tearoff=>0){
16
add(:command, :label=>'Right menu: first item',
17
:command=>proc{print 'You have selected the first item' +
16
add(:command, :label=>'Right menu: first item',
17
:command=>proc{print 'You have selected the first item' +
18
18
" from the Right menu.\n"})
19
add(:command, :label=>'Right menu: second item',
20
:command=>proc{print 'You have selected the second item' +
19
add(:command, :label=>'Right menu: second item',
20
:command=>proc{print 'You have selected the second item' +
21
21
" from the Right menu.\n"})
23
23
pack(:side=>:left, :padx=>25, :pady=>25)
26
TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0,
26
TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0,
27
27
:direction=>:below, :relief=>:raised){|mb|
28
28
menu(TkMenu.new(:parent=>mb, :tearoff=>0){
29
add(:command, :label=>'Below menu: first item',
30
:command=>proc{print 'You have selected the first item' +
29
add(:command, :label=>'Below menu: first item',
30
:command=>proc{print 'You have selected the first item' +
31
31
" from the Below menu.\n"})
32
add(:command, :label=>'Below menu: second item',
33
:command=>proc{print 'You have selected the second item' +
32
add(:command, :label=>'Below menu: second item',
33
:command=>proc{print 'You have selected the second item' +
34
34
" from the Below menu.\n"})
36
36
pack(:side=>:left, :padx=>25, :pady=>25)
39
TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0,
39
TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0,
40
40
:direction=>:above, :relief=>:raised){|mb|
41
41
menu TkMenu.new(:parent=>mb, :tearoff=>0){
42
add(:command, :label=>'Above menu: first item',
43
:command=>proc{print 'You have selected the first item' +
42
add(:command, :label=>'Above menu: first item',
43
:command=>proc{print 'You have selected the first item' +
44
44
" from the Above menu.\n"})
45
add(:command, :label=>'Above menu: second item',
46
:command=>proc{print 'You have selected the second item' +
45
add(:command, :label=>'Above menu: second item',
46
:command=>proc{print 'You have selected the second item' +
47
47
" from the Above menu.\n"})
49
49
pack(:side=>:left, :padx=>25, :pady=>25)
52
TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0,
52
TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0,
53
53
:direction=>:left, :relief=>:raised){|mb|
54
54
menu(TkMenu.new(:parent=>mb, :tearoff=>0){
55
add(:command, :label=>'Left menu: first item',
56
:command=>proc{print 'You have selected the first item' +
55
add(:command, :label=>'Left menu: first item',
56
:command=>proc{print 'You have selected the first item' +
57
57
" from the Left menu.\n"})
58
add(:command, :label=>'Left menu: second item',
59
:command=>proc{print 'You have selected the second item' +
58
add(:command, :label=>'Left menu: second item',
59
:command=>proc{print 'You have selected the second item' +
60
60
" from the Left menu.\n"})
62
62
pack(:side=>:left, :padx=>25, :pady=>25)
66
66
############################
67
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
67
TkFrame.new(:borderwidth=>2, :relief=>:sunken,
68
68
:height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
69
69
############################
71
71
TkLabel.new(:text=>'Sample of TkOptionMenu').pack(:side=>:top)
73
colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
73
colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
74
74
Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet)
79
b1 = TkOptionMenubutton .
80
new(:parent=>f, :values=>%w(one two three)) .
79
b1 = TkOptionMenubutton .
80
new(:parent=>f, :values=>%w(one two three)) .
81
81
pack(:side=>:left, :padx=>25, :pady=>25)
83
83
b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB|