diff options
| author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-04 03:56:00 +0000 |
|---|---|---|
| committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-10-04 03:56:00 +0000 |
| commit | 75eec4c054e6bc8bd12c6a401d103c5a8de4d961 (patch) | |
| tree | 790b6e523c308dc06dd9e6a3ab007f6988554a3c /ext/tk/sample | |
| parent | 69478e941a5bd38347607ab494b761a419f3dfcb (diff) | |
| download | ruby-75eec4c054e6bc8bd12c6a401d103c5a8de4d961.tar.gz ruby-75eec4c054e6bc8bd12c6a401d103c5a8de4d961.tar.xz ruby-75eec4c054e6bc8bd12c6a401d103c5a8de4d961.zip | |
* ext/tk/lib/tk/image.rb: bug fix
* ext/tk/lib/tk/optiondb.rb: support definition of command resources on widgets
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
| -rw-r--r-- | ext/tk/sample/cmd_res_test.rb | 17 | ||||
| -rw-r--r-- | ext/tk/sample/cmd_resource | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/ext/tk/sample/cmd_res_test.rb b/ext/tk/sample/cmd_res_test.rb new file mode 100644 index 000000000..9bbb2044c --- /dev/null +++ b/ext/tk/sample/cmd_res_test.rb @@ -0,0 +1,17 @@ +require 'tk' +TkOptionDB.readfile(File.expand_path('cmd_resource', + File.dirname(__FILE__))) +f = TkFrame.new(:class=>'BtnFrame').pack +b = TkButton.new(:parent=>f, :widgetname=>'hello').pack +cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3) +cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, cmd1) +cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, b) +cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3){ + def self.__check_proc_string__(str) + "{|arg| print [arg, $SAFE].inspect, ': '; Proc.new#{str}.call(arg)}" + end +} +cmd1.show_msg('cmd1') +cmd2.show_msg('cmd2') +cmd3.show_msg('cmd3') +cmd4.show_msg('cmd4') diff --git a/ext/tk/sample/cmd_resource b/ext/tk/sample/cmd_resource new file mode 100644 index 000000000..9cc491554 --- /dev/null +++ b/ext/tk/sample/cmd_resource @@ -0,0 +1,5 @@ +*BtnFrame.hello.text: HELLO +*BtnFrame.hello.command: ruby {puts "Hello World!!"} +*BTN_CMD.show_msg: {|arg| print "Hello, #{arg}!!\n"} +*hello.show_msg: {|arg| print "Hello, Hello, #{arg}!!\n"} +*hello.ZZZ.show_msg: {|arg| print "Hello, Hello, ZZZ:#{arg}!!\n"} |
