except AttributeError: pass try: # see if something has been posted to Queue message = sb.QUEUE_TO_GUI.get_nowait() sb.QUEUE_FROM_GUI.put(sg.popup_yes_no(message)) except queue.Empty: # get_nowait() will get exception when Queue is empty pass # break from the loop if no more messages are queued up if event == "SPORT": sport = values["SPORT"][0] competitions = get_all_competitions(sport) window['COMPETITIONS'].update(values=competitions) window['MAIN_COMPETITIONS'].update(visible=sport=="football") elif event == "SELECT_NONE_COMPETITION": window['COMPETITIONS'].update(set_to_index=[]) elif event == "CURRENT_COMPETITIONS": thread_competitions = threading.Thread(target=lambda : get_current_competitions_interface(window, values)) thread_competitions.start() elif event == "MAIN_COMPETITIONS": competitions = get_all_competitions(sport) big_five = ["France - Ligue 1", "Angleterre - Premier League", "Allemagne - Bundesliga", "Italie - Serie A", "Espagne - LaLiga"] window['COMPETITIONS'].update(set_to_index=[i for i, competition in enumerate(competitions) if competition in big_five]) elif event == "SELECT_ALL": window['SITES'].update(set_to_index=[i for i, _ in enumerate(sb.BOOKMAKERS)]) elif event == "SELECT_NONE_SITE": window['SITES'].update(set_to_index=[]) elif event == 'START_PARSING': selected_competitions = values["COMPETITIONS"] selected_sites = values["SITES"] window["MATCHES_ODDS"].update([]) window["MATCHES"].update([]) if selected_competitions and selected_sites:
except AttributeError: pass try: # see if something has been posted to Queue message = sportsbetting.QUEUE_TO_GUI.get_nowait() sportsbetting.QUEUE_FROM_GUI.put(sg.popup_yes_no(message)) except queue.Empty: # get_nowait() will get exception when Queue is empty pass # break from the loop if no more messages are queued up if event == "SPORT": sport = values["SPORT"][0] competitions = get_all_competitions(sport) window['COMPETITIONS'].update(values=competitions) elif event == "SELECT_NONE_COMPETITION": window['COMPETITIONS'].update(set_to_index=[]) elif event == "CURRENT_COMPETITIONS": thread_competitions = threading.Thread( target=lambda: get_current_competitions_interface(window, values)) thread_competitions.start() elif event == "MAIN_COMPETITIONS": get_main_competitions_interface(window, values) elif event == "SELECT_ALL": window['SITES'].update(set_to_index=[i for i, _ in enumerate(sites)]) elif event == "SELECT_NONE_SITE": window['SITES'].update(set_to_index=[]) elif event == 'START_PARSING': selected_competitions = values["COMPETITIONS"] selected_sites = values["SITES"] window["MATCHES_ODDS"].update([]) window["MATCHES"].update([]) if selected_competitions and selected_sites: window["STOP_PARSING"].update(visible=True) window["START_PARSING"].update(visible=False)
window["PROGRESS_STAKES"].UpdateBar(ceil(sportsbetting.PROGRESS), 100) except AttributeError: pass try: # see if something has been posted to Queue message = sportsbetting.QUEUE_TO_GUI.get_nowait() sportsbetting.QUEUE_FROM_GUI.put(sg.popup_yes_no(message)) except queue.Empty: # get_nowait() will get exception when Queue is empty pass # break from the loop if no more messages are queued up if event == "SPORT": sport = values["SPORT"][0] competitions = get_all_competitions(sport) window['COMPETITIONS'].update(values=competitions) elif event == "SELECT_NONE_COMPETITION": window['COMPETITIONS'].update(set_to_index=[]) elif event == "CURRENT_COMPETITIONS": get_current_competitions_interface(window, values) elif event == "MAIN_COMPETITIONS": get_main_competitions_interface(window, values) elif event == "SELECT_ALL": window['SITES'].update(set_to_index=[i for i, _ in enumerate(sites)]) elif event == "SELECT_NONE_SITE": window['SITES'].update(set_to_index=[]) elif event == 'START_PARSING': selected_competitions = values["COMPETITIONS"] selected_sites = values["SITES"] window["MATCHES_ODDS"].update([]) window["MATCHES"].update([]) if selected_competitions and selected_sites: def parse_thread(): """ :return: Crée un thread pour le parsing des compétitions