Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- def get():
- if len(e1.get()) == 0 or len(e2.get()) == 0:
- errorL = Label(w, text = "Fill in the entries.", fg = "red")
- errorL.grid(row = 2)
- else:
- pass
- firstNum = float(e1.get())
- secondNum = float(e2.get())
- answer = firstNum + secondNum
- answerText = Label(w, text = answer, fg = "green")
- answerText.grid(row = 3, column = 1, sticky = "w")
- w = Tk()
- w.geometry("450x400")
- w.title("Application")
- e1 = Entry(w)
- e2 = Entry(w)
- b1 = Button(w, text="Add", command = get)
- t1 = Label(w, text="First number: ")
- t2 = Label(w, text="Second number: ")
- helpText = Label(w, text = "Answer: ")
- t1.grid(row = 0, column = 0)
- e1.grid(row = 0, column = 1, sticky = "w")
- t2.grid(row = 0, column = 2)
- e2.grid(row = 0, column = 3)
- b1.grid(row = 1, column = 0, sticky = "w")
- helpText.grid(row = 3, sticky = "w")
- w.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement