mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
115 lines
3.8 KiB
Ruby
115 lines
3.8 KiB
Ruby
|
# radio3.rb
|
|||
|
#
|
|||
|
# This demonstration script creates a toplevel window containing
|
|||
|
# several radiobutton widgets.
|
|||
|
#
|
|||
|
# radiobutton widget demo (called by 'widget')
|
|||
|
#
|
|||
|
|
|||
|
# toplevel widget
|
|||
|
if defined?($radio3_demo) && $radio3_demo
|
|||
|
$radio3_demo.destroy
|
|||
|
$radio3_demo = nil
|
|||
|
end
|
|||
|
|
|||
|
# demo toplevel widget
|
|||
|
$radio3_demo = TkToplevel.new {|w|
|
|||
|
title("Radiobutton Demonstration 3")
|
|||
|
iconname("radio3")
|
|||
|
positionWindow(w)
|
|||
|
}
|
|||
|
|
|||
|
# label
|
|||
|
msg = TkLabel.new($radio3_demo) {
|
|||
|
font $font
|
|||
|
wraplength '5i'
|
|||
|
justify 'left'
|
|||
|
text '<27><><EFBFBD>ˤ<EFBFBD>3<EFBFBD>ĤΥ饸<CEA5><E9A5B8><EFBFBD>ܥ<EFBFBD><DCA5>롼<F3A5B0A5>פ<EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD><EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5>롼<EFBFBD>פ<EFBFBD>°<EFBFBD><C2B0><EFBFBD>뤹<EFBFBD>٤ƤΥܥ<CEA5><DCA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܥ<EFB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D><DCA5><EFBFBD><EFBFBD>ξ<EFBFBD><CEBE>֤ϸ<D6A4><CFB8>Τ褦<CEA4>˸ġ<CBB8><C4A1>Υܥ<CEA5><DCA5><EFBFBD><EFBFBD><EFBFBD>on/off<66><66><EFBFBD>֤<D6A4><F2BCA8A4>褦<EFBFBD>ˤʤ<CBA4><CAA4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߤ<EFBFBD><DFA4>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>ͤ<CDA4><F2B8ABA4>ˤϡ<CBA4><CFA1>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD>ȡץܥ<D7A5><DCA5><EFBFBD><EFBFBD><EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|||
|
}
|
|||
|
msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew')
|
|||
|
|
|||
|
# variable
|
|||
|
size = TkVariable.new
|
|||
|
color = TkVariable.new
|
|||
|
align = TkVariable.new
|
|||
|
|
|||
|
# frame
|
|||
|
TkFrame.new($radio3_demo) {|frame|
|
|||
|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
|
|||
|
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
|
|||
|
TkGrid('x',
|
|||
|
TkButton.new(frame, :text=>'<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>',
|
|||
|
:image=>$image['view'], :compound=>:left,
|
|||
|
:command=>proc{
|
|||
|
showVars($radio3_demo, ['size', size],
|
|||
|
['color', color], ['compound', align])
|
|||
|
}),
|
|||
|
TkButton.new(frame, :text=>'<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>',
|
|||
|
:image=>$image['view'], :compound=>:left,
|
|||
|
:command=>proc{showCode 'radio3'}),
|
|||
|
TkButton.new(frame, :text=>'<27>Ĥ<EFBFBD><C4A4><EFBFBD>',
|
|||
|
:image=>$image['delete'], :compound=>:left,
|
|||
|
:command=>proc{
|
|||
|
tmppath = $radio3_demo
|
|||
|
$radio3_demo = nil
|
|||
|
$showVarsWin[tmppath.path] = nil
|
|||
|
tmppath.destroy
|
|||
|
}),
|
|||
|
:padx=>4, :pady=>4)
|
|||
|
frame.grid_columnconfigure(0, :weight=>1)
|
|||
|
TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew')
|
|||
|
}
|
|||
|
|
|||
|
# frame
|
|||
|
f_left = TkLabelFrame.new($radio3_demo, 'text'=>'ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
|
|||
|
'pady'=>2, 'padx'=>2)
|
|||
|
f_mid = TkLabelFrame.new($radio3_demo, 'text'=>'<27><>',
|
|||
|
'pady'=>2, 'padx'=>2)
|
|||
|
f_right = TkLabelFrame.new($radio3_demo, 'text'=>'<27>ӥåȥޥå<DEA5><C3A5><EFBFBD><EFBFBD><EFBFBD>',
|
|||
|
'pady'=>2, 'padx'=>2)
|
|||
|
f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
|
|||
|
f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
|
|||
|
f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
|
|||
|
|
|||
|
TkButton.new($radio3_demo, 'text'=>'<27>ȥ饤<C8A5><E9A5A4><EFBFBD>ơ<EFBFBD><C6A1><EFBFBD>',
|
|||
|
'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
|
|||
|
grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
|
|||
|
}
|
|||
|
|
|||
|
# radiobutton
|
|||
|
[10, 12, 14, 18, 24].each {|sz|
|
|||
|
TkRadioButton.new(f_left) {
|
|||
|
text "<EFBFBD>ݥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #{sz}"
|
|||
|
variable size
|
|||
|
relief 'flat'
|
|||
|
value sz
|
|||
|
tristatevalue 'multi'
|
|||
|
}.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
|
|||
|
}
|
|||
|
|
|||
|
['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
|
|||
|
TkRadioButton.new(f_mid) {
|
|||
|
text col
|
|||
|
variable color
|
|||
|
relief 'flat'
|
|||
|
value col.downcase
|
|||
|
anchor 'w'
|
|||
|
tristatevalue 'multi'
|
|||
|
command proc{f_mid.fg(color.value)}
|
|||
|
}.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
|
|||
|
}
|
|||
|
|
|||
|
label = TkLabel.new(f_right, 'text'=>'<27><><EFBFBD>٥<EFBFBD>', 'bitmap'=>'questhead',
|
|||
|
'compound'=>'left')
|
|||
|
label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
|
|||
|
label.height(TkWinfo.reqheight(label))
|
|||
|
a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
|
|||
|
TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
|
|||
|
'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7,
|
|||
|
'command'=>proc{label.compound(align.value)})
|
|||
|
}
|
|||
|
|
|||
|
Tk.grid('x', a_btn[0])
|
|||
|
Tk.grid(a_btn[1], label, a_btn[2])
|
|||
|
Tk.grid('x', a_btn[3])
|