diff options
| author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-19 16:14:43 +0000 |
|---|---|---|
| committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-19 16:14:43 +0000 |
| commit | 3660776ed276ead87e6b2ba8caf3108157ae21ef (patch) | |
| tree | bd3f9c1e0fa20f4c864b4f7ae911d26c96c858d1 /ext/tk/sample | |
| parent | 9e3dd7bad2521e008c88a6b53ae85b8eba7e05d8 (diff) | |
| download | ruby-3660776ed276ead87e6b2ba8caf3108157ae21ef.tar.gz ruby-3660776ed276ead87e6b2ba8caf3108157ae21ef.tar.xz ruby-3660776ed276ead87e6b2ba8caf3108157ae21ef.zip | |
tcltklib.c :
* lib_do_one_event() : change default value of the argument
* lib_do_one_event() : returns true/false
* add TclTkLib::EventFlag::NONE ( == 0 )
* add set_no_event_wait() and get_no_event_wait()
* modify MANUAL.euc and README.euc
tk.rb :
* change default value of TkCore.do_one_event argument
* add TkCore.set_no_event_wait(wait) and TkCore.get_no_event_wait
* add Tk.exit ( == destroy root widget )
tkafter.rb :
* rename TkAfter => TkTimer ( TkAfter is an alias name now. )
* set_callback returns self
* continue() raises an exception, if already running or no procedure.
* skip() raises an exception, if not running.
sample/tktimer2.rb
* new sample for TkTimer class.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample')
| -rw-r--r-- | ext/tk/sample/tktimer2.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/tk/sample/tktimer2.rb b/ext/tk/sample/tktimer2.rb new file mode 100644 index 000000000..0359ac4d0 --- /dev/null +++ b/ext/tk/sample/tktimer2.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class. + +require "tk" + +label = TkLabel.new(:relief=>:raised, :width=>10) \ + .pack(:side=>:bottom, :fill=>:both) + +tick = proc{|aobj| + cnt = aobj.return_value + 5 + label.text format("%d.%02d", *(cnt.divmod(100))) + cnt +} + +timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 }) + +TkButton.new(:text=>'Start') { + command proc{ timer.continue unless timer.running? } + pack(:side=>:left, :fill=>:both, :expand=>true) +} +TkButton.new(:text=>'Stop') { + command proc{ timer.stop if timer.running? } + pack('side'=>'right','fill'=>'both','expand'=>'yes') +} + +ev_quit = TkVirtualEvent.new('Control-c', 'Control-q') +Tk.root.bind(ev_quit, proc{Tk.exit}).focus + +Tk.mainloop |
