[Tutor] Tkinter and after() method
Phil
phillor9 at gmail.com
Fri Jan 27 17:55:05 EST 2023
On 27/1/23 20:17, Alan Gauld via Tutor wrote:
> If thats the case calling after inside a for loop is
> extremely bad practice and quite likely to cause your
> GUI to freeze which is a very bad user experience.
Thank you Alan for your reply and example code.
The GUI did freeze, however, at the time of posting my question I
couldn't think of a better method. I posted a second message about half
an hour latter after I discovered a syntax error which solved the
recursion error (that was only test code and nothing to do with my
project) but not the freezing GUI. The answer came to me at around 3:00
AM and I have now removed the for-loop so the problem has been solved.
I must resist the urge to post a plea for help whenever a problem
frustrates me.
>> To try to get some understanding of what's required I tried this:
>>
>> self.r = 31
>>
>> self.abc()
>> self.print_count()
>> self.after(1000, self.print_count()
>>
>> def abc(self):
>> self.r += 1
>> print(self.r)
>>
>> def print_count(self)
>> self.abc()
>> self.after(1000, self.print_count()
> That makes no sense whatsoever.
I can see why my test example code caused you to think that. As I said
in my second posting after I removed "self.print_count()" and corrected
self.after(1000, self.print_count()) to self.after(1000,
self.print_count) the test worked.
Anyway, thank you again for taking the trouble to reply to my confusing
question.
--
Regards,
Phil
More information about the Tutor
mailing list