From: NetManiac Date: 2007-08-21T21:15:05+09:00 Subject: TkTimer and calling own methods from handler Hi! I'm experimenting with Ruby Tcl/Tk and I've got stuck with timers. I reduced my problem to following example: #!/usr/bin/env ruby require "tk" def advance button.text = global_var.to_s global_var += 1 end global_var = 0 root = TkRoot.new(:title=>'Example') button = TkButton.new(root) { text "button" } button.pack("side"=>"right", "fill"=>"y") tick = proc{|aobj| advance } timer = TkTimer.new(250, -1,tick ) timer.start(0) Tk.mainloop() I want this code to increase number displayed on button, but does not work. When I change timer definition to: tick = proc{|aobj| button.text = global_var.to_s global_var += 1 } It does work, so it looks like I need to call my own method some special way? I have examined examples in Ruby source code, but all of them operates without wrapping code in own methods (I suppose to make it easier to understand). So how I should call own methods? -- Witold Rugowski http://nhw.pl/wp/ (EN blog) http://FriendsFeedMe.com