2004-05-21 22:23:59 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
require 'remote-tk'
|
2004-05-21 22:23:59 -04:00
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
# start sub-process
|
|
|
|
ip_name = 'remote_ip'
|
|
|
|
ip_list = TkWinfo.interps
|
2004-05-21 22:23:59 -04:00
|
|
|
fork{
|
|
|
|
exec "/usr/bin/env ruby -r tk -e \"Tk.appname('#{ip_name}');Tk.mainloop\""
|
|
|
|
}
|
2004-05-22 01:22:09 -04:00
|
|
|
sleep 1 until (app = (TkWinfo.interps - ip_list)[0]) && app =~ /^#{ip_name}/
|
2004-05-21 22:23:59 -04:00
|
|
|
p TkWinfo.interps
|
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
# create RemoteTkIp object
|
|
|
|
ip = RemoteTkIp.new(app)
|
2004-05-21 22:23:59 -04:00
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
# setup remote-ip window
|
2004-05-21 22:23:59 -04:00
|
|
|
btns = []
|
|
|
|
ip.eval_proc{
|
|
|
|
btns <<
|
|
|
|
TkButton.new(:command=>proc{
|
|
|
|
puts 'This procesure is on the controller-ip (Ruby-side)'
|
|
|
|
},
|
|
|
|
:text=>'print on controller-ip (Ruby-side)').pack(:fill=>:x)
|
|
|
|
|
|
|
|
btns <<
|
|
|
|
TkButton.new(:command=>
|
|
|
|
'puts {This procesure is on the remote-ip (Tk-side)}',
|
|
|
|
:text=>'print on remote-ip (Tk-side)').pack(:fill=>:x)
|
|
|
|
|
|
|
|
btns <<
|
|
|
|
TkButton.new(:command=>
|
|
|
|
'ruby {
|
|
|
|
puts "This procedure is on the remote-ip (Ruby-side)"
|
|
|
|
p Array.new(3,"ruby")
|
|
|
|
}',
|
|
|
|
:text=>'ruby cmd on the remote-ip').pack(:fill=>:x)
|
|
|
|
|
|
|
|
TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)
|
|
|
|
}
|
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
# setup controller-ip window
|
2004-05-21 22:23:59 -04:00
|
|
|
btns.each_with_index{|b, idx|
|
|
|
|
TkButton.new(:command=>proc{ip.eval_proc{b.flash}},
|
|
|
|
:text=>"flash button-#{idx}",
|
|
|
|
:padx=>10).pack(:padx=>10, :pady=>2)
|
|
|
|
}
|
|
|
|
|
|
|
|
TkButton.new(:command=>proc{exit}, :text=>'QUIT',
|
|
|
|
:padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
|
|
|
|
|
2004-05-22 01:22:09 -04:00
|
|
|
# start eventloop
|
2004-05-21 22:23:59 -04:00
|
|
|
Tk.mainloop
|