nobodylikeyou
nobodylikeyou

Reputation: 3

Developing Kodi Addon - How to make that default spinning wheel when waiting?

I'm developing a Kodi add-on and while waiting for fetch data from api I want to show that default kodi spinning circle with darker background. Now I'm using .DialogProgress() function when waiting but it looks kinda weird. I can't find anything related with that in Kodi docs.

What function I should use?

Upvotes: 0

Views: 267

Answers (1)

Roman Miroshnychenko
Roman Miroshnychenko

Reputation: 1564

Something like this:

from contextlib import contextmanager

from xbmc import executebuiltin


@contextmanager
def busy_spinner():
    """
    Show busy spinner for long operations
    This context manager guarantees that a busy spinner will be closed
    even in the event of an unhandled exception.
    """
    executebuiltin('ActivateWindow(10138)')  # Busy spinner on
    try:
        yield
    finally:
        executebuiltin('Dialog.Close(10138)')  # Busy spinner off



with bysy_spinner():
    some_long_operation()

Upvotes: 0

Related Questions