diff options
Diffstat (limited to 'ext/tk/sample/demos-jp/timer')
-rw-r--r-- | ext/tk/sample/demos-jp/timer | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ext/tk/sample/demos-jp/timer b/ext/tk/sample/demos-jp/timer index 232f4ae5ca..58a41d00c0 100644 --- a/ext/tk/sample/demos-jp/timer +++ b/ext/tk/sample/demos-jp/timer @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # timer -- # This script generates a counter with start,stop and reset buttons. @@ -80,12 +80,28 @@ 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}) @@ -99,8 +115,8 @@ end class Timer < TkRoot attr_reader :countframe - def initialize - super + def initialize(*args) + super(*args) @countframe = CountFrame.new(self) @buttonframe = ButtonFrame.new(self) for f in [@buttonframe,@countframe] |