Refresher UI element

from ui import Refresher
counter = 0
def get_data():
    counter += 1
    return [str(counter), str(1000-counter)] #Return value will be sent directly to output.display_data
Refresher(get_data, i, o, 1, name="Counter view").activate()
class ui.refresher.Refresher(refresh_function, i, o, refresh_interval=1, keymap=None, name='Refresher')[source]

Implements a state where display is refreshed from time to time, updating the screen with information from a function.

__init__(refresh_function, i, o, refresh_interval=1, keymap=None, name='Refresher')[source]

Initialises the Refresher object.

Args:

  • refresh_function: a function which returns data to be displayed on the screen upon being called, in the format accepted by screen.display_data()
  • i, o: input&output device objects

Kwargs:

  • refresh_interval: Time between display refreshes (and, accordingly, refresh_function calls)
  • keymap: Keymap entries you want to set while Refresher is active
  • name: Refresher name which can be used internally and for debugging.
activate()[source]

A method which is called when refresher needs to start operating. Is blocking, sets up input&output devices, renders the refresher, periodically calls the refresh function&refreshes the screen while self.in_foreground is True, while refresher callbacks are executed from the input device thread.

deactivate()[source]

Deactivates the refresher completely, exiting it.

print_name()[source]

A debug method. Useful for hooking up to an input event so that you can see which refresher is currently active.