By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,385 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,385 IT Pros & Developers. It's quick & easy.

wx.Timer in seconds to hours and minutes

P: 6
Hi i want to know how to define the seconds into hours and minutes for the media player timer i have already done it in seconds but not sure how to hours and minute. Pls help!

Expand|Select|Wrap|Line Numbers
  1. ef onTimer(self,event):
  2.         current =
  3.         self.info_pos.SetLabel(" %i seconds" % (int(current)/1000))
  4.         self.slider.SetValue(current)
Jan 7 '13 #1
Share this Question
Share on Google+
6 Replies

Expert 100+
P: 626
divmod() returns both the quotient and the remainder. For future reference, "Pls help!" says that you are too lazy to key in complete words.
Expand|Select|Wrap|Line Numbers
  1. current = 3600 ## seconds
  3. minutes, seconds = divmod(current, 60)
  4. hours, minutes = divmod(minutes, 60)
  5. print hours, minutes, seconds 
Jan 7 '13 #2

P: 6
Hi thanks for the reply but i still do not get it, how do declare it as a code.?
Jan 8 '13 #3

Expert 100+
P: 626
It is already code and will run. You can run the code above as is. Change the variable if you desire, and and take a look at the output. Idle (comes with Python) might be an IDE for you to start with. Copy and paste the above into the Idle window. How to save and run a python program in Idle.
Jan 8 '13 #4

P: 6
I still do not know how to get the code working anyone else has any ideas that can be helpful.?
Jan 15 '13 #5

Expert Mod 2.5K+
P: 2,851
Does your GUI work? Perhaps you could post a small code example that we could test.
Jan 17 '13 #6

P: 6
Hi this is my code for the timer that i did for my Media player .
I used ctrl. I am not sure of how to do the coding to change it to Hours and minutes, please help!

Expand|Select|Wrap|Line Numbers
  1. #Timer
  2.         self.timer = wx.Timer(self)
  3.         self.Bind(wx.EVT_TIMER, self.onTimer)
  4.         self.timer.Start(100)
  6.  def onPlay(self,event):
  8.         self.slider.SetRange(0,
  9.'length: %d seconds' % (
  12. def onTimer(self,event):
  13.         current =
  14.         self.info_pos.SetLabel(" %i seconds" % (int(current)/1000))
  15.         self.slider.SetValue(current)
Jan 19 '13 #7

Post your reply

Sign in to post your reply or Sign up for a free account.