<commit_before>from Tkinter import *
from guiConstraints import *
from toolTips import *
from readFile import *
import sys
sys.path.append("../")
import globs
from genetic import constraint, interface, scheduler
import tkMessageBox

font_style = "Helvetica"
size_h1 = 20
size_h2 = 18
size_p = 14
size_l = 12

class Page(Frame):
    def __init__(self, root):
        Frame.__init__(self, root)

    def show(self):
        self.lift()

class HomePage(Page):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.head_label = Label(self, text="CSC Department Scheduler", font=(font_style, size_h1))
        self.head_label.pack(pady=10)

        paragraph_text = "User Guide: step-by-step\n\n" +\
                         "1.) Click RUN to begin generating CSC schedules.\n\n" +\
                         "a.) OPTIONAL: Click the Constraint button to \ngenerate custom schedules.\n\n" +\
                         "2.) After the scheduling is finished click on the View \nbutton" +\
                         " to view the schedules.\n"
        self.description_label = Label(self, text=paragraph_text, font=(font_style, size_p))
        self.description_label.pack()

        runtime_option_text = "Choose a run speed:"
        self.runtime_label = Label(self, text = runtime_option_text, font = (font_style, size_p))
        self.runtime_label.pack()
        self.runtime_disclaimer = Label(self, text = "The scheduler may finish earlier"\
                                        " if it finds 5 valid schedules.", font = (font_style, 10))
        self.runtime_disclaimer.pack(pady = 5)
                                        

        runtime_modes = [
            ("Quick (~1 minute)", 1),
            ("Moderate (~10 minutes)", 10),
            ("High (~1 hour)", 60),
            ("Overnight (~8 hours)", 480),
            ("Custom", 0)
            ]

        self.runtime_selected_var = IntVar()
        self.runtime_selected_var.set(1)
        self.runtime_selected_var.trace("w", self.check_if_custom)

        for mode, val in runtime_modes:
            b = Radiobutton(self, text = mode, variable = self.runtime_selected_var,
                            value = val, font = (font_style, size_l))
            b.pack(anchor = W, padx = 225)


        self.custom_input = Frame(self, width = 50, height = 20)
        self.input_label = Label(self.custom_input, text = "Insert a time (in minutes):",
                                 font = (font_style, size_l))
        self.input_label.pack()

        self.runtime_custom_input = StringVar() #will be converted to int later, prevents type errors
        self.runtime_custom_input.set("0")
        self.runtime_custom_input.trace("w", self.check_if_digit)
        
        self.input_box = Entry(self.custom_input, textvariable = self.runtime_custom_input)
        self.input_box.pack()
        # self.custom_input.pack() # uncomment to show this by default


    def check_if_digit(self, *args):
        self.input_box.config(state = DISABLED) # disabled so tkMessageBox doesn't corrupt input field
        entered_value = self.runtime_custom_input.get()
        for c in entered_value:
            if not c.isdigit():
                self.runtime_custom_input.set(entered_value[:-1]) # remove the non-digit character
                tkMessageBox.showerror(title = "Error", message = "Time must only contain numbers.")
                self.input_box.config(state = NORMAL)
                return 0
        self.input_box.config(state = NORMAL)
        return 1
        
<commit_msg>change custom runtime default to 5 minutes<commit_after>from Tkinter import *
from guiConstraints import *
from toolTips import *
from readFile import *
import sys
sys.path.append("../")
import globs
from genetic import constraint, interface, scheduler
import tkMessageBox

font_style = "Helvetica"
size_h1 = 20
size_h2 = 18
size_p = 14
size_l = 12

class Page(Frame):
    def __init__(self, root):
        Frame.__init__(self, root)

    def show(self):
        self.lift()

class HomePage(Page):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.head_label = Label(self, text="CSC Department Scheduler", font=(font_style, size_h1))
        self.head_label.pack(pady=10)

        paragraph_text = "User Guide: step-by-step\n\n" +\
                         "1.) Click RUN to begin generating CSC schedules.\n\n" +\
                         "a.) OPTIONAL: Click the Constraint button to \ngenerate custom schedules.\n\n" +\
                         "2.) After the scheduling is finished click on the View \nbutton" +\
                         " to view the schedules.\n"
        self.description_label = Label(self, text=paragraph_text, font=(font_style, size_p))
        self.description_label.pack()

        runtime_option_text = "Choose a run speed:"
        self.runtime_label = Label(self, text = runtime_option_text, font = (font_style, size_p))
        self.runtime_label.pack()
        self.runtime_disclaimer = Label(self, text = "The scheduler may finish earlier"\
                                        " if it finds 5 valid schedules.", font = (font_style, 10))
        self.runtime_disclaimer.pack(pady = 5)
                                        

        runtime_modes = [
            ("Quick (~1 minute)", 1),
            ("Moderate (~10 minutes)", 10),
            ("High (~1 hour)", 60),
            ("Overnight (~8 hours)", 480),
            ("Custom", 0)
            ]

        self.runtime_selected_var = IntVar()
        self.runtime_selected_var.set(1)
        self.runtime_selected_var.trace("w", self.check_if_custom)

        for mode, val in runtime_modes:
            b = Radiobutton(self, text = mode, variable = self.runtime_selected_var,
                            value = val, font = (font_style, size_l))
            b.pack(anchor = W, padx = 225)


        self.custom_input = Frame(self, width = 50, height = 20)
        self.input_label = Label(self.custom_input, text = "Insert a time (in minutes):",
                                 font = (font_style, size_l))
        self.input_label.pack()

        self.runtime_custom_input = StringVar() #will be converted to int later, prevents type errors
        self.runtime_custom_input.set("5")
        self.runtime_custom_input.trace("w", self.check_if_digit)
        
        self.input_box = Entry(self.custom_input, textvariable = self.runtime_custom_input)
        self.input_box.pack()
        # self.custom_input.pack() # uncomment to show this by default


    def check_if_digit(self, *args):
        self.input_box.config(state = DISABLED) # disabled so tkMessageBox doesn't corrupt input field
        entered_value = self.runtime_custom_input.get()
        for c in entered_value:
            if not c.isdigit():
                self.runtime_custom_input.set(entered_value[:-1]) # remove the non-digit character
                tkMessageBox.showerror(title = "Error", message = "Time must only contain numbers.")
                self.input_box.config(state = NORMAL)
                return 0
        self.input_box.config(state = NORMAL)
        return 1
        

{'fraction_non_alphanumeric': 0.1037326995666154, 'fraction_numerical': 0.012721934852509437, 'mean_word_length': 2.1725055432372504, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1308048', 'n_tokens_mistral': 2150, 'n_tokens_neox': 2012, 'n_words': 536}