I'm trying to make an advanced baseball metric calculator. Can anyone explain why the lambda in "wobaentry" is returning nonetypes when calling the "wOBA" function. I have a set of functions that I modelled this segment after and it's working perfectly. What am I overlooking? Any insight would be greatly appreciate
from tkinter import *
import tkinter.messagebox
def wobaentry():
wobainput= Tk()
L4 = Label(wobainput, text = "wOBA", fg = "red", font = "Times").grid(row=1, column=1)
L5 = Label(wobainput, text ="Walks").grid(row=2, column=1)
L6 = Label(wobainput, text ="Singles").grid(row=3, column=1)
L7 = Label(wobainput, text ="Doubles").grid(row=4, column=1)
L8 = Label(wobainput, text ="Triples").grid(row=5, column=1)
L9 = Label(wobainput, text ="Home Runs").grid(row=6, column=1)
L10 = Label(wobainput, text ="At bats").grid(row=7, column=1)
L11 =Label(wobainput, text ="Sacrifice flies").grid(row=8, column=1)
L12 = Label(wobainput, text ="Intentional Walks").grid(row=9, column=1)
L14 = Label(wobainput, text ="Hit By Pitch").grid(row=10, column=1)
E4= Entry(wobainput, width= 60).grid(row=2, column=2)
E5= Entry(wobainput, width= 60).grid(row=3, column=2)
E6= Entry(wobainput, width= 60).grid(row=4, column=2)
E7= Entry(wobainput, width= 60).grid(row=5, column=2)
E8= Entry(wobainput, width= 60).grid(row=6, column=2)
E9= Entry(wobainput, width= 60).grid(row=7, column=2)
E10= Entry(wobainput, width= 60).grid(row=8, column=2)
E11= Entry(wobainput, width= 60).grid(row=9, column=2)
E13= Entry(wobainput, width= 60).grid(row=10, column=2)
B5= Button(wobainput, text= "Calculate wOBA", command = lambda: wOBA(E4, E5, E6, E7, E8, E9, E10, E11, E13) )
B5.grid(row=15, column=2)
def wOBA(E4, E5, E6, E7, E8, E9, E10, E11, E13):
wOBAoutput = Tk()
L13 = Label (wOBAoutput, text = "wOBA", fg="black", font = "times")
L13.grid (row=1, column = 1)
E12 = Entry(wOBAoutput, bd=5).grid(row=2, column=1)
bb = float(E4.get())
hbp = float(E13.get())
singles = float(E5.get())
doubles = float(E6.get())
triple = float(E7.get())
hr = float(E8.get())
ab = float(E9.get())
sf = float(E10.get())
ibb = float(E11.get())
ubb = bb - ibb
woba = float(((ubb * .69) + (.720 * hbp) + (.884 * singles) + (1.261 * doubles) + (1.601 * triple) + (2.072 * hr)) / (ab + bb - ibb + sf + hbp))
E12.insert(0, str(woba))
E12['bg']='grey'
This is the set that is working:
def pythagentry():
pythaginput = Tk()
L0 = Label(pythaginput, text= "Expected Wins", fg="black", font = "Times")
L0.grid(row=1, column=1)
L1 = Label(pythaginput, text= "Runs Scored", fg="black", font= "Times")
L1.grid(row=2, column=1)
L2 = Label(pythaginput, text= "Runs Allowed", fg="black", font= "Times")
L2.grid(row=3, column=1)
L3 = Label(pythaginput, text= "Season Length", fg="black", font= "Times")
L3.grid(row=4, column=1)
E1 = Entry(pythaginput,bd=5)
E1.grid (row=2, column=2)
E2 = Entry(pythaginput,bd=5)
E2.grid (row=3, column=2)
E3 = Entry(pythaginput,bd=5)
E3.grid (row=4, column=2)
B4 = Button (pythaginput,text='Calculate Pythagorean Wins', command = lambda: pythag(E1, E2, E3) )
B4.grid (row=5, column=2)
def pythag(E1, E2, E3):
pythagoutput = Tk()
L4=Label(pythagoutput,text="Expected Wins:",fg="red")
L4.grid (row =1, column =1)
E5=Entry(pythagoutput, bd=5)
E5.grid(row=4,column=1)
runsscored= float(E1.get())
runsallowed= float(E2.get())
lengthseason= float(E3.get())
ratio = runsscored / runsallowed
winpct = pow (ratio, 2) / (pow(ratio, 2) + 1)
expectedwins = lengthseason * winpct
E5.insert(0, str(expectedwins))
E5['bg']='grey'