Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Polling

Sahar Nasiri
Sahar Nasiri
7,454 Points

Trace

I didn't understand what exactly this line does and why do we need it? Why does my timer_text disappear when I comment this line?

self.timer_text.trace("w", self.build_timer)

1 Answer

Wairton Rebouças
Wairton Rebouças
8,225 Points

self.timer_text.trace("w", self.build_timer) Trace is a method to add an observer to timer_text, in this case, whenever you modify timer_text variable, self.build_timer method will be called. Since this method is used to build your timer, if you comment it, your timer will never be built.

More resources:

stringvar and trace effbot site

Observer pattern on wikipedia