您的位置:首页 > 其它

用Shoes 写累积计时器

2009-11-03 19:34 99 查看
已经用了一个月的天翼,除了经常掉线外,最郁闷的就是它没有统计总时间,所以用Shoes 写了一个计时器来记录一共用了多久。

Shoes.app :title => "Timer", :height => 70, :width => 150 do
stack do
@cap = caption "Pope"
flow do
@start = button("start") { @t1 = Time.now }
@stop = button("stop") do
@t2 = Time.now

t = 0
File.open("f:/time", "r") { |file| t = file.gets }

total_time = @t2 - @t1 + t.to_f
@cap.text = "#{"%3.4f" % (total_time / 3600)} hours"

File.open("f:/time", "w") { |file| file.puts total_time  }
end
end
end
end


这是界面:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: