Exemplo n.º 1
0
    def __init__(self, root):
        super(WeightRoomScriptEditor, self).__init__(root)
        self.exercises_and_sets = ['exercise']

        self.grid_rowconfigure(0, weight=1)

        # Container for adding exercises and sets
        add_exercise_set_button_frame = tk.Frame(self)
        add_exercise_set_button_frame.grid(row=0, column=0, sticky='NW')

        tk.Label(add_exercise_set_button_frame,
                 text='Add Exercises and Sets:').grid(
                     row=0, column=0, columnspan=NUM_ITEMS_PER_ROW)
        tk.Button(add_exercise_set_button_frame,
                  text='Add Exercise',
                  command=self.add_exercise).grid(row=1,
                                                  column=0,
                                                  columnspan=NUM_ITEMS_PER_ROW)

        length = 10
        while length <= MAX_LENGTH_OF_SET:
            button = tk.Button(add_exercise_set_button_frame,
                               text=seconds_to_minutes_seconds_string(length),
                               command=lambda l=length: self.add_set(l))
            row = (length // 10 - 1) // NUM_ITEMS_PER_ROW + 3
            column = (length // 10 - 1) % NUM_ITEMS_PER_ROW
            button.grid(row=row, column=column, sticky='EW')
            length += 10

        # Container for script display listbox
        sets_frame = tk.Frame(self)
        sets_frame.grid(row=0, column=1, sticky='NS')

        sets_scrollbar = tk.Scrollbar(sets_frame)
        sets_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        self.exercises_or_sets_lb = tk.Listbox(sets_frame)
        self.exercises_or_sets_lb.pack(fill=tk.Y, expand=True)
        self.exercises_or_sets_lb.configure(yscrollcommand=sets_scrollbar.set)
        sets_scrollbar.configure(command=self.exercises_or_sets_lb.yview)

        # Set up widgets for misc script actions
        misc_items_frame = tk.Frame(self)
        delete_period_btn = tk.Button(misc_items_frame,
                                      text='Delete',
                                      command=self.delete_exercise_set)
        delete_period_btn.pack()
        self.total_length_lbl = tk.Label(misc_items_frame,
                                         text='Total Length: 00:00')
        self.total_length_lbl.pack()
        misc_items_frame.grid(row=0, column=2, sticky='NW')

        self.refresh_sets_lb()
Exemplo n.º 2
0
    def initialize_set(self):
        self.time_remaining_in_set = self.script[self.current_set]['length']
        self.interval_timer_slider.configure(to_=self.time_remaining_in_set -
                                             1)
        self.exercise_lbl.configure(
            text=self.script[self.current_set]['exercise_label'])
        self.set_lbl.configure(text=self.script[self.current_set]['set_label'])

        self.time_lbl.configure(
            text=seconds_to_minutes_seconds_string(self.time_remaining_in_set))
        self.interval_timer_slider.configure(state=tk.NORMAL)
        self.interval_timer_slider.set(
            self.script[self.current_set]['length'] -
            self.time_remaining_in_set)
        if self.is_playing:
            self.interval_timer_slider.configure(state=tk.DISABLED)
Exemplo n.º 3
0
    def on_second(self):
        #decrement the time and check on end of set
        if self.is_playing:
            self.time_remaining_in_set -= 1
            if self.time_remaining_in_set <= 0:
                self.next_period()
                if self.current_set == 0:
                    self.is_playing = False

        #Update the slider
        self.time_lbl.configure(
            text=seconds_to_minutes_seconds_string(self.time_remaining_in_set))
        self.interval_timer_slider.configure(state=tk.NORMAL)
        self.interval_timer_slider.set(
            self.script[self.current_set]['length'] -
            self.time_remaining_in_set)
        if self.is_playing:
            self.interval_timer_slider.configure(state=tk.DISABLED)

        #callback will invoke itself repeatadely so that it keeps happening
        self.after(1000, self.on_second)
Exemplo n.º 4
0
    def refresh_sets_lb(self):
        current_exercise = 0
        current_set = 0
        total_time = 0

        self.exercises_or_sets_lb.delete(0, tk.END)

        for exercise_or_set in self.exercises_and_sets:
            if type(exercise_or_set) is str:
                current_exercise += 1
                current_set = 0
                self.exercises_or_sets_lb.insert(
                    tk.END, f'Exercise {current_exercise}')
            else:
                set_length = exercise_or_set
                current_set += 1
                total_time += set_length
                formatted_time = seconds_to_minutes_seconds_string(set_length)
                self.exercises_or_sets_lb.insert(
                    tk.END, f'Set {current_set}       {formatted_time}')

        self.total_length_lbl.configure(
            text=
            f'Total Length: {seconds_to_minutes_seconds_string(total_time)}')
Exemplo n.º 5
0
    def __init__(self, root, script, prefs, layout_option='a'):
        super(WeightRoomTimer, self).__init__(root)
        #Initialize interval timer values and preference values
        self.script = script
        self.current_set = 0
        self.time_remaining_in_set = 0
        self.is_playing = False
        self.exercise_lbl_size = prefs['exercise_lbl_size']
        self.set_lbl_size = prefs['set_lbl_size']
        self.time_lbl_size = prefs['time_lbl_size']

        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)

        #Set up interval timer playback widgets
        interval_timer_playback_frame = tk.Frame(self)
        interval_timer_playback_frame.grid_columnconfigure(3, weight=1)
        self.previous_period_btn = tk.Button(interval_timer_playback_frame,
                                             text='<<',
                                             command=self.previous_period)
        self.previous_period_btn.grid(row=0, column=0, sticky='W')
        tk.Button(interval_timer_playback_frame,
                  text='>',
                  command=self.pause_timer).grid(row=0, column=1, sticky='W')
        self.next_period_btn = tk.Button(interval_timer_playback_frame,
                                         text='>>',
                                         command=self.next_period)
        self.next_period_btn.grid(row=0, column=2, sticky='W')
        self.interval_timer_slider = tk.Scale(interval_timer_playback_frame,
                                              from_=0,
                                              to_=1800,
                                              showvalue=False,
                                              orient=tk.HORIZONTAL,
                                              command=self.slider_update)
        self.interval_timer_slider.grid(row=1,
                                        column=0,
                                        columnspan=4,
                                        sticky='WE')
        interval_timer_playback_frame.grid(row=0, column=0, sticky='NSEW')

        #set up parent frame of the labels displaying the period number and time remaining
        lbls_parent_frame = tk.Frame(self)
        lbls_parent_frame.grid(row=1, column=0, columnspan=2, sticky='NSEW')
        lbls_parent_frame.grid_rowconfigure(2, weight=1)
        lbls_parent_frame.grid_columnconfigure(5, weight=1)

        # Set up space for adjusting label size
        tk.Button(lbls_parent_frame,
                  text='Decrease Excercise Size',
                  command=self.decrease_exercise_lbl_size).grid(row=0,
                                                                column=0,
                                                                sticky='W')
        tk.Button(lbls_parent_frame,
                  text='Increase Exercise Size',
                  command=self.increase_exercise_lbl_size).grid(row=0,
                                                                column=1,
                                                                sticky='W')
        tk.Button(lbls_parent_frame,
                  text='Decrease Set Size',
                  command=self.decrease_set_lbl_size).grid(row=0,
                                                           column=2,
                                                           sticky='W')
        tk.Button(lbls_parent_frame,
                  text='Increase Set Size',
                  command=self.increase_set_lbl_size).grid(row=0,
                                                           column=3,
                                                           sticky='W')
        tk.Button(lbls_parent_frame,
                  text='Decrease Time Size',
                  command=self.decrease_time_lbl_size).grid(row=0,
                                                            column=4,
                                                            sticky='W')
        tk.Button(lbls_parent_frame,
                  text='Increase Time Size',
                  command=self.increase_time_lbl_size).grid(row=0,
                                                            column=5,
                                                            sticky='W')

        # Labels for exercise and time remaining
        self.exercise_lbl = tk.Label(lbls_parent_frame,
                                     text='Exr: 1',
                                     font=('Times', self.exercise_lbl_size))
        self.exercise_lbl.grid(row=1, column=0, columnspan=6, sticky='W')
        self.set_lbl = tk.Label(lbls_parent_frame,
                                text='Set: 1',
                                font=('Times', self.set_lbl_size))
        if layout_option == 'a':
            self.set_lbl.grid(row=1, column=0, columnspan=6, sticky='E')
        else:
            self.set_lbl.grid(row=2, column=0, columnspan=6, sticky='SW')
        self.time_remaining_in_set = self.script[self.current_set]['length']
        self.time_lbl = tk.Label(lbls_parent_frame,
                                 text=seconds_to_minutes_seconds_string(
                                     self.time_remaining_in_set),
                                 font=('Times', self.time_lbl_size))
        self.time_lbl.grid(row=2, column=0, columnspan=6, sticky='SE')

        #initialize the starting values and sizes of the label widgets
        self.interval_timer_slider.configure(to_=self.time_remaining_in_set -
                                             1)
        self.interval_timer_slider.set(0)
        self.initialize_set()

        #this call back
        self.after(1000, self.on_second)
Exemplo n.º 6
0
 def slider_update(self, new_slider_value):
     self.time_remaining_in_set = self.script[
         self.current_set]['length'] - int(new_slider_value)
     self.time_lbl.configure(
         text=seconds_to_minutes_seconds_string(self.time_remaining_in_set))