Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby Tk: how to make something happen periodically?

Reply
Thread Tools

Ruby Tk: how to make something happen periodically?

 
 
S P Arif Sahari Wibowo
Guest
Posts: n/a
 
      02-10-2007
Hi!

In Ruby Tk, how to make something happen periodically, while the user
does not touch the button, menu, etc.?

Thanks!

 
Reply With Quote
 
 
 
 
Morton Goldberg
Guest
Posts: n/a
 
      02-10-2007
On Feb 10, 2007, at 2:30 AM, S P Arif Sahari Wibowo wrote:

> In Ruby Tk, how to make something happen periodically, while the user
> does not touch the button, menu, etc.?


Go to <http://rubykitchensink.ca/> and search on "tktimer".

Regards, Morton



 
Reply With Quote
 
 
 
 
Morton Goldberg
Guest
Posts: n/a
 
      02-10-2007
On Feb 10, 2007, at 2:51 AM, Morton Goldberg wrote:

> On Feb 10, 2007, at 2:30 AM, S P Arif Sahari Wibowo wrote:
>
>> In Ruby Tk, how to make something happen periodically, while the user
>> does not touch the button, menu, etc.?

>
> Go to <http://rubykitchensink.ca/> and search on "tktimer".


Let me recant on that. It's better to go to Google and search "ruby
+tktimer". This finds a lot more stuff. I also recommend the
following link

http://www.ruby-lang.org/cgi-bin/cvs...ext/tk/sample/

There you will find links to tktimer.rb, tktimer2.rb, and tktimer3.rb
-- these are examples of the use of the TkTimer class. It's also
possible that you might find

http://raa.ruby-lang.org/project/rubytk_en/

and

http://blade.nagaokaut.ac.jp/cgi-bin...by-talk/212939

useful.

Regards, Morton



 
Reply With Quote
 
S P Arif Sahari Wibowo
Guest
Posts: n/a
 
      02-17-2007
On Feb 10, 3:22 am, Morton Goldberg <m_goldb...@ameritech.net> wrote:
> > Go to <http://rubykitchensink.ca/> and search on "tktimer".

>
> Let me recant on that. It's better to go to Google and search "ruby
> +tktimer". This finds a lot more stuff. I also recommend the
> following link
> http://www.ruby-lang.org/cgi-bin/cvs...ext/tk/sample/


Works like a charm, once I know the keyword, things went smoothly.
Thanks!

That said, do you know about proc in the arguments for TkTimer's start
method / parameter, where its result goes?

Thanks!

 
Reply With Quote
 
Morton Goldberg
Guest
Posts: n/a
 
      02-18-2007
On Feb 17, 2007, at 6:20 PM, S P Arif Sahari Wibowo wrote:

> On Feb 10, 3:22 am, Morton Goldberg <m_goldb...@ameritech.net> wrote:
>>> Go to <http://rubykitchensink.ca/> and search on "tktimer".

>>
>> Let me recant on that. It's better to go to Google and search "ruby
>> +tktimer". This finds a lot more stuff. I also recommend the
>> following link
>> http://www.ruby-lang.org/cgi-bin/cvs...ext/tk/sample/

>
> Works like a charm, once I know the keyword, things went smoothly.
> Thanks!
>
> That said, do you know about proc in the arguments for TkTimer's start
> method / parameter, where its result goes?


No, I'm sorry, but I don't know where the result of a block passed to
TkTimer#start goes. In my own work, I have always written these
blocks for their effects, not their results. IMO you shouldn't rely
on the results such blocks. Remember: "effect" can include
modifications to the state of objects visible within your own code.

Regards, Morton

 
Reply With Quote
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      02-18-2007
From: "S P Arif Sahari Wibowo" <>
Subject: Re: Ruby Tk: how to make something happen periodically?
Date: Sun, 18 Feb 2007 08:20:11 +0900
Message-ID: < .com>
> That said, do you know about proc in the arguments for TkTimer's start
> method / parameter, where its result goes?


Please try this.
--------------------------------------------------------------
TkTimer.new(100, 2, proc{|tm|
p [:body, tm.class, tm.current_args, tm.return_value]
tm.return_value + 1
}).start(500, proc{|tm|
p [:init, tm.class, tm.current_args, tm.return_value]
4
},
1,2,3)
--------------------------------------------------------------

It will returns
--------------------------------------------------------------
(wait 500ms)
[:init, TkTimer, [1, 2, 3], nil]
(wait 100ms)
[:body, TkTimer, [], 4]
(wait 100ms)
[:body, TkTimer, [], 5]
--------------------------------------------------------------

A TkTimer object keeps the result (last value) of the previous proc.
You can get the result by TkTimer#return_value method.

BTW, TkTimer class is not accurate. Because, the interval shows
the wait between finish of previous proc and start of next proc.
So, the timer delays by the time cost of the proc.

TkRTTimer class is a little more accurate than TkTimer class.
It modifies the interval based on the difference between the requested
time and current time. It doesn't mean to keep same intervals.
But it will make the delay by repeating minimum.
Please try "ext/tk/sample/tkrttimer.rb".
It will show you a part of properties of TkRTTimer class.
--
Hidetoshi NAGAI ()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
THIS WORKS - IT'S BEEN PROVEN! LET'S MAKE THIS HAPPEN! Arm7 C++ 1 08-28-2008 01:19 PM
Don't Just Dream About an Exciting New Career in booming telecomindustry...Make it Happen with India's Top Telecom Management program at AegisSchool of Telecommunication and Business, Mumbai. telecom news Java 0 03-26-2008 10:37 AM
Don't Just Dream About an Exciting New Career in booming telecomindustry...Make it Happen with India's Top Telecom Management program at AegisSchool of Telecommunication and Business, Mumbai. telecom news C Programming 0 03-26-2008 10:37 AM
Don't Just Dream About an Exciting New Career in booming telecomindustry...Make it Happen with India's Top Telecom Management program at AegisSchool of Telecommunication and Business, Mumbai. telecom news Cisco 0 03-26-2008 10:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57