diff options
| author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-25 14:40:32 +0000 |
|---|---|---|
| committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-25 14:40:32 +0000 |
| commit | 925d4842418e360c0642e1f8b5bc75e25a81a77e (patch) | |
| tree | 8da67d71873fd5d0371809db0e3471b72a3f97ec /ext/tk/sample | |
| parent | 9f203a99f90ec3d0d1a3cbd81adee8665ca427b2 (diff) | |
| download | ruby-925d4842418e360c0642e1f8b5bc75e25a81a77e.tar.gz ruby-925d4842418e360c0642e1f8b5bc75e25a81a77e.tar.xz ruby-925d4842418e360c0642e1f8b5bc75e25a81a77e.zip | |
tk.rb :
* add and modify :
TkWidget.database_class, TkWidget.database_classname,
TkWidget#database_class, TkWidget#database_classname
* instances of a subclass of TkToplevel or TkFrame are
created with ":class=>subclass" option as default.
For example, the followings create similar objects.
(1) TkFrame.new(:class=>'XXX')
(2) class XXX < TkFrame; end; XXX.new
sample/tkoptdb.rb :
* add new part of sample script
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
| -rw-r--r-- | ext/tk/sample/tkoptdb.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/tk/sample/tkoptdb.rb b/ext/tk/sample/tkoptdb.rb index 930985dc2..066bd9501 100644 --- a/ext/tk/sample/tkoptdb.rb +++ b/ext/tk/sample/tkoptdb.rb @@ -31,6 +31,7 @@ cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 2) { end } +# following two frame widgets use same database entry TkFrame.new(:class=>'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 |
