Implement example command callback to toggle the next button

This commit is contained in:
Kristóf Tóth 2018-03-14 18:05:19 +01:00
parent f354fd73dc
commit e3c533de76

View File

@ -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}