summaryrefslogtreecommitdiff
path: root/ext/tk/sample
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-21 20:45:27 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-21 20:45:27 +0000
commitea710f0dcad908c46d3e58291db45ea3738991da (patch)
tree577835e82903eb19d713f91c830ef62bd6e08f40 /ext/tk/sample
parentdfdffdd9a3eb2c56a8913277d00a7598aaf2aa16 (diff)
* ext/tk/lib/tk.rb: add Tk.appsend_deny and improve Tk.rb_appsend
* ext/tk/lib/tk.rb, ext/tk/lib/tk/*.rb : replace obj.send() -> obj.__send__() * ext/tk/lib/remote-tk.rb: add a new library which create an object to control a Tk interpreter on the other process git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
-rw-r--r--ext/tk/sample/remote-ip_sample.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/tk/sample/remote-ip_sample.rb b/ext/tk/sample/remote-ip_sample.rb
new file mode 100644
index 0000000000..3a2dbe4852
--- /dev/null
+++ b/ext/tk/sample/remote-ip_sample.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'remote-tk'
+
+puts <<EOM
+This sample controls the other Tk interpreter (Ruby/Tk, Tcl/Tk, and so on)
+which running on the other process. For this purpose, Ruby/Tk uses Tcl/Tk's
+'send' command. Availability of the command depends on your GUI environment.
+If this script doesn't work, please check your environment (see Tcl/Tk FAQ).
+EOM
+#'
+
+unless (wish = TkWinfo.interps.find{|ip| ip =~ /^wish/})
+ puts ''
+ puts 'Please start "wish" (Tcl/Tk shell) before running this sample script.'
+ exit 1
+end
+
+ip = RemoteTkIp.new(wish)
+ip.eval_proc{TkButton.new(:command=>proc{puts 'This procesure is on the controller-ip (Rubh/Tk)'}, :text=>'print on Ruby/Tk (controller-ip)').pack(:fill=>:x)}
+ip.eval_proc{TkButton.new(:command=>'puts {This procesure is on the remote-ip (wish)}', :text=>'print on wish (remote-ip)').pack(:fill=>:x)}
+
+# If your remote-ip is Ruby/Tk, you can control the remote Ruby by
+# 'ruby' or 'ruby_eval' or 'ruby_cmd' on the Tk interpreter.
+if ip.is_rubytk?
+ ip.eval_proc{TkButton.new(:command=>'ruby {p 111; p Array.new(3,"ruby")}', :text=>'ruby cmd on the remote-ip').pack(:fill=>:x)}
+end
+
+ip.eval_proc{TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)}
+
+TkButton.new(:command=>proc{exit}, :text=>'QUIT',
+ :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
+
+Tk.mainloop