[Tkinter-discuss] How fast is my computer?

Opstad, Dave dave.opstad at monotypeimaging.com
Tue Apr 3 18:09:50 CEST 2007


Bob Greschke wrote:

> I have several applications (Python/Tkinter, of course) that run on
> everything from 233MHz single board computers to 3GHz screamers.  I like to
> keep the user entertained by printing messages like '1000 things
> processed...', '2000 things processed...', etc.  Depending on the speed of a
> system it might be  appropriate to say something every 1000 things on some
> machines, and on others say something maybe every 50 things to keep the
> messages coming out at a reasonable pace.

Rather than using timing (which does change quite a bit from machine to
machine, as you say), why not use a threshold value? Each time through the
loop you call an updateProgress() method, and that method adds one to its
internal count, but it only actually updates the graphical widget if the
percent change since the last redraw is greater than the threshold.

This way you can call the same progress routine irrespective of processor
speed, because the redrawing only happens in discrete chunks. I've used this
trick to good effect in a ProgressWheel Tkinter widget I wrote.

Dave

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20070403/40b0ce9d/attachment.htm 


More information about the Tkinter-discuss mailing list