⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tktimer.rb

📁 ruby的源代码
💻 RB
字号:
#!/usr/local/bin/ruby# This script generates a counter with start and stop buttons.require "tk"$label = TkLabel.new {  text '0.00'  relief 'raised'  width 10  pack('side'=>'bottom', 'fill'=>'both')}TkButton.new {  text 'Start'  command proc {    if $stopped      $stopped = FALSE      tick    end  }  pack('side'=>'left','fill'=>'both','expand'=>'yes')}TkButton.new {  text 'Stop'  command proc{    exit if $stopped    $stopped = TRUE  }  pack('side'=>'right','fill'=>'both','expand'=>'yes')}$seconds=0$hundredths=0$stopped=TRUEdef tick  if $stopped then return end  Tk.after 50, proc{tick}  $hundredths+=5  if $hundredths >= 100    $hundredths=0    $seconds+=1  end  $label.text format("%d.%02d", $seconds, $hundredths)endroot = Tk.rootroot.bind "Control-c", proc{root.destroy}root.bind "Control-q", proc{root.destroy}Tk.root.focusTk.mainloop

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -