#encoding:utf-8 require "tk" count = 180 stop_counter=false start_counter=true restart_counter=false reresteart_counter=false label=TkLabel.new clock=TkLabel.new(text:count) button=TkButton.new{ text "Start" command{TkTimer.start(1000){ if stop_counter == false && start_counter == true count = count - 1 clock.text = count elsif stop_counter==true && start_counter == false && restart_counter == false next elsif stop_counter == true&& start_counter==false&& restart_counter == true count = count -1 clock.text=count end } } } button2=TkButton.new{ text:"Stop" command {stop_counter=true start_counter=false restart_counter=false}} button3=TkButton.new{ text:"Reset" command{ count=180 clock.text=count stop_counter = true start_counter=false restart_counter=false }} button4=TkButton.new{ text:"Quit" command{Tk.root.destroy()}} button5=TkButton.new{ text:"ReStart" command{ stop_counter=true start_counter=false restart_counter=true}} label.pack button.pack button2.pack button3.pack button4.pack button5.pack clock.pack Tk.mainloop