We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Update "clock" without freezing program

Just fooling around I came across an issue updating a digital-clock like label. This:

self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime())
        self.clock=ttk.Label(self,text=self.now)
        self.clock.pack()
        while True:
            self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime())
            self.clock['text']=self.now

simply freezes the program, I've managed to get it to update on certain events like the user hitting a button but I'd like it to continuously update. Any ideas?

EDIT: I got this to work using configure, but why does that work and not this?
Double EDIT:After some thinking I decided it was because the program was stuck in an infinite while loop, however this simply revisits the method.

2
Contributors
2
Replies
17 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
Skill Endorsements: 0
Question Self-Answered as of 1 Year Ago

You are using after timer events as demonstrated in by color changing label demo snippet?

pyTony
pyMod
Moderator
6,307 posts since Apr 2010
Reputation Points: 879
Solved Threads: 986
Skill Endorsements: 26

No, I just checked out similar clocks on tkinter using the power of google, I didn't even think to go to the color changing one :(

pyguy62
Posting Whiz
353 posts since Aug 2011
Reputation Points: 34
Solved Threads: 19
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1099 seconds using 2.66MB