from tkinter import *
import random
root = Tk()
root.title("Random")
root.geometry("600x400")
root.resizable(False, False)
def open_saw():
saw_wn = Tk()
saw_wn.title("Random App - Spin a Wheel")
saw_wn.geometry("600x400")
saw_wn.resizable(False, False)
saw_wn.mainloop()
def open_coin():
c_wn = Tk()
c_wn.title("Random App - Flip a Coin")
c_wn.geometry("600x400")
c_wn.resizable(False, False)
Label(c_wn, text=" ").grid(row=0, column=0)
Label(c_wn, text="Flip the coin below!").grid(row=0, column=1)
c_wn.mainloop()
def open_average():
avg_wn = Tk()
avg_wn.title("Random App - Flip a Coin")
avg_wn.geometry("600x400")
avg_wn.resizable(False, False)
Label(avg_wn, text=" ").grid(row=0, column=0)
Label(avg_wn, text="Enter your values below to get the averages in mean, median, mode, and range").grid(row=0,
column=1)
entry_avg = Entry(avg_wn).grid(row=1, column=1)
def calculate_mean():
print(entry_avg.get().split(','))
Button(avg_wn, text='test', command=calculate_mean).grid(row=2, column=1)
Label(root, text=" ").grid(row=0, column=0)
title = Label(root, text="Welcome to Random")
title.config(font=("Yu Gothic UI", 24))
title.grid(row=0, column=1)
button1 = Button(root, text=" Spin a wheel ", padx=80, pady=25, command=open_saw)
button1.place(x=2.25, y=100)
button2 = Button(root, text="Calculate mean, mode, median, and range", padx=20, pady=25, command=open_average)
button2.place(x=325, y=100)
button3 = Button(root, text="Flip a Coin", padx=125, pady=25, command=open_coin)
button3.place(x=2.25, y=200)
button4 = Button(root, text="Roll a die", padx=107.5, pady=25)
button4.place(x=325, y=200)
root.mainloop()
What I want is to get a list from the entry so that I can calculate mean, mode, median, etc but when I do, I receive an error. The error is below:
line 44, in calculate_mean
print(entry_avg.get().split(','))
AttributeError: 'NoneType' object has no attribute 'get'
Please help as I am a beginner at programming and I am stuck on this. If you need additional info please tell me and I will give you.