Beispiel #1
0
    def add_to_grid(self):

        # Sets all of the data to what the user inputted
        name_label = Label(
            text=self.exercise_name.text
        )  # Creates label with newest exercise name inputted
        sets_label = Label(
            text=self.num_sets.text
        )  # Creates label with newest number of sets inputted
        reps_label = Label(
            text=self.num_reps.text
        )  # Creates label with newest number of reps inputted
        weight_label = Label(
            text=self.amt_weight.text
        )  # Creates label with newest amount of weight inputted

        # Checks to make sure there is a name and numbers of sets as input
        if self.exercise_name.text and self.num_sets.text != "":

            # Something new was add, changed back to save
            self.save_button.text = str('Save')

            # Increase the number of rows to allow space for new input
            self.add_routine_grid.rows += 1

            # Adds the input to the grid
            self.add_routine_grid.add_widget(
                name_label)  # Adds the name to the grid
            self.add_routine_grid.add_widget(
                sets_label)  # Adds the sets to the grid
            self.add_routine_grid.add_widget(
                reps_label)  # Adds the reps to the grid
            self.add_routine_grid.add_widget(
                weight_label)  # Adds the weight to the grid

            # Creates variables to store routine data
            name_text = self.exercise_name.text  # Stores the name of the exercise
            sets_text = self.num_sets.text  # Stores the amount of sets
            reps_text = self.num_reps.text  # Stores the amount of reps
            weight_text = self.amt_weight.text  # Stores the amount of weight

            # Appends all the exercise info to the list (order important)
            workout_list.append(name_text)  # Adds exercise name to list
            workout_list.append(
                sets_text)  # Adds the number of sets to the list
            workout_list.append(
                reps_text)  # Adds the number of reps to the list
            workout_list.append(
                weight_text)  # Adds the amount of weight to the list

            print(workout_list)

            # Calls the next step
            ScreenManager.reset_fields(self)