예제 #1
0
    def createLeftFrame(self):
        left_frame = ttk.Frame(self)
        util.SetGrid(left_frame, 0, 0)
        util.SetGridWeights(left_frame,
                            row_weights=(1, 1, 1, 1, 1, 2, 1, 2, 1))

        # Button to open updated Excel file
        open_file_button = ttk.Button(left_frame,
                                      text=_('Load schedule'),
                                      command=self.openUpdatedExcel)
        util.SetGrid(open_file_button, 0, 0)
        # Opened file name. Empty label if no file is loaded
        open_file_label = ttk.Label(left_frame,
                                    textvariable=self.open_filename_strv)
        util.SetGrid(open_file_label, 1, 0)

        # Start date, end date of new schedule
        start_date_label = ttk.Label(left_frame,
                                     textvariable=self.start_date_strv)
        util.SetGrid(start_date_label, 2, 0)
        end_date_label = ttk.Label(left_frame, textvariable=self.end_date_strv)
        util.SetGrid(end_date_label, 3, 0)

        # Re-check for error button
        self.recheck_error_button = ttk.Button(left_frame,
                                               text=_('Re-check'),
                                               command=self.validateExcel)
예제 #2
0
    def createRightFrame(self):
        right_frame = ttk.Frame(self)
        util.SetGrid(right_frame, 0, 1)
        util.SetGridWeights(right_frame, row_weights=(1, 9))

        # Right side of the frame only displays status (of validation and solver run)
        label = ttk.Label(right_frame, text=_('Errors'))
        util.SetGrid(label, 0, 0)
        self.status_text_area = scrolledtext.ScrolledText(right_frame, state=tk.DISABLED)
        util.SetGrid(self.status_text_area, 1, 0)
예제 #3
0
def CreateGUI():
    root = tk.Tk()
    root.minsize(900, 600)
    root.maxsize(900, 600)
    root.title(_('Shift Scheduler v0.1'))
    util.SetGridWeights(root, row_weights=(1, 4))

    lower_frame = lower.LowerFrame(root)
    util.SetGrid(lower_frame, 1, 0)
    upper_frame = upper.UpperFrame(root, lower_frame)
    util.SetGrid(upper_frame, 0, 0)

    return root
예제 #4
0
    def CreateUpdateScheduleButton(self, col_index):
        frame = ttk.Frame(self)
        util.SetGrid(frame, 0, col_index)

        button_label = ttk.Button(
            frame, text=_('Update existing schedule'), command=self._lower_frame.ShowUpdateScheduleFrame)
        button_label.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
예제 #5
0
    def CreateBareboneExcelButton(self, col_index):
        frame = ttk.Frame(self)
        util.SetGrid(frame, 0, col_index)

        button_label = ttk.Button(
            frame, text=_('Create barebone Excel'), command=self._lower_frame.ShowBareboneFrame)
        button_label.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
예제 #6
0
    def CreateValidateScheduleButton(self, col_index):
        frame = ttk.Frame(self)
        util.SetGrid(frame, 0, col_index)

        button_label = ttk.Button(
            frame, text=_('Check for errors'), command=self._lower_frame.ShowValidateScheduleFrame)
        button_label.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
        
예제 #7
0
    def validateExcel(self):
        filepath = self.filepath
        if not filepath:
            return

        util.SetGrid(self.recheck_error_button, 4, 0)

        base_schedule = excel_input.ReadFromExcelFile(filepath)

        # Update labels
        start_date = base_schedule.software_config.start_date
        end_date = base_schedule.software_config.end_date
        self.updateLabels(filepath, start_date, end_date)

        # Validate
        errors = validator.ValidateTotalScheduleFormat(base_schedule, barebone=False)
        
        if errors:
            self.addToTextArea('\n'.join(errors))
        else:
            self.addToTextArea(_('No error is found.\n'))  # TODO: Add output time
예제 #8
0
 def showFrame(self, frame_to_show):
     if self.displayed_frame is not None:
         self.displayed_frame.grid_forget()
     self.displayed_frame = frame_to_show
     util.SetGrid(self.displayed_frame, 0, 0)
     
