As a Python program who has just learned about Python GUI programming, write a program where the user can input the three costs. The program should then compute the total cost after it drops the lowest cost. Make use of object-oriented programming.
import tkinter as tk
window = tk.Tk()
label1 = tk.Label(text="First Price")
entry1 = tk.Entry()
label1.pack()
entry1.pack()
label2 = tk.Label(text="Second Price")
entry2 = tk.Entry()
label2.pack()
entry2.pack()
label3 = tk.Label(text="Third Price")
entry3 = tk.Entry()
label3.pack()
entry3.pack()
def check():
if len(entry1.get())>0 and len(entry2.get())>0 and len(entry3.get())>0:
a = int(entry1.get())
b = int(entry2.get())
c = int(entry3.get())
ans = a+b+c-min(a,b,c)
result = tk.Label(master=window, text=f"Total cost: {ans}")
result.pack()
btn = tk.Button(master=window, text="Total", command=check)
btn.pack()
Comments
Leave a comment