mainthread

This module allows you to run code on the main thread easely. This can be used for modifiying the UI.

Example:

from UIKit import UIScreen
import mainthread

def set_brightness():
    inverted = int(not int(UIScreen.mainScreen.brightness))
    UIScreen.mainScreen.setBrightness(inverted)

mainthread.run_async(set_brightness)
mainthread.run_async(code)

Runs the given code asynchronously on the main thread.

Parameters:code – Code to execute in the main thread.