import PySimpleGUI as sg #Theme sg.theme('Python') #Layout layout = [ [sg.Text('Food Bill: $'), sg.InputText(size=(20,1))], [sg.Text('Drinks Bill: $'), sg.InputText(size=(15,1))], [sg.Text('Do you wish to tip?'), sg.Button('Yes', key='YES'), sg.Button('No', key='NO')], [sg.InputText(size=(25,1), key='TIP', visible=False)], [sg.Text('How many people are paying? '), sg.InputText(size=(15,1), key='PEOPLE')], [sg.Button('Submit', key='SUBMIT')], [sg.Text('')], [sg.Text('Split Bill:')], [sg.Text('', size=(25,1), key='output1')], [sg.Text('', size=(25,1), key='output2')], [sg.Text('', size=(25,1), key='output3')], [sg.Text('', size=(25,1), key='output4')], [sg.Text('', size=(25,1), key='output5')], [sg.Text('', size=(25,1), key='output6')] ] #Defining Window window = sg.Window('Split bill', layout) mealTotal = 0 tipTotal = 0 total_bill = 0 split_bill = 0 Individual_Tip = 0 Tip_Split = 0 #Total Bill def totalBill(): food = int(values[0]) drink = int(values[1]) mealTotal = food+drink #TipButton def TipButton1(): window['YES'].Update(visible = True) tipTotal = int(values['TIP']) def TipBill(): total_bill = mealTotal + tipTotal def SplitBill(): numOfPpl = int(values['PEOPLE']) split_bill = mealTotal/numOfPpl def IndiviualTip(): Individual_Tip = tipTotal/numOfPpl def TipSplit(): Tip_Split = total_bill/numOfPpl #Making Loop while True: #Creating Window event, values = window.read() if event == 'Yes': TipButton1() if event == 'Sumbit': totalBill() TipBill() SplitBill() IndiviualTip() TipSplit() window.find_element('output1').Update("Your Total Bill is: $", "mealTotal") window.find_element('output2').Update("Your Overall Bill is: $", "total_bill") window.find_element('output3').Update("Your Tip Bill is: $", "tipTotal") window.find_element('output4').Update("Your Split Bill is: $", "split_bill") window.find_element('output5').Update("Your Individual Tip is: $", "Individual_Tip") window.find_element('output6').Update("Your Individual Bill is: $", "Tip_Split") if event == 'No': if event == 'Submit': totalBill() SplitBill() window.find_element('output1').Update("Your Total Bill is: $", "mealTotal") window.find_element('output2').Update("Your Individual Bill is: $", "split_bill") if event == 'Close': window.close()