(root, comment_bool, reddit_state)
Creates a window to let users select which comments or posts
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true for comments, false for posts
    :param reddit_state: dictionary holding reddit settings
    :return: none
Creates a window to let users select which comments or posts
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true for comments, false for posts
    :param reddit_state: dictionary holding reddit settings
    :return: none
Creates a window to let users select which comments or posts to whitelist : param root : the reference to the actual tkinter GUI window : param comment_bool : true for comments false for posts : param reddit_state : dictionary holding reddit settings : return : none
def set_reddit_whitelist(root, comment_bool, reddit_state):
    """
    Creates a window to let users select which comments or posts
        to whitelist
    :param root: the reference to the actual tkinter GUI window
    :param comment_bool: true for comments, false for posts
    :param reddit_state: dictionary holding reddit settings
    :return: none
    """
    # 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 = reddit_state[f'whitelisted_{identifying_text}']
        whitelist_dict[id] = not whitelist_dict[id]
        reddit_state[f'whitelisted_{identifying_text}'] = whitelist_dict
        reddit_state.sync

    if reddit_state['whitelist_window_open'] == 1:
        return

    if comment_bool:
        identifying_text = 'comments'
        item_array = reddit_state['user'].comments.new(limit=None)
    else:
        identifying_text = 'posts'
        item_array = reddit_state['user'].submissions.new(limit=None)

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

    whitelist_window.protocol(
        'WM_DELETE_WINDOW', lambda: close_window(whitelist_window, reddit_state, 'whitelist_window_open'))

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

    counter = 3
    for item in item_array:
        if (item.id not in reddit_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 = reddit_state[f'whitelisted_{identifying_text}']
            whitelist_dict[item.id] = False
            reddit_state[f'whitelisted_{identifying_text}'] = whitelist_dict
            reddit_state.sync

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

        if (reddit_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.body if comment_bool else item.title, 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_reddit_whitelist ( root , comment_bool , reddit_state ) : # 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 = reddit_state [ f'whitelisted_{identifying_text}' ] whitelist_dict [ id ] = not whitelist_dict [ id ] reddit_state [ f'whitelisted_{identifying_text}' ] = whitelist_dict reddit_state . sync if reddit_state [ 'whitelist_window_open' ] == 1 : return if comment_bool : identifying_text = 'comments' item_array = reddit_state [ 'user' ] . comments . new ( limit = None ) else : identifying_text = 'posts' item_array = reddit_state [ 'user' ] . submissions . new ( limit = None ) whitelist_window = tk . Toplevel ( root ) reddit_state [ 'whitelist_window_open' ] = 1 reddit_state . sync whitelist_window . protocol ( 'WM_DELETE_WINDOW' , lambda : close_window ( whitelist_window , reddit_state , 'whitelist_window_open' ) ) frame = build_window ( root , whitelist_window , f'Pick {identifying_text} to save' ) counter = 3 for item in item_array : if ( item . id not in reddit_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 = reddit_state [ f'whitelisted_{identifying_text}' ] whitelist_dict [ item . id ] = False reddit_state [ f'whitelisted_{identifying_text}' ] = whitelist_dict reddit_state . sync whitelist_checkbutton = tk . Checkbutton ( frame , command = lambda id = item . id : flip_whitelist_dict ( id , identifying_text ) ) if ( reddit_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 . body if comment_bool else item . title , 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