1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/demos-jp/clrpick.rb

76 lines
1.9 KiB
Ruby
Raw Normal View History

#
# widget demo prompts the user to select a color (called by 'widget')
#
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if defined?($clrpick_demo) && $clrpick_demo
$clrpick_demo.destroy
$clrpick_demo = nil
end
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$clrpick_demo = TkToplevel.new {|w|
title("Color Selection Dialogs")
iconname("colors")
positionWindow(w)
}
# label <20><><EFBFBD><EFBFBD>
TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
'text'=>"<EFBFBD>ʲ<EFBFBD><EFBFBD>Υܥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>򲡤<EFBFBD><EFBFBD>ơ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>طʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򤷤Ʋ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>").pack('side'=>'top')
# frame <20><><EFBFBD><EFBFBD>
TkFrame.new($clrpick_demo) {|frame|
TkButton.new(frame) {
#text 'λ<><CEBB>'
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
command proc{
tmppath = $clrpick_demo
$clrpick_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
command proc{showCode 'clrpick'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# button <20><><EFBFBD><EFBFBD>
TkButton.new($clrpick_demo, 'text'=>'<27>طʿ<D8B7><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ...') {|b|
command(proc{setColor $clrpick_demo, b, 'background',
['background', 'highlightbackground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
TkButton.new($clrpick_demo, 'text'=>'<27><><EFBFBD>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ...') {|b|
command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
}
def setColor(w,button,name,options)
w.grab
initialColor = button[name]
color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w,
'initialcolor'=>initialColor)
if color != ""
setColor_helper(w,options,color)
end
w.grab('release')
end
def setColor_helper(w, options, color)
options.each{|opt|
begin
w[opt] = color
rescue
end
}
TkWinfo.children(w).each{|child|
setColor_helper child, options, color
}
end