diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/tk/sample/binstr_usage.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/tk/sample/binstr_usage.rb')
-rw-r--r-- | trunk/ext/tk/sample/binstr_usage.rb | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/trunk/ext/tk/sample/binstr_usage.rb b/trunk/ext/tk/sample/binstr_usage.rb deleted file mode 100644 index be8399ba51..0000000000 --- a/trunk/ext/tk/sample/binstr_usage.rb +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env ruby - -require "tk" - -TkMessage.new(:width=>360, :text=><<EOM).pack -This sample shows how to use a binary sequence between Ruby and Tk. \ -This reads the image data from the file as the binary sequence. - -To treat the difference of encodings between on Ruby and on Tk seamlessly, \ -Ruby/Tk converts the encoding of string arguments automatically. \ -I think it is comfortable for users on almost all situations. \ -However, when treats a binary sequence, the convert process makes troubles. - -Tk::BinaryString class (subclass of Tk::EncodedString class) is the class \ -to avoid such troubles. Please see the source code of this sample. \ -A Tk::BinaryString instance is used to create the image for the center button. -EOM - -ImgFile=[File.dirname(__FILE__), 'images','tcllogo.gif'].join(File::Separator) - -ph1 = TkPhotoImage.new(:file=>ImgFile) -p ph1.configinfo - -b_str = Tk::BinaryString(IO.read(ImgFile)) -p [b_str, b_str.encoding] - -ph2 = TkPhotoImage.new(:data=>b_str) -p ph2.configinfo -p ph2.data(:grayscale=>true) - -ph3 = TkPhotoImage.new(:palette=>256) -ph3.put(ph2.data) - -ph4 = TkPhotoImage.new() -ph4.put(ph2.data(:grayscale=>true)) - -#p [b_str.encoding, b_str.rb_encoding] - -f = TkFrame.new.pack -TkButton.new(:parent=>f, :image=>ph1, :command=>proc{exit}).pack(:side=>:left) -TkButton.new(:parent=>f, :image=>ph2, :command=>proc{exit}).pack(:side=>:left) -TkButton.new(:parent=>f, :image=>ph3, :command=>proc{exit}).pack(:side=>:left) -TkButton.new(:parent=>f, :image=>ph4, :command=>proc{exit}).pack(:side=>:left) - -Tk.mainloop |