button off/on

Hello,
how could I set button to off/on. First push make function, second push stopped this function.

Thanks for help

Do you want it to execute dynamically, i.e. you start the script and if the user has pressed the stop button, you stop the script? Or do you just want a toggle button to enable/disable a feature?

If its the latter, then toggles are in the Draw Module.

If its the former, then there are a couple of options. One is to use the Window.TestBreak() function, and if its true then you stop executing your function loop. If you, however, need this to be an actual button, that’s more difficult because the interface freezes when you run a Python script, so what you could do is periodically store the state of your algorithm in the registry (store variable values, etc.) and return control to the interface. You then wait some time for the user to press the button, and if they don’t you reload values into your function and start where you left off.

I need exactly toggle button to start/stop sound. Its possible to done it in logic menu?