diff options
Diffstat (limited to 'ext/tk/sample')
-rw-r--r-- | ext/tk/sample/remote-ip_sample2.rb | 7 | ||||
-rw-r--r-- | ext/tk/sample/tkoptdb-safeTk.rb | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/ext/tk/sample/remote-ip_sample2.rb b/ext/tk/sample/remote-ip_sample2.rb index fcc34b73de..cc7f424489 100644 --- a/ext/tk/sample/remote-ip_sample2.rb +++ b/ext/tk/sample/remote-ip_sample2.rb @@ -40,8 +40,11 @@ ip.eval_proc{ } # setup controller-ip window -btns.each_with_index{|b, idx| - TkButton.new(:command=>proc{ip.eval_proc{b.flash}}, +btns.each_with_index{|btn, idx| + # The scope of the eval-block of 'eval_proc' method is different from + # the enternal. If you want to pass local values to the eval-block, + # use arguments of eval_proc method. They are passed to block-arguments. + TkButton.new(:command=>proc{ip.eval_proc(btn){|b| b.flash}}, :text=>"flash button-#{idx}", :padx=>10).pack(:padx=>10, :pady=>2) } diff --git a/ext/tk/sample/tkoptdb-safeTk.rb b/ext/tk/sample/tkoptdb-safeTk.rb index f6c3ca4ee7..4b0816d304 100644 --- a/ext/tk/sample/tkoptdb-safeTk.rb +++ b/ext/tk/sample/tkoptdb-safeTk.rb @@ -37,6 +37,18 @@ ip = MultiTkIp.new_safeTk{ print "ip.eval_proc{$SAFE} ==> ", ip.eval_proc{$SAFE}, "\n" +print "\ncall 'ip.wait_on_mainloop = false'\n" +print "If 'ip.wait_on_mainloop? == true', ", + "when 'mainloop' is called on 'ip.eval_proc', ", + "'ip.eval_proc' does't return while the root window exists.\n", + "If you want to avoid that, set wait_on_mainloop to false. ", + "Then the mainloop in the eval_proc returns soon ", + "and the following steps are evaluated. \n", + "If you hate the both of them, use 'ip.bg_eval_proc' or ", + "wrap 'ip.eval_proc' by a thread.\n" + +ip.wait_on_mainloop = false + ret = ip.eval_proc{ # When a block is given to 'eval_proc' method, # the block is evaluated on the IP's current safe level. @@ -46,7 +58,7 @@ ret = ip.eval_proc{ load file } -print "ip.eval_proc{}, which includes insecure operiation in the given block, returns an exception object: ", ret.inspect, "\n" +print "\nip.eval_proc{}, which includes insecure operiation in the given block, returns an exception object: ", ret.inspect, "\n" print "If a proc object is given, the proc is evaluated on the safe-level which is kept on the proc :: ip.eval_proc( proc{$SAFE} ) ==> ", ip.eval_proc(proc{$SAFE}), "\n" |