用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
这是界面:
![](http://p.blog.csdn.net/images/p_blog_csdn_net/Sedgewick/EntryImages/20091103/网卡计时器.png)
相关文章推荐
- 安卓案例-计时器
- OSG计时器与时间戳
- 计时器Timer
- 方便计时器
- html+css+jquery__60秒计时器
- C++计时器:毫秒级和微秒级
- c++之std::accumulate连续操作如累加累积等
- 内核 API,第 3 部分: 2.6 内核中的计时器和列表
- swift学习 - 计时器
- js实现计时器
- TCP通信四种计时器
- 计时器
- 验证码计时器-CountDownTimer
- [HackerRank]Hard Disk Drives/[JZOJ100005]Shoes
- Recyclerview的一些个人理解与使用(三)列表中的计时器
- 基于NStime计时器的实现
- 设置短信验证码动态计时器
- 关于在WebLogic服务器上部署应用时错误的累积
- white new balance 998 shoes