Question

I am writing a timer program in Python using PyGTK. It is precise to the hundredths place. Right now, I am using a constantly updated label. This is a problem, because if I resize the window while the timer is running, Pango more often than not throws some crazy error and my program terminates. It's not always the same error, but different ones that I assume are some form of failed draw. Also, the label updates slower and slower as I increase the font size.

So, I am wondering if there is a more correct way to display the timer. Is there a more stable method than constantly updating a label?

Was it helpful?

Solution 2

I figured out the problem. It was indeed a problem with the threads. I never would've guessed that myself. The trick is to use gobject.timeout_add() to create a timer instead of a threaded loop. Here is some information about gobject.timeout_add():

http://faq.pygtk.org/index.py?req=show&file=faq01.021.htp

Don't forget to have your function return True, or the timer will stop.

OTHER TIPS

Updating a label should work perfectly reliably, so I suspect you're doing something else wrong. Are you using threads? What does your code look like? How small can you condense your program (by removing functionality, not by obfuscating the code), without making the problem go away?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top