已经用了一个月的天翼,除了经常掉线外,最郁闷的就是它没有统计总时间,所以用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 这是界面: