Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:43:25+00:00 2026-06-11T16:43:25+00:00

since I haven’t found anything here, I try and put my Question. I’m trying

  • 0

since I haven’t found anything here, I try and put my Question.

I’m trying to build a simple metronome in kivy. I basically took the Audio example which was provided with the installation und wanted to add a metronome functionality.

class AudioButton(ToggleButton):

    filename = StringProperty(None)
    sound = ObjectProperty(None)

    def on_filename(self, instance, value):
        # the first time that the filename is set, we are loading the sample
        if self.sound is None:
            self.sound = SoundLoader.load(value)

    def on_press(self):
        # stop the sound if it's currently playing
        if self.sound.status != 'stop':
            self.sound.stop()
        self.sound.play()

As you can see, I changed the class from Button to ToggleButton.

I tried to put a while loop with the self.sound.play(), but that results in infinity, so basically I’m looking for a way to break out of the loop, if I press the Button again.

I didn’t really understand the Event loop management from the documentation, which I think should be the answer, but I never used an event loop before.
It would be great if someone could provide some example code for such a situation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:43:26+00:00Added an answer on June 11, 2026 at 4:43 pm

    The place that you want to start looking is in the Kivy docs discussing clock events. In event-driven systems like this any kind of while loop takes the system to its knees. Instead, when you want something to happen periodically, you ask the system to set up a timer and tell it the function that you’d like to have called every time that timer elapses.

    In your case, you’d probably just play that single metronome tick and be done until the next time the timer elapses.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since I haven't found an answer to the question asked previously here I'm trying
This question brings me back to my college days, but since I haven't coded
I'm trying to write a new plugin since I haven't been able to find
So I'm trying to write a new plugin since I haven't been able to
Be patient since I haven't worked with compression algorithms much so this may be
I haven't touched Java since using JBuilder in the late 90's while at University,
It's about an year since Apple introduced ARC. I personally haven't tried it yet
I have no code to really display here, since I have not been able
It is a long time since I haven't done Makefiles. My actual Makefile works
The following is my block of code. since I haven't installed Firebug in IE,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.