Created
January 2, 2018 22:35
-
-
Save Paulchen-Panther/676cfc368549146ac4a0e2544f98f135 to your computer and use it in GitHub Desktop.
Python callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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