(self)
return frame
Build the tab that will handle Reddit configuration and actions
        :return: Set up Reddit frame
Build the tab that will handle Reddit configuration and actions
        :return: Set up Reddit frame
Build the tab that will handle Reddit configuration and actions : return : Set up Reddit frame
def build_reddit_tab(self):
        """
        Build the tab that will handle Reddit configuration and actions
        :return: Set up Reddit frame
        """
        global reddit_state

        frame = tk.Frame(self.tabs)

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

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

        scheduler_frame = tk.Frame(frame)
        scheduler_frame.grid(row=2, column=0, sticky='w')

        # Configuration section title
        configuration_label = tk.Label(
            configuration_frame, text='Configuration')
        configuration_label.config(font=('arial', 25))

        # Configuration to set total time of items to save
        current_time_to_save = tk.StringVar()
        if 'hours' in reddit_state:
            def get_text(time, text):
                return '' if time == '0' else time + text

            hours_text = get_text(reddit_state['hours'], 'hours')
            days_text = get_text(reddit_state['days'], 'days')
            weeks_text = get_text(reddit_state['weeks'], 'weeks')
            years_text = get_text(reddit_state['years'], 'years')

            current_time_to_save.set(
                f'Currently set to save: [{years_text} {weeks_text} {days_text} {hours_text}] of items')
        else:
            current_time_to_save.set('Currently set to save: [nothing]')
        time_keep_label = tk.Label(
            configuration_frame, text='Keep comments/submissions younger than: ')

        hours_dropdown = create_dropdown(configuration_frame, 2, 24)
        days_dropdown = create_dropdown(configuration_frame, 2, 7)
        weeks_dropdown = create_dropdown(configuration_frame, 2, 52)
        years_dropdown = create_dropdown(configuration_frame, 2, 15)

        hours_label = tk.Label(configuration_frame, text='hours')
        days_label = tk.Label(configuration_frame, text='days')
        weeks_label = tk.Label(configuration_frame, text='weeks')
        years_label = tk.Label(configuration_frame, text='years')

        time_currently_set_label = tk.Label(
            configuration_frame, textvariable=current_time_to_save)
        set_time_button = tk.Button(
            configuration_frame, text='Set Total Time To Keep',
            command=lambda: reddit.set_reddit_time_to_save(
                hours_dropdown.get(), days_dropdown.get(),
                weeks_dropdown.get(), years_dropdown.get(),
                current_time_to_save, reddit_state)
        )

        # Configuration to set saving items with a certain amount of upvotes
        current_max_score = tk.StringVar()
        if 'max_score' in reddit_state:
            if reddit_state['max_score'] == 9999999999:
                reddit.set_reddit_max_score(
                    'Unlimited', current_max_score, reddit_state)
            else:
                reddit.set_reddit_max_score(
                    reddit_state['max_score'], current_max_score, reddit_state)
        else:
            current_max_score.set('Currently set to: 0 upvotes')

        max_score_label = tk.Label(
            configuration_frame, text='Delete comments/submissions less than score:')
        max_score_entry_field = tk.Entry(configuration_frame, width=5)
        max_score_currently_set_label = tk.Label(
            configuration_frame, textvariable=current_max_score)

        set_max_score_button = tk.Button(
            configuration_frame, text='Set Max Score',
            command=lambda: reddit.set_reddit_max_score(
                max_score_entry_field.get(), current_max_score, reddit_state)
        )
        set_max_score_unlimited_button = tk.Button(
            configuration_frame, text='Set Unlimited',
            command=lambda: reddit.set_reddit_max_score(
                'Unlimited', current_max_score, reddit_state)
        )

        # Configuration to let user skip over gilded comments
        gilded_skip_bool = tk.IntVar()
        # Skip gilded posts by default
        if 'gilded_skip' in reddit_state:
            if reddit_state['gilded_skip'] == 0:
                gilded_skip_bool.set(0)
            else:
                gilded_skip_bool.set(1)
        else:
            gilded_skip_bool.set(1)
        gilded_skip_label = tk.Label(
            configuration_frame, text='Skip Gilded items:')
        gilded_skip_check_button = tk.Checkbutton(
            configuration_frame, variable=gilded_skip_bool,
            command=lambda: reddit.set_reddit_gilded_skip(gilded_skip_bool, reddit_state))

        # Multiple edits
        multi_edit_bool = tk.IntVar()
        if 'multi_edit' in reddit_state:
            if reddit_state['multi_edit'] == 0:
                multi_edit_bool.set(0)
            else:
                multi_edit_bool.set(1)
        multi_edit_label = tk.Label(
            configuration_frame, text='Edit item multiple times before deleting (runs slightly slower):')
        multi_edit_check_button = tk.Checkbutton(
            configuration_frame, variable=multi_edit_bool, command=lambda: reddit.set_multi_edit(multi_edit_bool, reddit_state))

        # Don't delete comments, only edit
        only_edit_bool = tk.IntVar()
        if 'only_edit' in reddit_state:
            if reddit_state['only_edit'] == 0:
                only_edit_bool.set(0)
            else:
                only_edit_bool.set(1)
        only_edit_label = tk.Label(
            configuration_frame, text='Only edit items, do not delete:')
        only_edit_check_button = tk.Checkbutton(
            configuration_frame, variable=only_edit_bool, command=lambda: reddit.set_only_edit(only_edit_bool, reddit_state))

        # White listing
        whitelist_label = tk.Label(
            configuration_frame, text='Whitelist comments or submissions:')
        modify_whitelist_comments_button = tk.Button(
            configuration_frame, text='Pick comments to whitelist',
            command=lambda: reddit.set_reddit_whitelist(
                root, True, reddit_state)
        )
        modify_whitelist_posts_button = tk.Button(
            configuration_frame, text='Pick posts to whitelist',
            command=lambda: reddit.set_reddit_whitelist(
                root, False, reddit_state)
        )

        # Allows the user to actually delete comments or submissions
        deletion_section_label = tk.Label(deletion_frame, text='Deletion')
        deletion_section_label.config(font=('arial', 25))

        currently_deleting_text = tk.StringVar()
        currently_deleting_text.set('')
        deletion_progress_label = tk.Label(
            deletion_frame, textvariable=currently_deleting_text)

        deletion_progress_bar = ttk.Progressbar(
            deletion_frame, orient='horizontal',
            length=100, mode='determinate')

        num_deleted_items_text = tk.StringVar()
        num_deleted_items_text.set('')
        num_deleted_items_label = tk.Label(
            deletion_frame, textvariable=num_deleted_items_text)

        delete_comments_button = tk.Button(
            deletion_frame, text='Delete comments',
            command=lambda: reddit.delete_reddit_items(
                root, True, currently_deleting_text,
                deletion_progress_bar, num_deleted_items_text, reddit_state, False)
        )

        delete_submissions_button = tk.Button(
            deletion_frame, text='Delete submissions',
            command=lambda: reddit.delete_reddit_items(
                root, False, currently_deleting_text,
                deletion_progress_bar, num_deleted_items_text, reddit_state, False)
        )

        # Allows the user to schedule runs
        scheduler_section_label = tk.Label(scheduler_frame, text='Scheduler')
        scheduler_section_label.config(font=('arial', 25))

        scheduler_bool = tk.IntVar()
        scheduler_bool.set(0)

        scheduler_text = 'Select to delete reddit comments + submissions daily at'

        scheduler_hours_dropdown = create_dropdown(scheduler_frame, 2, 24)

        scheduler_currently_set_text = tk.StringVar()
        if 'scheduled_time' in reddit_state:
            scheduler_currently_set_text.set(
                f'Currently set to: {reddit_state["scheduled_time"]}')
        else:
            scheduler_currently_set_text.set('Currently set to: No time set')
        scheduler_currently_set_time_label = tk.Label(
            scheduler_frame, textvariable=scheduler_currently_set_text)

        scheduler_check_button = tk.Checkbutton(
            scheduler_frame, text=scheduler_text,
            variable=scheduler_bool,
            command=lambda: reddit.set_reddit_scheduler(
                root, scheduler_bool,
                int(scheduler_hours_dropdown.get()),
                tk.StringVar(), ttk.Progressbar(), scheduler_currently_set_text, reddit_state))

        # This part actually builds the reddit tab
        configuration_label.grid(row=0, column=0, sticky='w')
        time_keep_label.grid(row=1, column=0, sticky='w')
        hours_dropdown.grid(row=1, column=1, sticky='w')
        hours_label.grid(row=1, column=2, sticky='w')
        days_dropdown.grid(row=1, column=3, sticky='w')
        days_label.grid(row=1, column=4, sticky='w')
        weeks_dropdown.grid(row=1, column=5, sticky='w')
        weeks_label.grid(row=1, column=6, sticky='w')
        years_dropdown.grid(row=1, column=7, sticky='w')
        years_label.grid(row=1, column=8, sticky='w')
        set_time_button.grid(row=1, column=9, columnspan=2)
        time_currently_set_label.grid(row=1, column=11)

        max_score_label.grid(row=2, column=0, sticky='w')
        max_score_entry_field.grid(row=2, column=1, sticky='w')
        set_max_score_button.grid(row=2, column=9, sticky='w')
        set_max_score_unlimited_button.grid(row=2, column=10, sticky='w')
        max_score_currently_set_label.grid(row=2, column=11, sticky='w')

        gilded_skip_label.grid(row=3, column=0, sticky='w')
        gilded_skip_check_button.grid(row=3, column=1, sticky='w')

        multi_edit_label.grid(row=4, column=0, sticky='w')
        multi_edit_check_button.grid(row=4, column=1, sticky='w')

        only_edit_label.grid(row=5, column=0, sticky='w')
        only_edit_check_button.grid(row=5, column=1, sticky='w')

        whitelist_label.grid(row=6, column=0, sticky='w')
        modify_whitelist_comments_button.grid(
            row=6, column=1, columnspan=4, sticky='w')
        modify_whitelist_posts_button.grid(
            row=6, column=5, columnspan=4, sticky='w')

        ttk.Separator(configuration_frame, orient=tk.HORIZONTAL).grid(
            row=7, columnspan=13, sticky='ew', pady=5)

        deletion_section_label.grid(row=0, column=0, sticky='w')

        delete_comments_button.grid(row=1, column=0, sticky='w')
        delete_submissions_button.grid(row=1, column=1, sticky='w')

        deletion_progress_bar.grid(row=2, column=0, sticky='w')
        num_deleted_items_label.grid(row=2, column=1, sticky='w')
        deletion_progress_label.grid(row=2, column=2, sticky='w')

        ttk.Separator(deletion_frame, orient=tk.HORIZONTAL).grid(
            row=3, columnspan=3, sticky='ew', pady=5)

        scheduler_section_label.grid(
            row=0, column=0, sticky='w')
        scheduler_check_button.grid(row=1, column=0, sticky='w')
        scheduler_hours_dropdown.grid(row=1, column=1, sticky='w')
        scheduler_currently_set_time_label.grid(row=1, column=2, sticky='w')

        return frame
