(root, currently_deleting_text, deletion_progress_bar, num_deleted_items_text, twitter_state, scheduled_bool)
Deletes user's tweets according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param twitter_state: dictionary holding twitter settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
Deletes user's tweets according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param twitter_state: dictionary holding twitter settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
Deletes user s tweets according to user configurations . : param root : the reference to the actual tkinter GUI window : param currently_deleting_text : Describes the item that is currently being deleted . : param deletion_progress_bar : updates as the items are looped through : param num_deleted_items_text : updates as X out of Y comments are looped through : param twitter_state : dictionary holding twitter settings : param scheduled_bool : True if a scheduled run False if triggered manually : return : none
def delete_twitter_tweets(root, currently_deleting_text, deletion_progress_bar, num_deleted_items_text, twitter_state, scheduled_bool):
    """
    Deletes user's tweets according to user configurations.
    :param root: the reference to the actual tkinter GUI window
    :param currently_deleting_text: Describes the item that is currently being deleted.
    :param deletion_progress_bar: updates as the items are looped through
    :param num_deleted_items_text: updates as X out of Y comments are looped through
    :param twitter_state: dictionary holding twitter settings
    :param scheduled_bool: True if a scheduled run, False if triggered manually
    :return: none
    """
    if twitter_state['confirmation_window_open'] == 1 and not scheduled_bool:
        return

    global twitter_api

    confirmation_window = tk.Toplevel(root)
    twitter_state['confirmation_window_open'] = 1
    twitter_state.sync

    confirmation_window.protocol(
        'WM_DELETE_WINDOW', lambda: close_window(confirmation_window, twitter_state, 'confirmation_window_open'))

    frame = build_window(root, confirmation_window,
                         f"The following tweets will be deleted")

    user_tweets = gather_items(twitter_api.user_timeline)
    total_tweets = len(user_tweets)

    num_deleted_items_text.set(f'0/{str(total_tweets)} items processed so far')

    button_frame = tk.Frame(frame)
    button_frame.grid(row=1, column=0, sticky='w')

    def delete_tweets():
        close_window(confirmation_window, twitter_state,
                     'confirmation_window_open')

        count = 1
        for tweet in user_tweets:
            tweet_snippet = helpers.format_snippet(tweet.text, 50)

            time_created = arrow.Arrow.fromdatetime(tweet.created_at)

            if time_created > twitter_state['time_to_save']:
                currently_deleting_text.set(
                    f'Tweet: `{tweet_snippet}` is more recent than cutoff, skipping.')
            elif tweet.favorite_count >= twitter_state['max_favorites']:
                currently_deleting_text.set(
                    f'Tweet: `{tweet_snippet}` has more favorites than max favorites, skipping.')
            elif tweet.retweet_count >= twitter_state['max_retweets'] and not tweet.retweeted:
                currently_deleting_text.set(
                    f'Tweet: `{tweet_snippet}` has more retweets than max retweets, skipping.')
            elif tweet.id in twitter_state['whitelisted_tweets'] and twitter_state['whitelisted_tweets'][tweet.id]:
                currently_deleting_text.set(
                    f'Tweet: `{tweet_snippet}` is whitelisted, skipping.')
            else:
                currently_deleting_text.set(
                    f'Deleting tweet: `{tweet_snippet}`')
                twitter_api.destroy_status(tweet.id)

            num_deleted_items_text.set(
                f'{str(count)}/{str(total_tweets)} items processed.')
            deletion_progress_bar['value'] = round(
                (count / total_tweets) * 100, 1)

            root.update()

            count += 1

    proceed_button = tk.Button(
        button_frame, text='Proceed', command=lambda: delete_tweets())
    cancel_button = tk.Button(button_frame, text='Cancel',
                              command=lambda: close_window(confirmation_window, twitter_state, 'confirmation_window_open'))

    proceed_button.grid(row=1, column=0, sticky='nsew')
    cancel_button.grid(row=1, column=1, sticky='nsew')

    counter = 3

    for tweet in user_tweets:
        time_created = arrow.Arrow.fromdatetime(tweet.created_at)

        if time_created > twitter_state['time_to_save']:
            pass
        elif tweet.favorite_count >= twitter_state['max_favorites']:
            pass
        elif tweet.retweet_count >= twitter_state['max_retweets'] and not tweet.retweeted:
            pass
        elif tweet.id in twitter_state['whitelisted_tweets'] and twitter_state['whitelisted_tweets'][tweet.id]:
            pass
        else:
            tk.Label(frame, text=helpers.format_snippet(
                tweet.text, 100)).grid(row=counter, column=0)
            ttk.Separator(frame, orient=tk.HORIZONTAL).grid(
                row=counter+1, columnspan=2, sticky='ew', pady=5)

        counter = counter + 2
