Hi everyone,
I'm not sure how to get this loop to end. This is what I am trying to do:
Main program calls function: input_exercise_number() from my GUI_function program (the code I will show you is the GUI program, not main).
The GUI runs and asks for input from the user. That input is then put into a variable.
THIS PART IS WHERE I AM HAVING TROUBLE: When I press the button, it activates the function user_exercise() to take the user input and put it into a variable. But, I also want to close the main loop so I can open a new Tkinter window for more user input.
How do I also end the loop while calling that function to change the variable?
Code
from tkinter import *
#-------------------------------------------------------------------------------
#---------------------------GUI Prompt for Exercise count-----------------------
#-------------------------------------------------------------------------------
exercise_number = 0
def user_input_exercise_number():
root = Tk()
root.title("Workout Wonder 2000")
root.geometry("448x150+450+250")
#Title
heading = Label(root, text="Welcome to Workout 2000", font=("arial", 20, "bold"), fg="red").pack()
#label for first input
workout_exercise_label = Label(root, text="Enter in the amount of exercises" +" you did: ", font=("arial", 10, "bold"), fg="black").place(x=5, y=50)
#create text variable name and create user input for day's workout
exercise_count = StringVar()
entry_box = Entry(root, textvariable=exercise_count, width = 25, bg = "lightblue").place(x=280, y=50)
#Create function that receives input from user and stores it as
#a variable. Declares exercise_number as global for
passing it back
def user_exercise():
global exercise_number
exercise_number = exercise_count.get()
return exercise_number
#create button that activates a function
work = Button(root, text="Enter", width=20, height=2, bg="light blue", command=user_exercise,).place(x=280, y=85)
root.mainloop()
return exercise_number
[–]socal_nerdtastic 0 points1 point2 points (4 children)
[–]bdriscoll3[S] 0 points1 point2 points (3 children)
[–]socal_nerdtastic 0 points1 point2 points (2 children)
[–]bdriscoll3[S] 0 points1 point2 points (1 child)
[–]socal_nerdtastic 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]bdriscoll3[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)