From e3c533de7680d1183e5410a64463afe895e21f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 14 Mar 2018 18:05:19 +0100 Subject: [PATCH] Implement example command callback to toggle the next button --- src/demo/event_handler_main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/demo/event_handler_main.py b/src/demo/event_handler_main.py index ad5e9ce..730cf18 100644 --- a/src/demo/event_handler_main.py +++ b/src/demo/event_handler_main.py @@ -25,11 +25,26 @@ def selectdir(history): except Exception: log.exception('Selectdir failed!') + +def toggle_next(history): + toggle_next.button_state = not toggle_next.button_state + try: + cmd = history[-1].split() + if cmd[0] == 'togglenext': + ServerUplinkConnector().send('messagecontrol', + {'data': {'command': 'showbutton', + 'next_visibility': toggle_next.button_state}}) + except Exception: + log.exception('Togglenext failed!') +toggle_next.button_state = False + + if __name__ == '__main__': ide = SourceCodeEventHandler(key='webide', directory=tfwenv.WEBIDE_WD, exclude=['__pycache__']) terminado = TerminadoEventHandler(key='shell') terminado.historymonitor.subscribe_callback(cenator) terminado.historymonitor.subscribe_callback(selectdir) + terminado.historymonitor.subscribe_callback(toggle_next) processmanager = ProcessManagingEventHandler(key='processmanager', dirmonitor=ide.monitor) eventhandlers = {ide, terminado, processmanager}