(root, tweet_bool, twitter_state)
Creates a window to let users select which tweets or favorites
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param tweet_bool: true for tweets, false for favorites
    :param twitter_state: dictionary holding twitter settings
    :return: none
Creates a window to let users select which tweets or favorites
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param tweet_bool: true for tweets, false for favorites
    :param twitter_state: dictionary holding twitter settings
    :return: none
Creates a window to let users select which tweets or favorites to whitelist : param root : the reference to the actual tkinter GUI window : param tweet_bool : true for tweets false for favorites : param twitter_state : dictionary holding twitter settings : return : none
def set_twitter_whitelist(root, tweet_bool, twitter_state):
    """
    Creates a window to let users select which tweets or favorites
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param tweet_bool: true for tweets, false for favorites
    :param twitter_state: dictionary holding twitter settings
    :return: none
    """
    global twitter_api
    # TODO: update this to get whether checkbox is selected or unselected instead of blindly flipping from true to false

    def flip_whitelist_dict(id, identifying_text):
        whitelist_dict = twitter_state[f'whitelisted_{identifying_text}']
        whitelist_dict[id] = not whitelist_dict[id]
        twitter_state[f'whitelisted_{identifying_text}'] = whitelist_dict
        twitter_state.sync

    def onFrameConfigure(canvas):
        '''Reset the scroll region to encompass the inner frame'''
        canvas.configure(scrollregion=canvas.bbox("all"))

    def closeWindow(whitelist_window):
        twitter_state['whitelist_window_open'] = 0
        whitelist_window.destroy()

    if tweet_bool:
        identifying_text = 'tweets'
        item_array = gather_items(twitter_api.user_timeline)
    else:
        identifying_text = 'favorites'
        item_array = gather_items(twitter_api.favorites)

    whitelist_window = tk.Toplevel(root)
    twitter_state['whitelist_window_open'] = 1

    whitelist_window.protocol(
        'WM_DELETE_WINDOW', lambda: closeWindow(whitelist_window))

    frame = build_window(root, whitelist_window,
                         f'Pick {identifying_text} to save')

    counter = 3
    for item in item_array:
        if (item.id not in twitter_state[f'whitelisted_{identifying_text}']):
            # I wish I could tell you why I need to copy the dictionary of whitelisted items, and then modify it, and then
            #   reassign it back to the persistant shelf. I don't know why this is needed, but it works.
            whitelist_dict = twitter_state[f'whitelisted_{identifying_text}']
            whitelist_dict[item.id] = False
            twitter_state[f'whitelisted_{identifying_text}'] = whitelist_dict
            twitter_state.sync

        whitelist_checkbutton = tk.Checkbutton(frame, command=lambda
                                               id=item.id: flip_whitelist_dict(id, identifying_text))

        if (twitter_state[f'whitelisted_{identifying_text}'][item.id]):
            whitelist_checkbutton.select()
        else:
            whitelist_checkbutton.deselect()

        whitelist_checkbutton.grid(row=counter, column=0)
        tk.Label(frame,
                 text=helpers.format_snippet(item.text, 100)).grid(row=counter, column=1)

        ttk.Separator(frame, orient=tk.HORIZONTAL).grid(
            row=counter+1, columnspan=2, sticky=(tk.E, tk.W), pady=5)

        counter = counter + 2
def set_twitter_whitelist ( root , tweet_bool , twitter_state ) : global twitter_api # TODO: update this to get whether checkbox is selected or unselected instead of blindly flipping from true to false def flip_whitelist_dict ( id , identifying_text ) : whitelist_dict = twitter_state [ f'whitelisted_{identifying_text}' ] whitelist_dict [ id ] = not whitelist_dict [ id ] twitter_state [ f'whitelisted_{identifying_text}' ] = whitelist_dict twitter_state . sync def onFrameConfigure ( canvas ) : '''Reset the scroll region to encompass the inner frame''' canvas . configure ( scrollregion = canvas . bbox ( "all" ) ) def closeWindow ( whitelist_window ) : twitter_state [ 'whitelist_window_open' ] = 0 whitelist_window . destroy ( ) if tweet_bool : identifying_text = 'tweets' item_array = gather_items ( twitter_api . user_timeline ) else : identifying_text = 'favorites' item_array = gather_items ( twitter_api . favorites ) whitelist_window = tk . Toplevel ( root ) twitter_state [ 'whitelist_window_open' ] = 1 whitelist_window . protocol ( 'WM_DELETE_WINDOW' , lambda : closeWindow ( whitelist_window ) ) frame = build_window ( root , whitelist_window , f'Pick {identifying_text} to save' ) counter = 3 for item in item_array : if ( item . id not in twitter_state [ f'whitelisted_{identifying_text}' ] ) : # I wish I could tell you why I need to copy the dictionary of whitelisted items, and then modify it, and then #   reassign it back to the persistant shelf. I don't know why this is needed, but it works. whitelist_dict = twitter_state [ f'whitelisted_{identifying_text}' ] whitelist_dict [ item . id ] = False twitter_state [ f'whitelisted_{identifying_text}' ] = whitelist_dict twitter_state . sync whitelist_checkbutton = tk . Checkbutton ( frame , command = lambda id = item . id : flip_whitelist_dict ( id , identifying_text ) ) if ( twitter_state [ f'whitelisted_{identifying_text}' ] [ item . id ] ) : whitelist_checkbutton . select ( ) else : whitelist_checkbutton . deselect ( ) whitelist_checkbutton . grid ( row = counter , column = 0 ) tk . Label ( frame , text = helpers . format_snippet ( item . text , 100 ) ) . grid ( row = counter , column = 1 ) ttk . Separator ( frame , orient = tk . HORIZONTAL ) . grid ( row = counter + 1 , columnspan = 2 , sticky = ( tk . E , tk . W ) , pady = 5 ) counter = counter + 2