# proc to make a button continuously call a function while depressed. button .b -text "Button" pack .b set afterid {} proc function {} { global afterid puts "Function." set afterid [after 1000 function] } bind .b <1> { function } bind .b { if {$afterid != {}} { after cancel $afterid set afterid {} } }