diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 6d8618a58a..74821f41c4 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1501,6 +1501,10 @@ class TkBindTag bind(*args, &b) if args != [] end + def name + @id + end + def to_eval @id end @@ -3283,9 +3287,23 @@ class TkWindow'BtnFrame'){|f| pack(:padx=>5, :pady=>5) TkButton.new(:parent=>f, :widgetname=>'hello'){ @@ -46,4 +47,36 @@ TkFrame.new(:class=>'BtnFrame'){|f| } } +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) + } + pack(:fill=>:x, :padx=>10, :pady=>10) + } + TkButton.new(:command=>proc{print "($SAFE=#{$SAFE}) : "; cmd.bye_msg; exit}, + :parent=>f, :widgetname=>'quit'){ + pack(:fill=>:x, :padx=>10, :pady=>10) + } +} + +# if unknown class, use default option values +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) + } + pack(:fill=>:x, :padx=>10, :pady=>10) + } + TkButton.new(:command=>proc{print "($SAFE=#{$SAFE}) : "; cmd.bye_msg; exit}, + :parent=>f, :widgetname=>'quit'){ + pack(:fill=>:x, :padx=>10, :pady=>10) + } +} + Tk.mainloop