Skip to content

Instantly share code, notes, and snippets.

@Paulchen-Panther
Created January 2, 2018 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paulchen-Panther/676cfc368549146ac4a0e2544f98f135 to your computer and use it in GitHub Desktop.
Save Paulchen-Panther/676cfc368549146ac4a0e2544f98f135 to your computer and use it in GitHub Desktop.
Python callback
from plugin import *
import time
def onCompStateChanged(comp, state):
print(comp, state)
def onSettingsChanged(settings):
None # or do somthing else with settings
log("Register callback functions ...")
registerCallback(ON_COMP_STATE_CHANGED, onCompStateChanged)
registerCallback(ON_SETTINGS_CHANGED, onSettingsChanged)
log("Successfully registered")
while not abort():
time.sleep(1)
# unregisterCallback() is not necessary, because the callbacks are deleted in the deconstructor of the thread
# but maybe helpful if anyone needed to switch the callback at runtime eg.
# unregisterCallback(ON_COMP_STATE_CHANGED)
# unregisterCallback(ON_SETTINGS_CHANGED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment