def evaluateUI(window: sg.Window, ser: Serial): event, values = window.read(1000) print(event, values) if event in (None, 'Exit'): return -1, CMD_ID.cmd_none elif event == 'COMPORT': return 2, CMD_ID.cmd_none elif event == 'RED' or event == 'GREEN' or event == 'BLUE': # if there was a slider event, make sure to update and # return the necessary command (blinking or steady) if window['CMD_STEADY'].Get() is True: return 1, CMD_ID.cmd_steady else: return 1, CMD_ID.cmd_blink elif event == 'CMD_STEADY': return 1, CMD_ID.cmd_steady elif event == 'CMD_BLINK': return 1, CMD_ID.cmd_blink elif event == 'CMD_ALL_ON': # update state of the radio buttons and sliders window['CMD_STEADY'].Update(True) window['RED'].Update(255) window['GREEN'].Update(255) window['BLUE'].Update(255) window.Refresh() return 1, CMD_ID.cmd_all_on elif event == 'CMD_ALL_OFF': # update state of the radio buttons and sliders window['CMD_STEADY'].Update(True) window['RED'].Update(0) window['GREEN'].Update(0) window['BLUE'].Update(0) window.Refresh() return 1, CMD_ID.cmd_all_off else: return 0, CMD_ID.cmd_none
def setStatus(window: sg.Window, statusText: str): window['status'].update(statusText) window.Refresh()