def delete_twitter_tweets ( root , currently_deleting_text , deletion_progress_bar , num_deleted_items_text , twitter_state , scheduled_bool ) : if twitter_state [ 'confirmation_window_open' ] == 1 and not scheduled_bool : return global twitter_api confirmation_window = tk . Toplevel ( root ) twitter_state [ 'confirmation_window_open' ] = 1 twitter_state . sync confirmation_window . protocol ( 'WM_DELETE_WINDOW' , lambda : close_window ( confirmation_window , twitter_state , 'confirmation_window_open' ) ) frame = build_window ( root , confirmation_window , f"The following tweets will be deleted" ) user_tweets = gather_items ( twitter_api . user_timeline ) total_tweets = len ( user_tweets ) num_deleted_items_text . set ( f'0/{str(total_tweets)} items processed so far' ) button_frame = tk . Frame ( frame ) button_frame . grid ( row = 1 , column = 0 , sticky = 'w' ) def delete_tweets ( ) : close_window ( confirmation_window , twitter_state , 'confirmation_window_open' ) count = 1 for tweet in user_tweets : tweet_snippet = helpers . format_snippet ( tweet . text , 50 ) time_created = arrow . Arrow . fromdatetime ( tweet . created_at ) if time_created > twitter_state [ 'time_to_save' ] : currently_deleting_text . set ( f'Tweet: `{tweet_snippet}` is more recent than cutoff, skipping.' ) elif tweet . favorite_count >= twitter_state [ 'max_favorites' ] : currently_deleting_text . set ( f'Tweet: `{tweet_snippet}` has more favorites than max favorites, skipping.' ) elif tweet . retweet_count >= twitter_state [ 'max_retweets' ] and not tweet . retweeted : currently_deleting_text . set ( f'Tweet: `{tweet_snippet}` has more retweets than max retweets, skipping.' ) elif tweet . id in twitter_state [ 'whitelisted_tweets' ] and twitter_state [ 'whitelisted_tweets' ] [ tweet . id ] : currently_deleting_text . set ( f'Tweet: `{tweet_snippet}` is whitelisted, skipping.' ) else : currently_deleting_text . set ( f'Deleting tweet: `{tweet_snippet}`' ) twitter_api . destroy_status ( tweet . id ) num_deleted_items_text . set ( f'{str(count)}/{str(total_tweets)} items processed.' ) deletion_progress_bar [ 'value' ] = round ( ( count / total_tweets ) * 100 , 1 ) root . update ( ) count += 1 proceed_button = tk . Button ( button_frame , text = 'Proceed' , command = lambda : delete_tweets ( ) ) cancel_button = tk . Button ( button_frame , text = 'Cancel' , command = lambda : close_window ( confirmation_window , twitter_state , 'confirmation_window_open' ) ) proceed_button . grid ( row = 1 , column = 0 , sticky = 'nsew' ) cancel_button . grid ( row = 1 , column = 1 , sticky = 'nsew' ) counter = 3 for tweet in user_tweets : time_created = arrow . Arrow . fromdatetime ( tweet . created_at ) if time_created > twitter_state [ 'time_to_save' ] : pass elif tweet . favorite_count >= twitter_state [ 'max_favorites' ] : pass elif tweet . retweet_count >= twitter_state [ 'max_retweets' ] and not tweet . retweeted : pass elif tweet . id in twitter_state [ 'whitelisted_tweets' ] and twitter_state [ 'whitelisted_tweets' ] [ tweet . id ] : pass else : tk . Label ( frame , text = helpers . format_snippet ( tweet . text , 100 ) ) . grid ( row = counter , column = 0 ) ttk . Separator ( frame , orient = tk . HORIZONTAL ) . grid ( row = counter + 1 , columnspan = 2 , sticky = 'ew' , pady = 5 ) counter = counter + 2