diff options
Diffstat (limited to 'ext/tk/sample/demos-jp/widget')
-rw-r--r-- | ext/tk/sample/demos-jp/widget | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 60ec5b5e96..8eb699e513 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -814,6 +814,12 @@ def showCode1(demo) TkLabel.new(f,'text'=>' pos:').pack('side'=>'left') posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left') + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x') if $tk_version =~ /^4\.[01]/ @@ -858,10 +864,21 @@ def showCode1(demo) TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0) } end + + btag = TkBindTag.new + + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') + + btags = $code_text.bindtags + btags.insert(btags.index($code_text.class) + 1, btag) + $code_text.bindtags = btags + else $code_window.deiconify $code_window.raise end + $code_window.title("Demo code: #{file}") $code_window.iconname(file) # fid = open(file, 'r') @@ -873,22 +890,7 @@ def showCode1(demo) #$code_text.set_insert('1.0') TkTextMarkInsert.new($code_text,'1.0') - btag = TkBindTag.new - - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') - - btags = $code_text.bindtags - btags.insert(btags.index($code_text.class) + 1, btag) - $code_text.bindtags = btags - - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end @@ -917,6 +919,12 @@ def showCode2(demo) TkLabel.new(lf, :text=>' pos:').pack(:side=>:left) posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left) + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + #b_dis = TkButton.new(bf, :text=>'λ²ò', :default=>:active, b_dis = TkButton.new(bf, :text=>'ÊĤ¸¤ë', :default=>:active, :command=>proc{ @@ -948,6 +956,16 @@ def showCode2(demo) $code_window.bindinfo('Return').each{|cmd, arg| $code_window.bind_append('Escape', cmd, arg) } + + btag = TkBindTag.new + + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') + + btags = $code_text.bindtags + btags.insert(btags.index($code_text.class) + 1, btag) + $code_text.bindtags = btags + else $code_window.deiconify $code_window.raise @@ -960,22 +978,7 @@ def showCode2(demo) $code_text.insert('1.0', fid.read) TkTextMarkInsert.new($code_text,'1.0') - btag = TkBindTag.new - - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') - - btags = $code_text.bindtags - btags.insert(btags.index($code_text.class) + 1, btag) - $code_text.bindtags = btags - - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end |