summaryrefslogtreecommitdiff
path: root/ext/tk/sample/demos-jp/widget
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-13 15:19:16 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-13 15:19:16 +0000
commit2150e7f5a1b65ac63ec120939baa5d6459e2c946 (patch)
treea7afd4dad48d0877e64803c2ccb6fe798dea85c9 /ext/tk/sample/demos-jp/widget
parenteb9bb3786afa1fbf2add2cdf0900cc5ad23bad91 (diff)
* ext/tk/lib/tk/timer.rb (TkRTTimer): correct calculation of offset
value. get a little better accuracy. * ext/tk/sample/demos-en/widget: use a binding with no local variables when eval a sample script. * ext/tk/sample/demos-en/bind.rb: ditto. * ext/tk/sample/demos-en/tcolor: ditto. * ext/tk/sample/demos-jp/widget: ditto. * ext/tk/sample/demos-jp/bind.rb: ditto. * ext/tk/sample/demos-jp/tcolor: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample/demos-jp/widget')
-rw-r--r--ext/tk/sample/demos-jp/widget34
1 files changed, 29 insertions, 5 deletions
diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget
index 7c559d2a09..ec9a07d778 100644
--- a/ext/tk/sample/demos-jp/widget
+++ b/ext/tk/sample/demos-jp/widget
@@ -11,7 +11,7 @@ require 'tk'
$demo_dir = File.dirname($0)
# root の生成
-$root = TkRoot.new{title "Widget Demonstration"}
+$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
# tk バージョンの取得
$tk_version = Tk::TK_VERSION
@@ -551,7 +551,27 @@ else # ver >= 8.4
alias showVars showVars2
end
+def _null_binding
+ # binding
+ Module.new.instance_eval{binding}
+end
+private :_null_binding
+
# テキスト上での click に対する動作
+def invoke(txt, idx)
+ tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+
+ cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update
+ eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding)
+ Tk.update
+ txt.cursor(cursor)
+
+ $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
+end
+=begin
def invoke (txt, idx)
tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
return unless tag
@@ -567,6 +587,7 @@ def invoke (txt, idx)
$tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
end
+=end
# 状態表示
def showStatus (txt, index)
@@ -601,7 +622,7 @@ def showCode1(demo)
}.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
TkButton.new(f) {
text "再実行"
- command proc{eval($code_text.get('1.0','end'))}
+ command proc{eval($code_text.get('1.0','end'), _null_binding)}
}.pack('side'=>'left', 'expand'=>'yes', 'pady'=>2)
# f.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x')
f.pack('side'=>'bottom', 'fill'=>'x')
@@ -694,7 +715,9 @@ def showCode2(demo)
:command=>proc{printCode($code_text, file)},
:image=>$image['print'], :compound=>:left)
b_run = TkButton.new(bf, :text=>'再実行',
- :command=>proc{eval($code_text.get('1.0','end'))},
+ :command=>proc{
+ eval($code_text.get('1.0','end'), _null_binding)
+ },
:image=>$image['refresh'], :compound=>:left)
TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
@@ -819,7 +842,7 @@ end
#
def aboutBox
Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
- 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.3-jp\n\n" +
+ 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.4-jp\n\n" +
"based on demos of Tk8.1 -- 8.5 " +
"( Copyright:: " +
"(c) 1996-1997 Sun Microsystems, Inc. / " +
@@ -840,7 +863,8 @@ ARGV.each{|cmd|
if cmd =~ /(.*).rb/
cmd = $1
end
- eval IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join
+ eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join,
+ _null_binding)
}
if no_launcher
$root.withdraw # hide root window