|
setup diary |
require 'tk' $text=TkLabel.new(nil,'text'=>'0.00','font'=>TkFont.new(['times',100,['bold']]) ).pack Tk.root.bind('KeyPress',proc{|key| $timer=($timer)?false:true if key=='space' },'%K') Tk.root.bind('KeyRelease',proc{|key| Thread::start{ t0=Time::now loop{ $text.text="%.2f"%(Time::now-t0) break if $timer==false sleep 0.008 } } if $timer==true and key=='space' },'%K') Tk.mainloop一応使えるし、まあこんなもんかな。