I'm trying to make a menu driven program that has GUI capability. For the sake of this post I edited it down so the menu has 2 options, to quit and to calculate an average of a set of numbers. I ran this before I used the GUI code and it worked perfectly.
The issue is that when I click "Average", it runs the function and allows 1 input but then I can't enter another number. Same issue with other functions I had. They won't run past the first input and then the Quit button also won't quit.
Feel free to ask any questions in the comments if I wasn't good at describing what I needed. It's my first day using GUI so sorry if anything looks weird, I'm trying to teach myself but got stuck here. End goal is to have the whole program run in a GUI environment but I figured starting with the menu would be the best place to start.
from tkinter import *
import tkinter as tk
def average():
print("Enter test scores to get the average of. Type '-99' to quit.")
num = 1
count = 0
total = 0
while num != -99:
num = int(input("Enter numbers: "))
total += num
count += 1
average = (total + 99) / (count-1)
print("The average is: ", average)
print("-----------")
main()
def main():
r = tk.Tk()
r.title('Number games')
button1 = tk.Button(r, activebackground = "blue", bg = "light blue", text='Average', width=25, command= average)
button4 = tk.Button(r, activebackground = "blue", bg = "light blue", text='Quit', width=25, command=r.destroy)
button1.pack()
button4.pack()
r.mainloop()
main()