From: Hidetoshi NAGAI Date: 2003-08-02T09:23:20+09:00 Subject: [ruby-dev:21066] patch for tkentry.rb 永井@知能.九工大です. ネットワークの不調(多分)のために CVS に接続できず, commit したくてもできないでいます. このメールも届くかどうかわかりませんが, もし届きましたら,添付のパッチの適用をお願いできないでしょうか. 特に tkentry.rb の修正は,「なんでこんなバグが今に至るまで 報告されていないのか」というようなものですし, demo のパッチも,一部機能拡張を含んではいますが ほとんどがそのデモを正常に動作させるためのものです. これを適用しなければエラーを出してしまって動きません. ご迷惑をおかけしますが,よろしくお願いします. # 一人だとなかなかすべてには目が行き届きませんね.(;_;) -----<修正内容>------------------------- * (bug fix) TkEntry#delete * (bug fix) some widget demos * support == ( "coerce TkVariable" add to the TODO list :-) ) ---------------------------------------- diff -ur ../../../ruby-1.8.0-preview7/ext/tk/lib/tk.rb ./lib/tk.rb --- ../../../ruby-1.8.0-preview7/ext/tk/lib/tk.rb 2003-08-01 16:08:43.000000000 +0900 +++ ./lib/tk.rb 2003-08-02 07:04:07.000000000 +0900 @@ -1839,6 +1839,10 @@ string(value).to_s end + def to_symbol + value.intern + end + def inspect format "#", @id end @@ -1849,6 +1853,8 @@ self.equal?(other) when String self.to_s == other + when Symbol + self.to_symbol == other when Integer self.to_i == other when Float diff -ur ../../../ruby-1.8.0-preview7/ext/tk/lib/tkentry.rb ./lib/tkentry.rb --- ../../../ruby-1.8.0-preview7/ext/tk/lib/tkentry.rb 2003-07-30 16:17:59.000000000 +0900 +++ ./lib/tkentry.rb 2003-08-02 05:11:50.000000000 +0900 @@ -158,7 +158,7 @@ self end def delete(first, last=None) - tk_send 'insert', first, last + tk_send 'delete', first, last self end def mark(pos) diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/rmt ./sample/demos-en/rmt --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/rmt 2003-08-01 05:52:37.000000000 +0900 +++ ./sample/demos-en/rmt 2003-08-02 05:54:55.000000000 +0900 @@ -53,10 +53,8 @@ # Create text window and scrollbar. - @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {|t| - TkScrollbar.new(root, 'command'=>proc{|*args| t.yview *args}) { - pack('side'=>'right', 'fill'=>'both') - } + @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) { + yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')}) pack('side'=>'left') } @@ -247,13 +245,18 @@ rescue end TkWinfo.interps.sort.each{|ip| - if Tk.appsend(ip, false, 'info commands ruby') == "" - mode = 'Tcl' - else - mode = 'Ruby' + begin + if Tk.appsend(ip, false, 'info commands ruby') == "" + mode = 'Tcl' + else + mode = 'Ruby' + end + menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), + 'command'=>proc{win.newApp ip, mode}) + rescue + menu.add('command', 'label'=>format("%s (unknown Tk)", ip), + 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled') end - menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), - 'command'=>proc{win.newApp ip, mode}) } menu.add('command', 'label'=>format("local (Ruby/Tk)"), 'command'=>proc{win.newApp 'local', 'Ruby'}) diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/rolodex ./sample/demos-en/rolodex --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/rolodex 2003-08-01 05:52:37.000000000 +0900 +++ ./sample/demos-en/rolodex 2003-08-02 06:23:06.000000000 +0900 @@ -4,7 +4,7 @@ # This script is a part of Tom LaStrange's rolodex # # Copyright (C) 1998 by Takaaki Tateishi -# Time-stamp: "98/07/20 12:00:02 ttate" +# Time-stamp: "03/08/02 06:23:06 nagai" # require "tk" @@ -176,8 +176,8 @@ class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -314,7 +314,7 @@ EOF $helpTopics["version"] = < -# Time-stamp: "98/07/20 12:00:36 ttate" +# Time-stamp: "03/08/02 06:23:32 nagai" # require "tk" @@ -198,8 +198,8 @@ class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -318,7 +318,7 @@ EOF $helpTopics["バージョン情報"] = < proc{changeColorSpace(:hsb)} add "separator" add "radio", - "label" => "Qutomatic updates", + "label" => "Automatic updates", "variable" => $autoUpdate, "value" => "1", "underline" => "0" @@ -367,7 +373,7 @@ "relief"=>"sunken", "borderwidth"=>"2", "exportselection"=>"false") - @scroll.command(proc{|*args| @names.yview *args}) + @scroll.command(proc{|*args| @names.yview(*args)}) @names.bind("Double-1",proc{ tc_loadNamedColor(@names.get(@names.curselection))}) @names.pack("side"=>"left") @@ -490,8 +496,8 @@ class TkColor"top", "fill"=>"x") diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/timer ./sample/demos-en/timer --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-en/timer 2003-08-01 05:52:37.000000000 +0900 +++ ./sample/demos-en/timer 2003-08-02 07:38:16.000000000 +0900 @@ -80,12 +80,28 @@ class ButtonFrame < TkFrame def initialize(parent=nil,keys=nil) super(parent,keys) +=begin @stop = TkButton.new(self, 'text'=>'Stop', 'command'=>proc{timer_stop}) @start = TkButton.new(self, 'text'=>'Start', 'command'=>proc{timer_start}) +=end + @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled) + @start = TkButton.new(self, :text=>'Start', :state=>:normal) + + @stop.command proc{ + timer_stop + @start.state(:normal) + @stop.state(:disabled) + } + @start.command proc{ + timer_start + @stop.state(:normal) + @start.state(:disabled) + } + @reset = TkButton.new(self, 'text'=>'Reset', 'command'=>proc{timer_reset}) @@ -99,8 +115,8 @@ class Timer < TkRoot attr_reader :countframe - def initialize - super + def initialize(*args) + super(*args) @countframe = CountFrame.new(self) @buttonframe = ButtonFrame.new(self) for f in [@buttonframe,@countframe] diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/ixset ./sample/demos-jp/ixset --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/ixset 2003-08-01 05:52:38.000000000 +0900 +++ ./sample/demos-jp/ixset 2003-08-02 05:11:38.000000000 +0900 @@ -166,7 +166,7 @@ l = TkLabel.new(bell, 'text'=>'Bell Settings') @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200, 'tickinterval'=>20, 'orient'=>'horizontal', - 'label'=>"Volume (%)") + 'label'=>"Volume (%)") f = TkFrame.new(bell) @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6) diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/rmt ./sample/demos-jp/rmt --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/rmt 2003-08-01 05:52:38.000000000 +0900 +++ ./sample/demos-jp/rmt 2003-08-02 05:54:46.000000000 +0900 @@ -53,10 +53,8 @@ # Create text window and scrollbar. - @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {|t| - TkScrollbar.new(root, 'command'=>proc{|*args| t.yview *args}) { - pack('side'=>'right', 'fill'=>'both') - } + @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) { + yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')}) pack('side'=>'left') } @@ -247,13 +245,18 @@ rescue end TkWinfo.interps.sort.each{|ip| - if Tk.appsend(ip, false, 'info commands ruby') == "" - mode = 'Tcl' - else - mode = 'Ruby' + begin + if Tk.appsend(ip, false, 'info commands ruby') == "" + mode = 'Tcl' + else + mode = 'Ruby' + end + menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), + 'command'=>proc{win.newApp ip, mode}) + rescue + menu.add('command', 'label'=>format("%s (unknown Tk)", ip), + 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled') end - menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip), - 'command'=>proc{win.newApp ip, mode}) } menu.add('command', 'label'=>format("local (Ruby/Tk)"), 'command'=>proc{win.newApp 'local', 'Ruby'}) diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/rolodex ./sample/demos-jp/rolodex --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/rolodex 2003-08-01 05:52:38.000000000 +0900 +++ ./sample/demos-jp/rolodex 2003-08-02 06:23:12.000000000 +0900 @@ -4,7 +4,7 @@ # This script is a part of Tom LaStrange's rolodex # # Copyright (C) 1998 by Takaaki Tateishi -# Time-stamp: "98/07/20 12:00:02 ttate" +# Time-stamp: "03/08/02 06:23:12 nagai" # require "tk" @@ -176,8 +176,8 @@ class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -314,7 +314,7 @@ EOF $helpTopics["version"] = < -# Time-stamp: "98/07/20 12:00:36 ttate" +# Time-stamp: "03/08/02 06:23:21 nagai" # require "tk" @@ -185,8 +185,8 @@ class Rolodex < TkRoot attr_reader :frame, :buttons, :menu - def initialize - super + def initialize(*args) + super(*args) @frame = RolodexFrame.new(self) @frame.pack("side"=>"top", "fill"=>"y", @@ -305,7 +305,7 @@ EOF $helpTopics["バージョン情報"] = < proc{changeColorSpace(:hsb)} add "separator" add "radio", - "label" => "Qutomatic updates", + "label" => "Automatic updates", "variable" => $autoUpdate, "value" => "1", "underline" => "0" @@ -367,7 +373,7 @@ "relief"=>"sunken", "borderwidth"=>"2", "exportselection"=>"false") - @scroll.command(proc{|*args| @names.yview *args}) + @scroll.command(proc{|*args| @names.yview(*args)}) @names.bind("Double-1",proc{ tc_loadNamedColor(@names.get(@names.curselection))}) @names.pack("side"=>"left") @@ -490,8 +496,8 @@ class TkColor"top", "fill"=>"x") diff -ur ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/timer ./sample/demos-jp/timer --- ../../../ruby-1.8.0-preview7/ext/tk/sample/demos-jp/timer 2003-08-01 05:52:38.000000000 +0900 +++ ./sample/demos-jp/timer 2003-08-02 07:38:06.000000000 +0900 @@ -80,12 +80,28 @@ class ButtonFrame < TkFrame def initialize(parent=nil,keys=nil) super(parent,keys) +=begin @stop = TkButton.new(self, 'text'=>'Stop', 'command'=>proc{timer_stop}) @start = TkButton.new(self, 'text'=>'Start', 'command'=>proc{timer_start}) +=end + @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled) + @start = TkButton.new(self, :text=>'Start', :state=>:normal) + + @stop.command proc{ + timer_stop + @start.state(:normal) + @stop.state(:disabled) + } + @start.command proc{ + timer_start + @stop.state(:normal) + @start.state(:disabled) + } + @reset = TkButton.new(self, 'text'=>'Reset', 'command'=>proc{timer_reset}) @@ -99,8 +115,8 @@ class Timer < TkRoot attr_reader :countframe - def initialize - super + def initialize(*args) + super(*args) @countframe = CountFrame.new(self) @buttonframe = ButtonFrame.new(self) for f in [@buttonframe,@countframe] -- 永井 秀利 (九工大 知能情報) nagai@ai.kyutech.ac.jp