I'm trying to create a GUI in Python that randomly returns a workout based on the muscle group I enter in the text input box.
I'm having a hard time creating a function that takes the text box input and returns a random workout given inside of the code.
How can I solve this?
from tkinter import *
#from PIL import ImportTk, Image
import random
root = Tk()
root.title("Workout Generator")
root.iconbitmap("")
root.geometry("500x500")
#Text Above Input Box
label = Label(root, text='Enter The Muscle Group You Want To Train', font='Helvetica')
label.pack()
#For input box
e = Entry(root, width=50)
e.pack()
e.get()
e.insert(0, ' ')
#Function for Workouts
def wrkout():
if e == 'Chest' or 'chest':
chest_workouts = ['Barbell Bench Press: 5 x 6\nWeighted Chest Dips: 5 x 8-10\nIncline Dumbbell Bench Press: 4 x 8-10\nCable Chest Fly: 3 x 12\nPush Ups 2 Sets: AMRAP', 'Incline Barbell Bench Press: 5 x 10\nSingle Arm DB Bench Press: 4 x 8-10\nChest Dips: 4 x 10\nMachine Chest Fly: 3 x 15\nPush Ups: 3 x 20']
return(random.choice(chest_workouts))
elif e == 'Legs' or 'legs':
leg_workouts = ['Barbell Squat: 5 x 5\nDB Split Leg Squat: 4 x 6-8 each leg\nMachine Hip Thrusts: 4 x 6-10\nDB Stiff Leg Deadlift: 4 x 8\n Seated Leg Extensions: 3 x 12', 'Barbell Split Leg Squat: 5 x 4-8 each leg\nDB Romanian Deadlift: 4 x 8\n Hack Squat: 4 x 8\nSingle Leg Stability Ball Leg Curl: 3 x 10-12\nAlternating Walking Lunges: 2 Sets of 20']
return(random.choice(leg_workouts))
#Function for returning text when the button is clicked
def myClick():
chest = wrkout() + e.get()
myLabel = Label(root, text=chest)
myLabel.pack()
#Function To Delete Text In Input Box
def delete():
e.delete(0, END)
# Button To Generate Workout
myButton = Button(root, text='Generate Workout', command=myClick)
#Button To Delete Workout
DeleteButton = Button(root, text='Delete', command=delete)
#Put Button On Screen
myButton.pack()
DeleteButton.pack()
root.mainloop()