wx.Timer in seconds to hours and minutes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prettypython
    New Member
    • Jan 2013
    • 6

    wx.Timer in seconds to hours and minutes

    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!


    Code:
    ef onTimer(self,event):
            current = self.mc.Tell()
            self.info_pos.SetLabel(" %i seconds" % (int(current)/1000))
            self.slider.SetValue(current)
    Last edited by Meetee; Jan 7 '13, 10:13 AM. Reason: Use code tags <code/> around your code
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    divmod() returns both the quotient and the remainder. For future reference, "Pls help!" says that you are too lazy to key in complete words.
    Code:
    current = 3600 ## seconds
    
    minutes, seconds = divmod(current, 60)
    hours, minutes = divmod(minutes, 60)
    print hours, minutes, seconds

    Comment

    • prettypython
      New Member
      • Jan 2013
      • 6

      #3
      Hi thanks for the reply but i still do not get it, how do declare it as a code.?

      Comment

      • dwblas
        Recognized Expert Contributor
        • May 2008
        • 626

        #4
        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.

        Comment

        • prettypython
          New Member
          • Jan 2013
          • 6

          #5
          wx.Timer in seconds to hours and minutes

          I still do not know how to get the code working anyone else has any ideas that can be helpful.?

          Comment

          • bvdet
            Recognized Expert Specialist
            • Oct 2006
            • 2851

            #6
            Does your GUI work? Perhaps you could post a small code example that we could test.

            Comment

            • prettypython
              New Member
              • Jan 2013
              • 6

              #7
              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!

              Code:
              #Timer
                      self.timer = wx.Timer(self)
                      self.Bind(wx.EVT_TIMER, self.onTimer)
                      self.timer.Start(100)
              
               def onPlay(self,event):
                      self.mc.Play()
                      self.slider.SetRange(0, self.mc.Length())
                      self.mc.SetLabel('length: %d seconds' % (self.mc.Length()/1000))
              
              
              def onTimer(self,event):
                      current = self.mc.Tell()
                      self.info_pos.SetLabel(" %i seconds" % (int(current)/1000))
                      self.slider.SetValue(current)
              Last edited by Rabbit; Jan 19 '13, 07:43 PM. Reason: Please use code tags when posting code.

              Comment

              Working...