예제 #9
0
    def createLeftFrame(self):
        left_frame = ttk.Frame(self)
        util.SetGrid(left_frame, 0, 0)
        util.SetGridWeights(left_frame,
                            row_weights=(1, 1, 1, 1, 1, 1, 1, 1, 2, 1))

        # Open modified schedule
        open_file_button = ttk.Button(left_frame,
                                      text=_('Load file'),
                                      command=self.openExcelToUpdate)
        util.SetGrid(open_file_button, 0, 0)
        open_file_label = ttk.Label(left_frame,
                                    textvariable=self.open_filename_strv)
        util.SetGrid(open_file_label, 1, 0)

        # Select date range to update
        start_date_label = ttk.Label(left_frame, text=_('Update start date'))
        util.SetGrid(start_date_label, 2, 0)
        self.start_date_cal = tkc.DateEntry(left_frame,
                                            year=2020,
                                            month=5,
                                            day=1,
                                            date_pattern=DATE_PATTERN,
                                            locale=LOCALE_CODE)
        util.SetGrid(self.start_date_cal, 3, 0)
        # End date to update
        end_date_label = ttk.Label(left_frame, text=_('Update end date'))
        util.SetGrid(end_date_label, 4, 0)
        self.end_date_cal = tkc.DateEntry(left_frame,
                                          year=2020,
                                          month=5,
                                          day=31,
                                          date_pattern=DATE_PATTERN,
                                          locale=LOCALE_CODE)
        util.SetGrid(self.end_date_cal, 5, 0)

        # Checkbox to keep the off dates
        keep_offdate_checkbox = ttk.Checkbutton(left_frame,
                                                text=_('Keep the OFF dates'),
                                                variable=self.keep_offdate_var,
                                                onvalue=True,
                                                offvalue=False)
        util.SetGrid(keep_offdate_checkbox, 6, 0)

        # Max search time frame
        max_time_frame = ttk.Frame(left_frame)
        util.SetGrid(max_time_frame, 7, 0)
        util.SetGridWeights(max_time_frame, column_weights=(4, 1, 1))

        max_time_label1 = ttk.Label(max_time_frame,
                                    text=_('Maximum search time'))
        util.SetGrid(max_time_label1, 0, 0)

        self.max_time_var.set(1)
        max_time_spinbox = ttk.Spinbox(max_time_frame,
                                       from_=1,
                                       to=30,
                                       textvariable=self.max_time_var)
        util.SetGrid(max_time_spinbox, 0, 1)

        max_time_label2 = ttk.Label(max_time_frame, text=_('minutes'))
        util.SetGrid(max_time_label2, 0, 2)

        max_time_info_label = ttk.Label(
            left_frame, text=_('Search will stop after this time'))
        util.SetGrid(max_time_info_label, 8, 0)

        # Start button
        submit_button = ttk.Button(left_frame,
                                   text=_('Start'),
                                   command=self.updateSchedule)
        util.SetGrid(submit_button, 9, 0)
예제 #10
0
    def createLeftFrame(self):
        left_frame = ttk.Frame(self)
        util.SetGrid(left_frame, 0, 0)
        util.SetGridWeights(left_frame,
                            row_weights=(1, 1, 1, 1, 1, 2, 1, 2, 1))

        # Button to open partially filled barebone filed
        open_file_button = ttk.Button(left_frame,
                                      text=_('Load barebone Excel file'),
                                      command=self.openBareboneExcel)
        util.SetGrid(open_file_button, 0, 0)
        # Opened file name. Empty label if no file is loaded
        open_file_label = ttk.Label(left_frame,
                                    textvariable=self.open_filename_strv)
        util.SetGrid(open_file_label, 1, 0)

        # Start date, end date of new schedule
        start_date_label = ttk.Label(left_frame,
                                     textvariable=self.start_date_strv)
        util.SetGrid(start_date_label, 2, 0)
        end_date_label = ttk.Label(left_frame, textvariable=self.end_date_strv)
        util.SetGrid(end_date_label, 3, 0)

        # How long should the solver run?
        max_time_frame = ttk.Frame(left_frame)
        util.SetGridWeights(max_time_frame, column_weights=(4, 1, 1))
        util.SetGrid(max_time_frame, 6, 0)

        max_time_label1 = ttk.Label(max_time_frame,
                                    text=_('Maximum search time'))
        util.SetGrid(max_time_label1, 0, 0)

        self.max_time_var.set(1)
        spinbox = ttk.Spinbox(max_time_frame,
                              from_=1,
                              to=30,
                              textvariable=self.max_time_var)
        util.SetGrid(spinbox, 0, 1)

        max_time_label2 = ttk.Label(max_time_frame, text=_('minutes'))
        util.SetGrid(max_time_label2, 0, 2)

        # Notice that the solver will stop after the specific time
        max_time_info_label = ttk.Label(
            left_frame, text=_('Search will stop after this time'))
        util.SetGrid(max_time_info_label, 7, 0)

        # Start button. Click will validate the input Excel and run the solver
        submit_button = ttk.Button(left_frame, text=_('Start Search'))
        util.SetGrid(submit_button, 8, 0)