From: Hidetoshi NAGAI Date: 2004-09-17T17:16:48+09:00 Subject: MultiTkIp class (Re: ruby-dev summary 24236-24254) Hi, From: "Takaaki Tateishi" Subject: ruby-dev summary 24236-24254 Date: Thu, 16 Sep 2004 04:17:20 +0900 Message-ID: <4487.210.194.45.215.1095275836.squirrel@210.194.45.215> > Also, he asked for someone to try multi-tk.rb and remote-tk.rb, since > those have been improved from the previous version. Please try the latest version of multi-tk.rb/remote-tk.rb. For example, the following script works properly. In it, * There are three IPs (ip1, ip2, and master). * A same procedure is running on each IP at same time. * The procedure does NOT have a IP parameter. However, * Each button is generated on the proper root window. * Each callback is running on each IP's safe-level. ( ip1's $SAFE==1, ip2's $SAFE==2, and master's $SAFE==0. ) * On slave IP, 'exit' function exits only the slave IP. And on master, exits all IPs and Ruby. Some (a little complex) tricks are used on the libraries. A slave IP can accept the script which works on a single IP without changes (except security reasons), and can be referd and controlled by a master IP. The libraries may be useful to create a test environment for Ruby/Tk scripts. ---------------------------------------------------- require 'multi-tk.rb' th = Thread.new{Tk.mainloop} TkLabel.new(:text=>'this is a primary master').pack ip1 = MultiTkIp.new_slave(:safe=>1) ip2 = MultiTkIp.new_slave(:safe=>2) cmd = proc{ require 'tk' TkButton.new(:text=>'b1: p self', :command=>proc{p self}).pack(:fill=>:x) sleep 0.5 TkButton.new(:text=>'b2: p $SAFE', :command=>proc{p $SAFE}).pack(:fill=>:x) sleep 0.5 TkButton.new(:text=>'b3: p MultiTkIp.ip_name', :command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x) sleep 0.5 TkButton.new(:text=>'EXIT', :command=>proc{exit}).pack(:fill=>:x) Tk.mainloop } Thread.new{ip1.eval_proc(cmd)} Thread.new{ip2.eval_proc(cmd)} cmd.call th.join ---------------------------------------------------- -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)