Re: Tk question about -command=sub{} and Text Insert()
2007/11/19, zentara [EMAIL PROTECTED]: On Mon, 19 Nov 2007 00:14:29 +0800, [EMAIL PROTECTED] (Panda-X) wrote: Hi all, Below is my code. With this code, 12345 will show at once after 5 seconds I click the button. But what I want is to insert() each number per second. Is that something I can do like $| = 1 in such case ? At least, could anybody tell this is the behavior of insert () ? or it's the behavior of -command = sub {} ? Thank you very much ! == It would be nice if you posted a complete running example, because it's hard to say whether it's Text widget update problem, OR the way you setup the class. Usually, in your case, the problem is solved by putting an update right after the text insert, this forces the Text widget to update itself immediately. But you may need to update the $mw too, since it's a class. sub RollText{ for ( 1..5 ) { $_[0] -{mw}{box} - insert ( 'end', $_ ) ; # sleep 1; $_[0] -{mw}{box}-update; #or possibly you need to tell the $mw to update the class $_[0] -{mw}-update; } } zentara -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html THANK YOU!!! That's exactly what I want !!! Again, THANK YOU VERY MUCH =)
Re: Tk question about -command=sub{} and Text Insert()
On 11/18/07, Panda-X [EMAIL PROTECTED] wrote: But what I want is to insert() each number per second. sub RollText{ for ( 1..5 ) { $_[0] -{mw}{box} - insert ( 'end', $_ ) ; sleep 1; } } You probably don't want sleep() there; the after() method is generally the way to ask Tk to make something happen after some time interval has passed. The interface is different than simply sleeping, but more powerful; check the Tk docs for the full story. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Tk question about -command=sub{} and Text Insert()
2007/11/19, Tom Phoenix [EMAIL PROTECTED]: On 11/18/07, Panda-X [EMAIL PROTECTED] wrote: But what I want is to insert() each number per second. sub RollText{ for ( 1..5 ) { $_[0] -{mw}{box} - insert ( 'end', $_ ) ; sleep 1; } } You probably don't want sleep() there; the after() method is generally the way to ask Tk to make something happen after some time interval has passed. The interface is different than simply sleeping, but more powerful; check the Tk docs for the full story. Hope this helps! --Tom Phoenix Stonehenge Perl Training Thanks Tom, As you said, I don't really want to sleep. =) In this code, I am trying to prove the sort of insert () will only prompt after everything is done. And what I want to understand more is how can I get an immediate insert(), rather than wait until all done! Any more clues ? Thank you very much !
Re: Tk question about -command=sub{} and Text Insert()
On 11/18/07, Panda-X [EMAIL PROTECTED] wrote: Any more clues ? This is a forum for Perl beginners, but there are forums available specifically for all of the major modules used with Perl. Some modules have more than one forum. As you might expect, you'll generally get better answers faster by inquiring in a more specific forum. Forums are most commonly mailing lists or web-based discussion boards. Instructions on how to find a forum can generally be found in the FAQ or main page of the module's documentation. If you don't find it there, try your favorite search engine after you check the Perl Mailing List Database: http://lists.cpan.org/ Many forums have their own FAQ; save time by searching for that before even subscribing to a mailing list or signing up on a discussion board. Even if the FAQ doesn't answer your question, it probably answers questions you didn't know you had; skimming the list of questions can be educational. Besides the FAQ, the archives of the forum itself may be searchable via your favorite search engine. Unless you've got a really new question, the answer is often out there already. Have fun with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/