def build_reddit_tab ( self ) : global reddit_state frame = tk . Frame ( self . tabs ) configuration_frame = tk . Frame ( frame ) configuration_frame . grid ( row = 0 , column = 0 , sticky = 'w' ) deletion_frame = tk . Frame ( frame ) deletion_frame . grid ( row = 1 , column = 0 , sticky = 'w' ) scheduler_frame = tk . Frame ( frame ) scheduler_frame . grid ( row = 2 , column = 0 , sticky = 'w' ) # Configuration section title configuration_label = tk . Label ( configuration_frame , text = 'Configuration' ) configuration_label . config ( font = ( 'arial' , 25 ) ) # Configuration to set total time of items to save current_time_to_save = tk . StringVar ( ) if 'hours' in reddit_state : def get_text ( time , text ) : return '' if time == '0' else time + text hours_text = get_text ( reddit_state [ 'hours' ] , 'hours' ) days_text = get_text ( reddit_state [ 'days' ] , 'days' ) weeks_text = get_text ( reddit_state [ 'weeks' ] , 'weeks' ) years_text = get_text ( reddit_state [ 'years' ] , 'years' ) current_time_to_save . set ( f'Currently set to save: [{years_text} {weeks_text} {days_text} {hours_text}] of items' ) else : current_time_to_save . set ( 'Currently set to save: [nothing]' ) time_keep_label = tk . Label ( configuration_frame , text = 'Keep comments/submissions younger than: ' ) hours_dropdown = create_dropdown ( configuration_frame , 2 , 24 ) days_dropdown = create_dropdown ( configuration_frame , 2 , 7 ) weeks_dropdown = create_dropdown ( configuration_frame , 2 , 52 ) years_dropdown = create_dropdown ( configuration_frame , 2 , 15 ) hours_label = tk . Label ( configuration_frame , text = 'hours' ) days_label = tk . Label ( configuration_frame , text = 'days' ) weeks_label = tk . Label ( configuration_frame , text = 'weeks' ) years_label = tk . Label ( configuration_frame , text = 'years' ) time_currently_set_label = tk . Label ( configuration_frame , textvariable = current_time_to_save ) set_time_button = tk . Button ( configuration_frame , text = 'Set Total Time To Keep' , command = lambda : reddit . set_reddit_time_to_save ( hours_dropdown . get ( ) , days_dropdown . get ( ) , weeks_dropdown . get ( ) , years_dropdown . get ( ) , current_time_to_save , reddit_state ) ) # Configuration to set saving items with a certain amount of upvotes current_max_score = tk . StringVar ( ) if 'max_score' in reddit_state : if reddit_state [ 'max_score' ] == 9999999999 : reddit . set_reddit_max_score ( 'Unlimited' , current_max_score , reddit_state ) else : reddit . set_reddit_max_score ( reddit_state [ 'max_score' ] , current_max_score , reddit_state ) else : current_max_score . set ( 'Currently set to: 0 upvotes' ) max_score_label = tk . Label ( configuration_frame , text = 'Delete comments/submissions less than score:' ) max_score_entry_field = tk . Entry ( configuration_frame , width = 5 ) max_score_currently_set_label = tk . Label ( configuration_frame , textvariable = current_max_score ) set_max_score_button = tk . Button ( configuration_frame , text = 'Set Max Score' , command = lambda : reddit . set_reddit_max_score ( max_score_entry_field . get ( ) , current_max_score , reddit_state ) ) set_max_score_unlimited_button = tk . Button ( configuration_frame , text = 'Set Unlimited' , command = lambda : reddit . set_reddit_max_score ( 'Unlimited' , current_max_score , reddit_state ) ) # Configuration to let user skip over gilded comments gilded_skip_bool = tk . IntVar ( ) # Skip gilded posts by default if 'gilded_skip' in reddit_state : if reddit_state [ 'gilded_skip' ] == 0 : gilded_skip_bool . set ( 0 ) else : gilded_skip_bool . set ( 1 ) else : gilded_skip_bool . set ( 1 ) gilded_skip_label = tk . Label ( configuration_frame , text = 'Skip Gilded items:' ) gilded_skip_check_button = tk . Checkbutton ( configuration_frame , variable = gilded_skip_bool , command = lambda : reddit . set_reddit_gilded_skip ( gilded_skip_bool , reddit_state ) ) # Multiple edits multi_edit_bool = tk . IntVar ( ) if 'multi_edit' in reddit_state : if reddit_state [ 'multi_edit' ] == 0 : multi_edit_bool . set ( 0 ) else : multi_edit_bool . set ( 1 ) multi_edit_label = tk . Label ( configuration_frame , text = 'Edit item multiple times before deleting (runs slightly slower):' ) multi_edit_check_button = tk . Checkbutton ( configuration_frame , variable = multi_edit_bool , command = lambda : reddit . set_multi_edit ( multi_edit_bool , reddit_state ) ) # Don't delete comments, only edit only_edit_bool = tk . IntVar ( ) if 'only_edit' in reddit_state : if reddit_state [ 'only_edit' ] == 0 : only_edit_bool . set ( 0 ) else : only_edit_bool . set ( 1 ) only_edit_label = tk . Label ( configuration_frame , text = 'Only edit items, do not delete:' ) only_edit_check_button = tk . Checkbutton ( configuration_frame , variable = only_edit_bool , command = lambda : reddit . set_only_edit ( only_edit_bool , reddit_state ) ) # White listing whitelist_label = tk . Label ( configuration_frame , text = 'Whitelist comments or submissions:' ) modify_whitelist_comments_button = tk . Button ( configuration_frame , text = 'Pick comments to whitelist' , command = lambda : reddit . set_reddit_whitelist ( root , True , reddit_state ) ) modify_whitelist_posts_button = tk . Button ( configuration_frame , text = 'Pick posts to whitelist' , command = lambda : reddit . set_reddit_whitelist ( root , False , reddit_state ) ) # Allows the user to actually delete comments or submissions deletion_section_label = tk . Label ( deletion_frame , text = 'Deletion' ) deletion_section_label . config ( font = ( 'arial' , 25 ) ) currently_deleting_text = tk . StringVar ( ) currently_deleting_text . set ( '' ) deletion_progress_label = tk . Label ( deletion_frame , textvariable = currently_deleting_text ) deletion_progress_bar = ttk . Progressbar ( deletion_frame , orient = 'horizontal' , length = 100 , mode = 'determinate' ) num_deleted_items_text = tk . StringVar ( ) num_deleted_items_text . set ( '' ) num_deleted_items_label = tk . Label ( deletion_frame , textvariable = num_deleted_items_text ) delete_comments_button = tk . Button ( deletion_frame , text = 'Delete comments' , command = lambda : reddit . delete_reddit_items ( root , True , currently_deleting_text , deletion_progress_bar , num_deleted_items_text , reddit_state , False ) ) delete_submissions_button = tk . Button ( deletion_frame , text = 'Delete submissions' , command = lambda : reddit . delete_reddit_items ( root , False , currently_deleting_text , deletion_progress_bar , num_deleted_items_text , reddit_state , False ) ) # Allows the user to schedule runs scheduler_section_label = tk . Label ( scheduler_frame , text = 'Scheduler' ) scheduler_section_label . config ( font = ( 'arial' , 25 ) ) scheduler_bool = tk . IntVar ( ) scheduler_bool . set ( 0 ) scheduler_text = 'Select to delete reddit comments + submissions daily at' scheduler_hours_dropdown = create_dropdown ( scheduler_frame , 2 , 24 ) scheduler_currently_set_text = tk . StringVar ( ) if 'scheduled_time' in reddit_state : scheduler_currently_set_text . set ( f'Currently set to: {reddit_state["scheduled_time"]}' ) else : scheduler_currently_set_text . set ( 'Currently set to: No time set' ) scheduler_currently_set_time_label = tk . Label ( scheduler_frame , textvariable = scheduler_currently_set_text ) scheduler_check_button = tk . Checkbutton ( scheduler_frame , text = scheduler_text , variable = scheduler_bool , command = lambda : reddit . set_reddit_scheduler ( root , scheduler_bool , int ( scheduler_hours_dropdown . get ( ) ) , tk . StringVar ( ) , ttk . Progressbar ( ) , scheduler_currently_set_text , reddit_state ) ) # This part actually builds the reddit tab configuration_label . grid ( row = 0 , column = 0 , sticky = 'w' ) time_keep_label . grid ( row = 1 , column = 0 , sticky = 'w' ) hours_dropdown . grid ( row = 1 , column = 1 , sticky = 'w' ) hours_label . grid ( row = 1 , column = 2 , sticky = 'w' ) days_dropdown . grid ( row = 1 , column = 3 , sticky = 'w' ) days_label . grid ( row = 1 , column = 4 , sticky = 'w' ) weeks_dropdown . grid ( row = 1 , column = 5 , sticky = 'w' ) weeks_label . grid ( row = 1 , column = 6 , sticky = 'w' ) years_dropdown . grid ( row = 1 , column = 7 , sticky = 'w' ) years_label . grid ( row = 1 , column = 8 , sticky = 'w' ) set_time_button . grid ( row = 1 , column = 9 , columnspan = 2 ) time_currently_set_label . grid ( row = 1 , column = 11 ) max_score_label . grid ( row = 2 , column = 0 , sticky = 'w' ) max_score_entry_field . grid ( row = 2 , column = 1 , sticky = 'w' ) set_max_score_button . grid ( row = 2 , column = 9 , sticky = 'w' ) set_max_score_unlimited_button . grid ( row = 2 , column = 10 , sticky = 'w' ) max_score_currently_set_label . grid ( row = 2 , column = 11 , sticky = 'w' ) gilded_skip_label . grid ( row = 3 , column = 0 , sticky = 'w' ) gilded_skip_check_button . grid ( row = 3 , column = 1 , sticky = 'w' ) multi_edit_label . grid ( row = 4 , column = 0 , sticky = 'w' ) multi_edit_check_button . grid ( row = 4 , column = 1 , sticky = 'w' ) only_edit_label . grid ( row = 5 , column = 0 , sticky = 'w' ) only_edit_check_button . grid ( row = 5 , column = 1 , sticky = 'w' ) whitelist_label . grid ( row = 6 , column = 0 , sticky = 'w' ) modify_whitelist_comments_button . grid ( row = 6 , column = 1 , columnspan = 4 , sticky = 'w' ) modify_whitelist_posts_button . grid ( row = 6 , column = 5 , columnspan = 4 , sticky = 'w' ) ttk . Separator ( configuration_frame , orient = tk . HORIZONTAL ) . grid ( row = 7 , columnspan = 13 , sticky = 'ew' , pady = 5 ) deletion_section_label . grid ( row = 0 , column = 0 , sticky = 'w' ) delete_comments_button . grid ( row = 1 , column = 0 , sticky = 'w' ) delete_submissions_button . grid ( row = 1 , column = 1 , sticky = 'w' ) deletion_progress_bar . grid ( row = 2 , column = 0 , sticky = 'w' ) num_deleted_items_label . grid ( row = 2 , column = 1 , sticky = 'w' ) deletion_progress_label . grid ( row = 2 , column = 2 , sticky = 'w' ) ttk . Separator ( deletion_frame , orient = tk . HORIZONTAL ) . grid ( row = 3 , columnspan = 3 , sticky = 'ew' , pady = 5 ) scheduler_section_label . grid ( row = 0 , column = 0 , sticky = 'w' ) scheduler_check_button . grid ( row = 1 , column = 0 , sticky = 'w' ) scheduler_hours_dropdown . grid ( row = 1 , column = 1 , sticky = 'w' ) scheduler_currently_set_time_label . grid ( row = 1 , column = 2 , sticky = 'w' ) return frame