I am trying to Create a GUI in Python that calculate the average of three numbers. I am having some issues tring to create the three boxes where the user should enter the numbers, so can anybody please give me a hand? Thank you so much!!!!
Here is a generic program templet that takes 2 numbers, checks the input, processes the entered data and shows the result. The Tkinter GUI toolkit is used. You can easily add additional inputs and change the processing to whatever you want ...
# a general Tkinter program to enter two numbers and process them
# for Python2
import Tkinter as tk
# for Python3
import tkinter as tk
""" take the two numbers entered and process them """
x = float(enter1.get())
y = float(enter2.get())
# the process step ...
s = str(x + y)
label3.config(text='Enter numeric values for x and y')
# create the root window
root = tk.Tk()
# create all the components/widgets
label1 = tk.Label(root, text='Enter number x:', width=28)
enter1 = tk.Entry(root, bg='yellow')
label2 = tk.Label(root, text='Enter number y:')
enter2 = tk.Entry(root, bg='yellow')
button1 = tk.Button(root, text='Add the numbers', command=calculate)
# the result label
label3 = tk.Label(root, text='', bg='green')
# pack widgets vertically in the root window in that order
# cursor in enter1
# return key in enter1 sets focus to enter2
# start the event loop