From: David Bailey Date: 2006-03-27T23:14:23+09:00 Subject: Callback For A Timer Event To Display Widget in Ruby/Tk Kind All, Um, I need to code an elapsed time display in Ruby/Tk. It was straightforward to use the Time class and the Time#srtftime method to get the time in just the form I wanted: t = Time.new; puts "Time is #{t.strftime("%I:%M:%S %p")}" Likewise, for displaying the string in a TkLabel widget: TkLabel.new(canvas, 'text'=>"The time is #{t.strftime("%I:%M:%S %p")}" ).pack( 'side'=>'top', 'padx'=>15, 'pady'=>15 ) It was also easy to understand binding in general: root.bind('q') { exit }. Or to setup a callback for a TkButton press: myButton = TkButton.new(root, 'text'=>'Click me!', 'command'=> proc { btnProc() }).place( 'x'=>x, 'y'=>y, 'width'=>w, 'height'=>h ) But, I have searched high and low, and I can not find out how to set up a callback for a timer event. I just want to display a time string on the TkCanvas or TkTopLevel window once per second. I have gone through a Perl/Tk reference book and I'm still having trouble figuring out how to "translate" this into Ruby/Tk. I'll of course keep searching and trying stuff, but if anyone knowledgeable has a code example of how to this, or can point me to one, or point me to a reference to the technique, I'd be grateful. Thank you and best regards, David -- Posted via http://www.ruby-forum.com/.