require "tk"
if __FILE__ == $0 || !TkCore::INTERP.safe?
if ENV['LANG'] =~ /^ja/
TkOptionDB.read_with_encoding(File.expand_path('resource.ja',
File.dirname(__FILE__)),
'utf-8')
else
TkOptionDB.readfile(File.expand_path('resource.en',
File.dirname(__FILE__)))
end
end
cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) {
class << self
def __check_proc_string__(str)
print "($SAFE=#{$SAFE} >>>) check!! str.tainted?::#{str.tainted?}"
str.untaint
print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): "
str
end
private :__check_proc_string__
end
}
TkFrame.new(:class=>'BtnFrame'){|f|
pack(:padx=>5, :pady=>5)
TkButton.new(:parent=>f, :widgetname=>'hello'){
command proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.show_msg(TkOptionDB.inspect)
print "(<<< $SAFE=#{$SAFE})"
}
pack(:fill=>:x, :padx=>10, :pady=>10)
}
TkButton.new(:command=>proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.bye_msg
print "(<<< $SAFE=#{$SAFE} ) : "
exit
},
:parent=>f, :widgetname=>'quit'){
pack(:fill=>:x, :padx=>10, :pady=>10)
}
}
class BtnFrame < TkFrame; end
BtnFrame.new{|f|
pack(:padx=>5, :pady=>5)
TkButton.new(:parent=>f, :widgetname=>'hello'){
command proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.show_msg(TkOptionDB.inspect)
print "(<<< $SAFE=#{$SAFE})"
}
pack(:fill=>:x, :padx=>10, :pady=>10)
}
TkButton.new(:command=>proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.bye_msg
print "(<<< $SAFE=#{$SAFE})"
exit
},
:parent=>f, :widgetname=>'quit'){
pack(:fill=>:x, :padx=>10, :pady=>10)
}
}
TkFrame.new(:class=>'BtnFrame2'){|f|
pack(:padx=>5, :pady=>5)
TkButton.new(:parent=>f, :widgetname=>'hello'){
command proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.show_msg(TkOptionDB.inspect)
print "(<<< $SAFE=#{$SAFE})"
}
pack(:fill=>:x, :padx=>10, :pady=>10)
}
TkButton.new(:command=>proc{
print "($SAFE=#{$SAFE} >>>) : "
cmd.bye_msg
print "(<<< $SAFE=#{$SAFE})"
exit
},
:parent=>f, :widgetname=>'quit'){
pack(:fill=>:x, :padx=>10, :pady=>10)
}
}
Tk.mainloop