Spinner

The Spinner displays an icon-size spinning animation. It is often used as an alternative to a ProgressBar for displaying indefinite activity, instead of actual progress.

To start the animation, use Spinner.start, to stop it use Spinner.stop.

Example

samples/gtk/widgets/src/nativeMain/kotlin/org/gtkkn/samples/gtk/widgets/Spinner.kt
fun spinner(): Widget {
    val spinner = Spinner().apply {
        setSizeRequest(100, 100)
    }

    val toggleButton = ToggleButton(label = "Start Spinning")

    // bind the spinning property of the spinner to the active property of the toggleButton
    toggleButton.bindProperty("active", spinner, "spinning", BindingFlags.DEFAULT)

    // update the text when the button is spinning
    toggleButton.connectClicked {
        if (toggleButton.getActive()) {
            toggleButton.setLabel("Stop Spinning")
        } else {
            toggleButton.setLabel("Start Spinning")
        }
    }

    val box = Box(Orientation.VERTICAL, 20).apply {
        setMargins(20)
        append(spinner)
        append(toggleButton)
    }

    return box
}