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

prettypython
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 = self.mc.Tell()
  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
  2.  
  3. minutes, seconds = divmod(current, 60)
  4. hours, minutes = divmod(minutes, 60)
  5. print hours, minutes, seconds 
Jan 7 '13 #2

prettypython
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

prettypython
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

bvdet
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

prettypython
P: 6
Hi this is my code for the timer that i did for my Media player .
I used wx.media 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)
  5.  
  6.  def onPlay(self,event):
  7.         self.mc.Play()
  8.         self.slider.SetRange(0, self.mc.Length())
  9.         self.mc.SetLabel('length: %d seconds' % (self.mc.Length()/1000))
  10.  
  11.  
  12. def onTimer(self,event):
  13.         current = self.mc.Tell()
  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.