insertDB( conn, (NOME, ";".join(INGREDIENTES), PREPARO, FOTO, ";".join(CATEGORIAS)), ) window["in_nome"].Update("") window["in_foto"].Update("") window["in_ingredientes"].Update("") window["in_preparo"].Update("") window["in_ingred_list"].Update("") window["in_cat"].Update("") window["in_cat_list"].Update("") window.Refresh() sg.PopupAutoClose( "Receita inserida com sucesso!", keep_on_top=True, no_titlebar=True, auto_close=True, auto_close_duration=2, button_type=POPUP_BUTTONS_NO_BUTTONS, ) except Exception as e: sg.PopupError( f"ERRO. Não foi possível inserir a receita. Por favor verifique os campos preenchidos.\nMotivo:\n{e}", title="ERRO", ) else: sg.PopupError( "ERRO: os seguintes erros foram encontrados:\n{0}".format( "\n".join(ERROS), title="ERRO" ) )
continue match = int_regex.match(values['_cycle_id_']) check_input(match, '_cycle_id_') # on submit click if event is '_submit_': error = '' if window['_start_'].BackgroundColor != bgColor_default: error += 'Wrong START input!\n' if window['_stop_'].BackgroundColor != bgColor_default: error += 'Wrong STOP input!\n' if window['_date_'].BackgroundColor != bgColor_default: error += 'Wrong date input!\n' if window['_cycle_id_'].BackgroundColor != bgColor_default: error += 'Wrong cycle id input!\n' if len(error) > 0: sg.PopupAutoClose(error) else: start: datetime.datetime = datetime.datetime.strptime( values['_date_'] + values['_start_'], "%d/%m/%Y%H:%M") stop: datetime.datetime = datetime.datetime.strptime( values['_date_'] + values['_stop_'], "%d/%m/%Y%H:%M") if (stop - start).total_seconds() // 60 <= 0: sg.PopupAutoClose('stop must be bigger than start') else: cycle_id: int = int(values['_cycle_id_']) myEngine: Engine = Engine(start, stop, cycle_id) sg.PopupAutoClose(myEngine) print(myEngine) if event in ('Exit', 'Window closed using X'): break