diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/tk/sample/demos-jp/timer | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/tk/sample/demos-jp/timer')
-rw-r--r-- | trunk/ext/tk/sample/demos-jp/timer | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/trunk/ext/tk/sample/demos-jp/timer b/trunk/ext/tk/sample/demos-jp/timer deleted file mode 100644 index 58a41d00c0..0000000000 --- a/trunk/ext/tk/sample/demos-jp/timer +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env ruby -# -# timer -- -# This script generates a counter with start,stop and reset buttons. -# -# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp) -# last update: Sat Jun 27 12:24:14 JST 1998 -# - -require "tk" -require "thread" -require "tkafter" - -$time = "0.00" -$m = Mutex.new -$loop = false - -def timer_stop - $loop = false - $m.lock -end - -def timer_start - $loop = true - $m.unlock -end - -def timer_reset - $time = "0.00" - $root.countframe.counter['text'] = $time -end - -def timer_loop - if $loop - $time = $time.succ - $root.countframe.counter['text'] = $time - end - Tk.after(10,proc{timer_loop}) -end - - -# -# thread version -# -def timer_loop2 - while true - $m.lock - $time = $time.succ - $root.countframe.counter['text'] = $time - sleep(0.01) - $m.unlock - end -end - -# -# TkAfter -# -def timer_loop3 - if $loop - $time = $time.succ - $root.countframe.counter['text'] = $time - end -end - - -class CountFrame < TkFrame - attr_reader :counter - - def initialize(parent=nil,keys=nil) - super(parent,keys) - @counter = TkLabel.new(self, - 'text'=>$time, - 'relief'=>'raised') - @counter.pack('fill'=>'both') - self - end -end - - -class ButtonFrame < TkFrame - def initialize(parent=nil,keys=nil) - super(parent,keys) -=begin - @stop = TkButton.new(self, - 'text'=>'Stop', - 'command'=>proc{timer_stop}) - @start = TkButton.new(self, - 'text'=>'Start', - 'command'=>proc{timer_start}) -=end - @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled) - @start = TkButton.new(self, :text=>'Start', :state=>:normal) - - @stop.command proc{ - timer_stop - @start.state(:normal) - @stop.state(:disabled) - } - @start.command proc{ - timer_start - @stop.state(:normal) - @start.state(:disabled) - } - - @reset = TkButton.new(self, - 'text'=>'Reset', - 'command'=>proc{timer_reset}) - for b in [@stop,@start,@reset] - b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes') - end - end -end - - -class Timer < TkRoot - attr_reader :countframe - - def initialize(*args) - super(*args) - @countframe = CountFrame.new(self) - @buttonframe = ButtonFrame.new(self) - for f in [@buttonframe,@countframe] - f.pack('side'=>'top', 'fill'=>'both') - end - self - end -end - - -$root = Timer.new - -#$thread = Thread.start{timer_loop2} -#timer_loop -TkAfter.new(10,-1,proc{timer_loop3}).start - -Tk.mainloop |