<commit_before>from Tkinter import Frame, Label, Button, Scrollbar, Listbox
from Tkconstants import RIGHT, LEFT, YES, BOTTOM, NW, VERTICAL, MULTIPLE, X, Y, END
import globs

class ConstraintsView(Frame):
    "Presents all constraints created by user"

    def __init__(self, parent):
        Frame.__init__(self, parent)
        # holds all constraints
        self.constraint_name_list = []

        # holds the scrollbox output text for the added constraints
        self.constraints_output = []

        text_label = "Constraints Added:"
        self.text = Label(self, text = text_label)
        self.text.pack(anchor = NW, expand = YES)

        buttons_frame = Frame(self)
        buttons_frame.pack(side = BOTTOM)

        self.delete_all = Button(buttons_frame, text="Delete all",\
                                 command=self.delete_all_constraints)
        self.delete_all.pack(side=RIGHT)

        self.delete_selection = Button(buttons_frame, text="Delete", command=self.delete_selection)
        self.delete_selection.pack(side = RIGHT, padx = 20)

        self.scrollbar = Scrollbar(self, orient=VERTICAL)
        self.listbox = Listbox(self, yscrollcommand = self.scrollbar.set, selectmode = MULTIPLE,\
                                width = 40, height = 15)
        self.scrollbar.config(command=self.listbox.yview)

        self.listbox.pack(side=LEFT, fill=X, expand=1)
        self.scrollbar.pack(side=LEFT, fill=Y)

    def add_constraint_listbox(self, constraint_name, priority):
        "Updates the list box with the new constraint created"
        output = constraint_name + " Priority = "
        
        self.constraint_name_list.append(constraint_name)
        
        if priority == 10:
            output += 'Low'
        elif priority == 25:
            output += 'Medium'
        elif priority == 50:
            output += 'High'
        elif priority == 0: # mandatory has a 0 priority
            output += 'Mandatory'

        self.constraints_output.append(output)

        # clear listbox
        self.listbox.delete(0, END)

        for item in self.constraints_output:
            self.listbox.insert(END, item)

    def delete_all_constraints(self):
        "Deletes all constraints from the listbox and the mainScheduler"<commit_msg>Add horizontal scrollbar to Constraints Added box<commit_after>from Tkinter import Frame, Label, Button, Scrollbar, Listbox, HORIZONTAL
from Tkconstants import RIGHT, LEFT, YES, BOTTOM, NW, VERTICAL, MULTIPLE, X, Y, END
import globs

class ConstraintsView(Frame):
    "Presents all constraints created by user"

    def __init__(self, parent):
        Frame.__init__(self, parent)
        # holds all constraints
        self.constraint_name_list = []

        # holds the scrollbox output text for the added constraints
        self.constraints_output = []

        text_label = "Constraints Added:"
        self.text = Label(self, text = text_label)
        self.text.pack(anchor = NW, expand = YES)

        buttons_frame = Frame(self)
        buttons_frame.pack(side = BOTTOM)

        self.delete_all = Button(buttons_frame, text="Delete all",\
                                 command=self.delete_all_constraints)
        self.delete_all.pack(side=RIGHT, pady = 10)

        self.delete_selection = Button(buttons_frame, text="Delete", command=self.delete_selection)
        self.delete_selection.pack(side = RIGHT, padx = 20)

        self.yScroll = Scrollbar(self, orient=VERTICAL)
        self.yScroll.pack(side=RIGHT, fill = Y)
        
        self.xScroll = Scrollbar(self, orient=HORIZONTAL)
        self.xScroll.pack(side=BOTTOM, fill = X)
        
        self.listbox = Listbox(self, xscrollcommand = self.xScroll.set,\
                               yscrollcommand = self.yScroll.set,\
                               selectmode = MULTIPLE,\
                               width = 45, height = 20)

        self.xScroll['command'] = self.listbox.xview
        self.yScroll['command'] = self.listbox.yview
    
        self.listbox.pack(side=LEFT, fill=X, expand=1)

    def add_constraint_listbox(self, constraint_name, priority):
        "Updates the list box with the new constraint created"
        output = constraint_name + " Priority = "
        
        self.constraint_name_list.append(constraint_name)
        
        if priority == 10:
            output += 'Low'
        elif priority == 25:
            output += 'Medium'
        elif priority == 50:
            output += 'High'
        elif priority == 0: # mandatory has a 0 priority
            output += 'Mandatory'

        self.constraints_output.append(output)

        # clear listbox
        self.listbox.delete(0, END)

        for item in self.constraints_output:
            self.listbox.insert(END, item)

    def delete_all_constraints(self):
        "Deletes all constraints from the listbox and the mainScheduler"
{'fraction_non_alphanumeric': 0.09189521080638559, 'fraction_numerical': 0.006958657388456815, 'mean_word_length': 2.3426812585499315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2818302', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1357, 'n_words': 344}